Page 1 of 1
How to reduce number of colors the right way?
Posted: 2017-04-04T09:17:43-07:00
by pbeitbeor
I want to reduce the number of colors of a jpg image to 16, with the following command:
convert -depth -colors 16 image.jpg image-16.jpg
When I count the colors in the image it's about 24000.
What is the correct convert syntax to get a color count of 16?
Re: How to reduce number of colors the right way?
Posted: 2017-04-04T09:27:17-07:00
by Bonzo
-depth should have a value or not be there which may be your problem.
Re: How to reduce number of colors the right way?
Posted: 2017-04-04T09:37:02-07:00
by fmw42
Proper IM 6 syntax reads the input image first, then the settings, then any operators, then the output. So your command should be something like
Code: Select all
convert image.jpg +dither -colors 16 image-16.jpg
However, jpg is compressed and thus the compression will likely change your colors and you will probably get more colors than you want. If you save to GIF, you can reduce the colors without producing more colors due to the jpg compression.
Code: Select all
convert image.jpg +dither -colors 16 -depth 4 image-16.jpg
+dither prevents -colors from dithering the colors
Re: How to reduce number of colors the right way?
Posted: 2017-04-04T12:54:40-07:00
by pbeitbeor
Thanks to both of you.
I gave it a little twist. I converted the image to png (not gif) and used the last command with it.
That did it for me.
Re: How to reduce number of colors the right way?
Posted: 2017-04-04T12:57:52-07:00
by fmw42
Palette PNG is similar to GIF. So that is fine