gif to png; changing one color

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Jyaif
Posts: 3
Joined: 2010-07-04T02:37:56-07:00
Authentication code: 8675308

gif to png; changing one color

Post 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
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: gif to png; changing one color

Post 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
Jyaif
Posts: 3
Joined: 2010-07-04T02:37:56-07:00
Authentication code: 8675308

Re: gif to png; changing one color

Post by Jyaif »

Thanks, everything you said worked :)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: gif to png; changing one color

Post by anthony »

The bug however still remains. At least at this time.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply