Page 1 of 1

From High res to 320x200 16 colors

Posted: 2014-06-03T23:30:32-07:00
by einstein1969
Hi to all,

I'm new to forum and i like very much ImageMagik!

I have some image/photos with resolution 1024x768 with many colors to display in a window dos batch at resolution max of 320x200.

The windows dos batch have 16 colors. The palette is the default windows 16 colors palette

I have read the documentation of ImageMagick and i thinks that there are several method to reduce size and color to this new values.

For achieve the maximum quality what is the better method of conversion?

Or if not exist a better method, what are the major methods for resize to resolution 320x200 and 16 color using the default windows palette?

einstein1969

Re: From High res to 320x200 16 colors

Posted: 2014-06-04T09:42:59-07:00
by fmw42
Grab the image of the 16 color palette from your link. Be sure it is not JPG. It appears to be png, so that is fine. Then use the following

Code: Select all

convert yourimage -resize 320x200 +dither -remap Windows_16colors_palette.png resultimage

see
http://www.imagemagick.org/Usage/quantize/#remap
http://www.imagemagick.org/script/comma ... php#resize
http://www.imagemagick.org/script/comma ... p#geometry

Re: From High res to 320x200 16 colors

Posted: 2014-06-04T09:47:13-07:00
by snibgo
(All following commands are Windows BAT syntax. Adjust for other shells.)

The basic method would be:

Code: Select all

convert in.png -resize "320x200^!" -remap pal16.png out.png
... where you have created pal16.png with this:

Code: Select all

convert ^
  xc:#000000 xc:#800000 xc:#f00000 xc:#008000 ^
  xc:#00ff00 xc:#808000 xc:#ffff00 xc:#000080 ^
  xc:#0000ff xc:#800080 xc:#ff00ff xc:#008080 ^
  xc:#00ffff xc:#808080 xc:#c0c0c0 xc:#ffffff ^
  +append ^
  PAL24:pal16.png
There are many options for resize. See many posts on downsampling by user NicolasRobidoux (memberlist.php?mode=viewprofile&u=17521). As you are reducing to 16 colours, I doubt that his refinements would make much difference.

For the colour reduction, you can specify the colorspace for quantization. This does make a difference. Eg:

Code: Select all

convert in.png -resize "320x200^!" -remap pal16.png out.png

Code: Select all

convert in.png -resize "320x200^!" -quantize RGB -remap pal16.png out.png

Code: Select all

convert in.png -resize "320x200^!" -quantize Lab -remap pal16.png out.png
I forget which quantize I mostly prefer for general photographs, but I do remember an important conclusion: the "best" one varies between photographs, and the only way to automate this was to try a remap with every possible colorspace, and do an RMSE comparison for every colorspace with the original photo. The one with the lowest score was the best colorspace to use.


[Fred has posted while I was writing. He suggests "+dither", which turns dithering off. This might, or might not, do what you want.]