PNG 8bit monochrome, how?

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
Tino Didriksen

PNG 8bit monochrome, how?

Post by Tino Didriksen »

Using ImageMagick 6.5.1-0 2009-08-27 Q16 OpenMP

I need to convert a colored image to an 8 bit monochrome PNG. Not a grayscale PNG nor a 1/2/4/16/24/32 bit PNG, but 8 bit with the only colors in the palette being black and white. Yes, I know that is silly, but that is what I need.

My current closest attempt is:

Code: Select all

convert 32bitcolors.png -alpha off -dither None -monochrome PNG24:tmp.png
convert tmp.png -depth 8 -colors 256 PNG8:blackwhite.png
However, that produces a 1 bit paletted PNG. Very close to what I want, but not quite...

If I leave out the PNG8: or use -colors 2 then it becomes a grayscale PNG.
If I add -depth 8 or -define png:color-type=3 or -define png:bit-depth=8 or combinations thereof, it has no effect.

What is the magic combination to make IM do as I want?
Post Reply