I tried the following:
convert file.png -background \#FFFFFF -flatten -resize '192x128>' -quality 50 small.jpg
to convert a PNG file with transparency to JPG. The transparent area stays black in the result however. What's wrong?
IM 6.0.7 coloring transparency in png to jpg fails
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: IM 6.0.7 coloring transparency in png to jpg fails
Try this and go from there. This works. Learned it from Anthony Thyssen
Recoloring transparent areas
# create test image (red square surrounded by black)
convert -size 100x100 xc:red -bordercolor black -border 50 tmp.png
# to make red transparent
convert tmp.png -transparent red tmp1.png
# to make transparent red (-opaque is -channel effected)
convert tmp1.png -channel RGBA -fill red -opaque none tmp2.jpg
Recoloring transparent areas
# create test image (red square surrounded by black)
convert -size 100x100 xc:red -bordercolor black -border 50 tmp.png
# to make red transparent
convert tmp.png -transparent red tmp1.png
# to make transparent red (-opaque is -channel effected)
convert tmp1.png -channel RGBA -fill red -opaque none tmp2.jpg
Re: IM 6.0.7 coloring transparency in png to jpg fails
It finally goes! Whow, great. Thanks a lot!
Note that images without transparency get disrupted by this, so it can't be used in batch on mixed sources!
Everybody please note, too, that I took the failing way using the -flatten operator from some manual here on PNG to JPG, which is obviously wrong then. Maybe someone wants to update that...
Note that images without transparency get disrupted by this, so it can't be used in batch on mixed sources!
Everybody please note, too, that I took the failing way using the -flatten operator from some manual here on PNG to JPG, which is obviously wrong then. Maybe someone wants to update that...
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: IM 6.0.7 coloring transparency in png to jpg fails
Your real problem however is you IM is very very old. At least 3 to 4 years old. I suggest you upgrade before you start complaining about the many other problems that have long since been fixed.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/