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?
PNG with indexed palette
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: PNG with indexed palette
-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.
Glennrp is the developer.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: PNG with indexed palette
As for your problem, assuming it is exactly two colors and no gradient. try...
The lighter color will map to blue, the darker to red.
Code: Select all
convert image -colorspace gray -normalize +level-colors red,blue result
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/