using fixed number of colors in image

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
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

using fixed number of colors in image

Post by manit »

I know that to find out the number of colors in image I can use
$identify -format "%k" file
In grub boot loader we can set image as background of menu but the restriction is image should be 640x480 ( resizing I know ) and have not more than 16 colors ( preferred 12 ) .

Currently I use gimp in which I do image > mode > indexed & set palette to 12.
[question]how can I use command of imagemagick to do this ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: using fixed number of colors in image

Post by fmw42 »

try

convert image -resize ... +dither -colors 12 -type palette result.gif
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

Thank You. It worked .

Post by manit »

If I don't use +dither then I get 5 colors
and if I use +dither then I got 10 though palette given as 12 in both.

I will read http://www.imagemagick.org/Usage/quantize/
Should I read anything else to understand better ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Thank You. It worked .

Post by fmw42 »

manit wrote:If I don't use +dither then I get 5 colors
and if I use +dither then I got 10 though palette given as 12 in both.

I will read http://www.imagemagick.org/Usage/quantize/
Should I read anything else to understand better ?
-colors does not enforce exact number of colors, but sets the maximum it will produce.

the reading on quantize is the only one I know apart from http://www.imagemagick.org/script/quantize.php which is linked inside that page
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: using fixed number of colors in image

Post by magick »

Add -treedepth 8 to your command line.
Post Reply