2008.11.21 19:11 "Re: [Tiff] 24 bit Color to 8 bit Palettized Conversion Utility (tiffcp enhancement/variation?)", by Bob Friesenhahn
Did you try VIPS? VIPS is able to accomplish many things without loading the whole image into memory and it is usually quite fast. I don't know if its color reduction works without loading the whole image though since that would require a several-pass algorithm.
Actually, from looking at the VIPS documentation, I am not finding an algorithm for color reduction at all. Maybe it does not exist. :-( Still, a programmer could use the VIPS API to develop a muti-pass color reduction algorithm.
In order to color reduce you need to
- Build a color tree / histogram of the existing colors in the image. This requires reading all the image pixels.
- Evaluate the color tree and build a colormap which best approximates it.
- Re-read the image pixels and generate colormap indexes which best approximate the image given the colormap which was selected. This may include dithering.
So it can be seen that to color reduce an image using the color tree / histogram method requires reading the pixels at least twice. RAM is now about 10,000 times faster than disk so reading from disk multiple times is prohibitive unless the decoded image can not fit in RAM.
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/