Page 1 of 1

Keeping the original (source) image PNG color space

Posted: 2007-11-14T03:40:12-07:00
by atom
Hello. Is there a way for mogrify/convert to use the same color depth as the input image automatically? In particular, it seems that ImageMagick defaults to write 16-bit/color (A)RGB PNG files since somewhere between 6.2.4 and 6.2.9, which causes things like "mogrify -crop" or "mogrify -convert" to produce files with a much larger file size than the input file, even though they have a lower resolution. Older versions such as 6.2.4 seem to default to write 8-bit/color (A)RGB png files, which although is better, is not perfect:

I've seen posts such as http://studio.imagemagick.org/discussio ... f=1&t=9731 and http://studio.imagemagick.org/pipermail ... 01706.html suggesting to override the defaults with either "-depth 8" or the "png24:" prefix for output filename.

This doesn't produce desired results if the input image is, say, a 256-color indexed/palette image.

Example results from 6.2.4, 6.2.9 and 6.3.6:
Input image:
lo.png: PNG image data, 963 x 558, 8-bit colormap, non-interlaced - 155108 bytes

Result using ImageMagick 6.2.4:
convert -scale 500x250 lo.png lo-624.png; file lo-624.png
lo-624.png: PNG image data, 431 x 250, 8-bit/color RGB, non-interlaced - 137615 bytes

Result using ImageMagick 6.2.9 and 6.3.6 (both give identical results):
convert -scale 500x250 lo.png lo-629.png; file lo-629.png
lo-629.png: PNG image data, 431 x 250, 16-bit/color RGB, non-interlaced - 378644 bytes

At least 6.2.4 produces a slightly smaller image, but it still converts from colormap to RGB...

Ideally, I'd like to have the output file use exactly the same "color space/depth" as the input, so that an 8-bit colormap input file gives an 8-bit colormap output file, while an 8-bit RGB input gives an 8-bit RGB output file. Is this possible to do without creating a script to parse the output of "identify" or "file" to determine which of several options (-depth? png24:? png8:? png32:?) to use to get the desired result?

Re: Keeping the original (source) image PNG color space

Posted: 2007-11-19T18:57:08-07:00
by anthony
IM handling of PNG is not as complete as many people would like. generally it outputs variations of 16bit PNG with just one option for PNG8 (GIF like - yuck)

the best idea is to use a OptiPNG or some other more specialized tool to set the specific PNG format you want.

Sorry.

Re: Keeping the original (source) image PNG color space

Posted: 2007-11-20T01:10:58-07:00
by atom
Awww :( Thanks for your reply in any case, I'll take a closer look at those png crushing applications :)