Page 1 of 1

Reduce numbers of colors in a PNG24 with Alpha Channel

Posted: 2010-10-06T23:52:59-07:00
by lilith
Hello everybody,
Thanks in advance for your time.

I want to reduce the number of colors in my PNG24 with alpha channel. To do that, i use the code :

Code: Select all

convert -colors 500 "image.png" "image.png"
It works, but it also destroys the Alpha restitution.

Is there a way to reduce colors in the RGB data only, without deterioring the Alpha Channel ?

I tried this option, but i think i do not use correctly, because it does not work.

Code: Select all

-channel
If it's not possible, i would like to know if it is possible to copy an Alpha Channel data from a file to another.
I tried also another approch :

- Extract the Alpha Channel data from a PNG24 to an external PNG file ; (DONE)
- Set Alpha Off, reduce number of colors, and Set Alpha On ; (DONE)
- Copy the Alpha Channel data to the reduced color PNG file. (NOT DONE)

How can i copy the Alpha Channel data to the reduced color PNG file ?
Thanks for your time.

Cheers.

Re: Reduce numbers of colors in a PNG24 with Alpha Channel

Posted: 2010-10-07T06:14:11-07:00
by anthony
Set -quantize transparent

yes it seems weird but that tells IM to ignore transparency when reducing colors
See http://www.imagemagick.org/Usage/quantize/#color_trans