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?
Keeping the original (source) image PNG color space
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Keeping the original (source) image PNG color space
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.
the best idea is to use a OptiPNG or some other more specialized tool to set the specific PNG format you want.
Sorry.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Keeping the original (source) image PNG color space
Awww :( Thanks for your reply in any case, I'll take a closer look at those png crushing applications :)