Page 1 of 1

How to preserve color palette when resizing

Posted: 2007-01-17T15:20:36-07:00
by jmaeding
I typically keep images of maps and things as tifs with 8-bit color, with an optimized palette.
I do this through corel photo paint.
Many times, I want to resize a map or photo by 50%. I am using convert.exe so I tried:
convert USGS.tif -resize 50%% -compress rle USGSsmaller.tif

The %% is because I am running from a windows batch file, it works fine with other operations.
The result of the resize is the colorspace gets set to 48 bit, and the image is huge. So I tried:
convert USGS.tif -resize 50%% -colors 256 -compress rle USGSsmall.tif

with very bad results, mostly blue pixels, ugly.
Is there something I need to do to resize, while keeping the palette intact, or some other way to end up with 8bit optimized palette?
I don't mind if it makes the 48bit , then converts to 8 bit, I just dont know how to do it. -colors 256 is not doing it.
thanks

Posted: 2007-01-17T15:38:44-07:00
by el_supremo
You seem to have the Q16 version of ImageMagick installed, so it is saving each pixel as 16 bits. Add -depth 8 before the output filename.

Pete

Posted: 2007-01-17T15:46:06-07:00
by jmaeding
I tried that just now, did not work. The size action worked fine but I got a 24 bit rgb image instead of 8 bit.

Any reason why I should be using the Q16 as opposed to Q8? I just chose the one that looked the most powerful. Maybe its not suited to people that only work with 24bit and lower colors.
thanks

Posted: 2007-01-17T17:04:58-07:00
by anthony
Use -scale or -filter point to stop the resize creating new colors.
Results are however not as good.

Posted: 2007-01-17T18:37:44-07:00
by jmaeding
I tried that and many other combinations, I get 24 bit every time.
I even uninstalled Q16 and put on Q8 version, same results.

One clue is if I just run a:
convert USGS.tif -depth 8 USGS8.tif

It errors out. It says a bunch of lines like "unexpected field...".
The sizing works fine, its the palette stuff that is failing.
I can post a portion of the image if there is a convenient place so you can see.
I am amazed I am hitting these issues with the first image I try.
Many other things work super well with IM, you would think the resample would be cake :)