Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Writing JPG with alpha channel

Hi all,

It seems that OpenCV cannot write JPEG images with alpha channel. For example, the code

Mat readMat = imread("water.png", IMREAD_UNCHANGED);
imwrite(string("water.jpg"), readMat);

using water.png, a 4-channel image downloaded from here with white background, produces a jpg image with 3 channels and black background. Is this a bug in OpenCV, or expected behavior?

Thanks.

Writing JPG with alpha channel

Hi all,

It seems that OpenCV cannot write JPEG images with alpha channel. For example, the code

Mat readMat = imread("water.png", IMREAD_UNCHANGED);
imwrite(string("water.jpg"), readMat);

using water.png, a 4-channel image downloaded from here with white background, produces a jpg image with 3 channels and black background. Is this a bug in OpenCV, or expected behavior?

Thanks.