Reduce numbers of colors in a PNG24 with Alpha Channel

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
lilith
Posts: 8
Joined: 2010-10-06T23:37:50-07:00
Authentication code: 8675308

Reduce numbers of colors in a PNG24 with Alpha Channel

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply