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?
How to reduce number of colors the right way?
Re: How to reduce number of colors the right way?
-depth should have a value or not be there which may be your problem.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to reduce number of colors the right way?
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
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.
+dither prevents -colors from dithering the colors
Code: Select all
convert image.jpg +dither -colors 16 image-16.jpg
Code: Select all
convert image.jpg +dither -colors 16 -depth 4 image-16.jpg
Re: How to reduce number of colors the right way?
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.
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to reduce number of colors the right way?
Palette PNG is similar to GIF. So that is fine