Count of colors by a picture

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
lelldorin
Posts: 8
Joined: 2017-06-11T13:56:45-07:00
Authentication code: 1151

Count of colors by a picture

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Count of colors by a picture

Post 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/
Post Reply