PNG with indexed palette

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
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

PNG with indexed palette

Post by GreenKoopa »

I have a PNG image containing only two colors in its palette. I need to change these two colors from certain rgb values to certain other rgba values. I can easily achieve this, but it is very slow. I think the time is spent rebuilding the color table. Is there a fast way to poke new values into the color table?

If not, I'll take the 10x increase in file size for the 10x speedup. -type TrueColorMatte still leaves me in indexed palette mode. -define png:color-type=6 does take me to true RGBA. What does -type do?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: PNG with indexed palette

Post by anthony »

-type is a hint to the image coder. PNG coder has many other options and generally ignored the type. It did no tuse to do that but now does in a recent expansion of the coder. Specifically with generating smaller palette PNG images.

Glennrp is the developer.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: PNG with indexed palette

Post by anthony »

As for your problem, assuming it is exactly two colors and no gradient. try...

Code: Select all

    convert image   -colorspace gray -normalize  +level-colors  red,blue  result
The lighter color will map to blue, the darker to red.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply