Page 1 of 1

Count of colors by a picture

Posted: 2017-08-01T07:54:58-07:00
by lelldorin
Hello

how can i get the used colors of an image using imagemagick?

I want to reduce the colors of an image to the lowest color value, but without lost the quality.

In corel Photo Paint 5 i have the option to reduce the colors to the only needed color.

Greetings Lelldorin

Re: Count of colors by a picture

Posted: 2017-08-01T09:13:19-07:00
by fmw42
Please always provide your IM version and platform when asking questions since syntax may vary.

In imagemagick you can get the list of unique colors via

Code: Select all

convert image -unique-colors -depth 8  txt:-
If you want to reduce the number of colors, you can use

Code: Select all

convert image +dither -colors N result
where N is the number of final colors you want.

If you want to convert your image to match a color table, then you need to create an image what contains only the colors you want, then

Code: Select all

convert image +dither -remap colortableimage result
See also
http://www.imagemagick.org/Usage/quantize/#remap

If you are using IM 7 rather than IM 6, then change convert to magick.

For novices, see

viewtopic.php?f=1&t=9620http://http://w ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/