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?".
I would like to create an indexed PNG8 image as efficiently as possible. Thus far I've been using the -clut operator, and then pngnq to reduce the number of colors. Accordion to the documentation, -clut replaces the original pixels:
Given two images, replace the channel values in the first image using each corresponding channel in the second image as a color lookup table.
Does anyone know if there is an alternative way to using -clut so that rather than actually replacing the original pixels, it will merely associate the specified 1x256 color lookup table with the 8-bit image?
CLUT is as you said just a color lookup and replacement method. where the color values themselves (typically greyscale) are used for replacement. (It is also used for hisogram adjustment of color images using a (usally) greyscale image.
It does not actually 'find and replace' one color with another color (actual one-to-one color replacement), but uses color values (grayscale) to lookup the position in the CLUT image for a replacement color value.
It has nothing to do with color palettes, tables or indexes in reality.
however it is posible to create a index pallete assignment function, it just does not exist at this time.
As long as after the assignment the image does not modify or add more colors
to the image to invalidate the palette, then Im should be able to save it to index images formats ( like PNG8 or GIF).
What is needed is programmers with the time to work on this!
anthony wrote:CLUT is as you said just a color lookup and replacement method. where the color values themselves (typically greyscale) are used for replacement. (It is also used for hisogram adjustment of color images using a (usally) greyscale image.
It does not actually 'find and replace' one color with another color (actual one-to-one color replacement), but uses color values (grayscale) to lookup the position in the CLUT image for a replacement color value.
It has nothing to do with color palettes, tables or indexes in reality.
however it is posible to create a index pallete assignment function, it just does not exist at this time.
As long as after the assignment the image does not modify or add more colors
to the image to invalidate the palette, then Im should be able to save it to index images formats ( like PNG8 or GIF).
What is needed is programmers with the time to work on this!
I just built a script that allows one to translate one set of colors in an image to another set from a list of color pairs in a file. So you can have many colors changed like in a colormap table. See mapcolors script at http://www.fmwconcepts.com/imagemagick/index.html
Last edited by fmw42 on 2009-03-23T11:39:28-07:00, edited 1 time in total.
Afetr just reading your options I think you can improve it further.
Extract and save the transparency channel of an image, and make it 'opaque' (see -alpha operator) in the working image. You can then safely use the 'none' color as an intermediate for ALL images, and then just restore the alpha channel.
Of course this will only work if the user wants to replace color regardless of there transparency (that is treat semi-transparent as an opaque color for replacement) but that is a very common requirement and makes for a good strategy.
If transparency is important in the replacement, then perhaps using semi-transparent color as the safe color would be better and less important.
Another option that would be useful but difficult to do using a command line replacement method, is a 'default color' that is the color to assign if none of the colors being replaced match (with the fuzz factor of course). For this to work you will need to be able loop though the image one pixel at a time doing the color replacements.