ConvertTo-Jpeg icon indicating copy to clipboard operation
ConvertTo-Jpeg copied to clipboard

PNG to JPG conversion with transparency

Open xoscov opened this issue 2 years ago • 4 comments

I need to convert png images to jpg but when converting it converts them to JPG with transparency even from PNG images that don't have transparency, is there a way to prevent this from happening so they convert to jpg images with a white background?

thank you

xoscov avatar Jan 14 '23 18:01 xoscov

Not sure what you're seeing, but I don't think the JPEG format supports transparency.

https://www.google.com/search?q=jpeg+transparency+support&ie=UTF-8&oe=UTF-8&hl=en-us&client=safari

DavidAnson avatar Jan 14 '23 19:01 DavidAnson

I am referring rather to the fact that a black background remains in the image instead of white as is usually seen in jpg images, but I just verified that it only happens when converting PNG images with transparency to jpg, the following images are an example What I'm talking about, the first one is in png format with transparency, when you convert it with the script a you can see the image with a black background as shown in the second image.

CSBC1C-LAT-DER-lc

CSBC1C-LAT-DER-l

xoscov avatar Jan 15 '23 04:01 xoscov

I'm not sure white is any better choice than black as a replacement color for transparency, but it's not something this script currently chooses. There may be a way to tell the conversion functions to use white, but I didn't find it after a couple of searches just now, sorry!

DavidAnson avatar Jan 15 '23 04:01 DavidAnson

ok I understand, I'll investigate about it, in any case thank you very much.

xoscov avatar Jan 15 '23 04:01 xoscov