Page 1 of 1

gif to png; changing one color

Posted: 2010-07-04T03:07:44-07:00
by Jyaif
Hi,
First of all, I am a relatively new user to ImageMagick, so I might be doing something wrong.
I am using: ImageMagick 6.6.2-9 2010-07-04 Q16 with OS X 10.6.2
I installed with MacPorts. No newer version of IM is available with MacPorts.

First, I tried to convert a gif to a png.

Code: Select all

convert a.gif a.png
convert: tRNS chunk has out-of-range samples for bit_depth `a.png' @ warning/png.c/PNGWarningHandler/1457.
The gif has transparency. The resulting png has not: the transparent pixels became green.

I accidentally found a work around. This command gives the correct result:

Code: Select all

convert a.gif -fill 'rgb(0,0,0)' -opaque 'rgb(0,0,0)' a2.png
Now, I want to change a single color:

Code: Select all

convert a2.png -opaque 'rgb(248,248,248)' -fill 'rgb(255,0,0)' b.png
It does not work either, all the 248,248,248 pixels become black :(

So, are those problems bugs, or is it normal ?

a.gif: Image
a.png: Image
b.png: Image

Re: gif to png; changing one color

Posted: 2010-07-04T06:00:24-07:00
by Drarakel
I think, you accidentally switched the options with your last command... Use this:
convert a2.png -fill 'rgb(255,0,0)' -opaque 'rgb(248,248,248)' b.png

Regarding the disappearing transparency: There are some issues with PNG lately.
In the meantime, you could also add '-type TrueColorMatte' in order to preserve the transparency:
convert a.gif -type TrueColorMatte a.png

If you need a smaller file size, then you could use a PNG optimizing tool afterwards.
http://www.imagemagick.org/Usage/formats/#png_non-im

Re: gif to png; changing one color

Posted: 2010-07-04T06:16:11-07:00
by Jyaif
Thanks, everything you said worked :)

Re: gif to png; changing one color

Posted: 2010-07-04T23:21:17-07:00
by anthony
The bug however still remains. At least at this time.