Currently I'm replacing ImageMagick library with OpenCV in my project and encountered strange problem when working with transparent images (png format). When I load image which contains alpha channel - the image appears "broken", sometimes (when only background is transparent) it just has black background, but when contents of the image is itself transparent then it looks like on the screenshot. As far as I tried - the problem is reproducible in C++ and Python.
I tried converting from BGRA to RGBA - the issue is still there but with slightly different color in the resulting image. I also tried it with several images I found on the Internet so I suppose it's not just one broken image, but something with OpenCV or the way I try to use it. When I was using ImageMagick (v7) in C++ - images were loaded properly without such issues (but I still need to replace it due to other reasons, so sticking to the old library isn't an option).
The main question:
Is there something I should know to be able to read such images properly or this is just the way OpenCV works?
I'm using OpenCV versions 4.4.0 in Python and 4.3.0 in C++.
This is the code I'm using in Python:
import cv2
img = cv2.imread('/home/monkeber/Pictures/trans2.png', cv2.IMREAD_UNCHANGED)
cv2.imshow("image", img)
cv2.waitKey(0)
resized = cv2.resize(img, (0, 0), fx=0.5, fy=0.5, interpolation = cv2.INTER_LINEAR)
cv2.imshow("Resized image", resized)
cv2.waitKey(0)
UPD. It appears the same problem is present in Imgur service which is used on StackOverflow, when I tried to make images look smaller in the question - I had the exact same effect on the original image.