Page 1 of 1

PNG with indexed palette

Posted: 2010-12-06T04:10:24-07:00
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?

Re: PNG with indexed palette

Posted: 2010-12-06T20:48:52-07:00
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.

Re: PNG with indexed palette

Posted: 2010-12-06T20:53:53-07:00
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.