Page 1 of 1

using fixed number of colors in image

Posted: 2010-03-09T03:20:35-07:00
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 ?

Re: using fixed number of colors in image

Posted: 2010-03-09T10:21:57-07:00
by fmw42
try

convert image -resize ... +dither -colors 12 -type palette result.gif

Thank You. It worked .

Posted: 2010-03-10T03:08:47-07:00
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 ?

Re: Thank You. It worked .

Posted: 2010-03-10T09:22:58-07:00
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

Re: using fixed number of colors in image

Posted: 2010-03-10T10:05:32-07:00
by magick
Add -treedepth 8 to your command line.