Prevent using ImageMagick for indexed colors?

I have PNG images with transparency. However, whenever I do any ImageMagick operation on the image (eg cropping), it changes some of the images to be "indexed" instead of RGB. The images that change are those with fewer than 256 colors, but the conversion destroys transparency.

In some research, I found that you can add the filename with png32:

for forced RGB, but that only works when using the command convert

, not mogrify

.

I can add -format png32

with mogrify, but renaming all images to *.png32

.

Presumably you can do this:

mogrify -define png:format=png32 -format png *.png

      

But that doesn't work, images are still indexed with non-RGB color. How to force PNG32 with mogrify?

+6


source to share


1 answer


Your command should work if you are using the latest version of ImageMagick (6.9.1-3 or newer).

Earlier versions will work if you use -format png32

as you did, then run the script to rename them back to * .png.



According to the ImageMagick 6 changelog , the option "-define png: format = png32" was added to ImageMagick in version 6.7.3-0, but a bug was introduced in version 6.8.9-0 that made it ignored. under certain circumstances; this bug has been fixed in version 6.9.1-3.

So the answer to your question is to either work around this issue by letting you mogrify

rename your input files to * .png32, or upgrade ImageMagick to 6.9.1-3 or later.

+6


source







All Articles