Døner M.
Døner M.

Reputation: 353

Color reduction with ImageMagick

There's an image I convert to grey in a first step using this:

convert out.jpg -colorspace GRAY -normalize png:out.png

In another step I would like to reduce colors to 12:

convert out.png +dither -colors 12 -filter box -normalize png:out.png

This works perfectly with a very old version of GraphicsMagick which I have installed on one machine. On another machine is the latest version of ImageMagick. Here the resulting image just has 8 colors.

Is there a way I can force ImageMagick to make exactly 12 colors? Not more, not less?

Upvotes: 7

Views: 5947

Answers (2)

fmw42
fmw42

Reputation: 53174

You can create our own 12 color colorable image and use -remap to recolor your image. See http://www.imagemagick.org/Usage/quantize/#remap and use -dither none

Upvotes: 0

rostok
rostok

Reputation: 2137

Use the -posterize switch

convert colors.png -colorspace gray +dither -posterize 12 mono12.png

Upvotes: 8

Related Questions