PNG Transparency Bug (mogrify)

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
redkahuna
Posts: 9
Joined: 2012-03-01T00:32:56-07:00
Authentication code: 8675308

PNG Transparency Bug (mogrify)

Post by redkahuna »

version: ImageMagick-6.7.5-7-Q16-windows-dll.exe

Small PNG 32bit images that only have greyscale colors with full 8bit alpha will not convert without loosing the alpha layer when using mogrify while convert still works.

"convert pngalpha.png -transparent none -resize 50% PNG32:pngalpha.png"
resulting in proper 32bit 50% scaled iamge

"mogrify pngalpha.png -transparent none -resize 50% PNG32:pngalpha.png"
resulting in proper 8 bit image index color

I spend hours trying everything to get mogrify to work but with no success. :(
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: PNG Transparency Bug (mogrify)

Post by glennrp »

redkahuna wrote: "mogrify pngalpha.png -transparent none -resize 50% PNG32:pngalpha.png"
resulting in proper 8 bit image index color
The first "pngalpha.png" in this command shouldn't be there. Removing it does
not help, though. This works (using -format PNG32 instead of the PNG32: prefix):

Code: Select all

mogrify -transparent none -resize 50% -format PNG32 pngalpha.png
I don't know if it's a bug or just the way things are.
redkahuna
Posts: 9
Joined: 2012-03-01T00:32:56-07:00
Authentication code: 8675308

Re: PNG Transparency Bug (mogrify)

Post by redkahuna »

Thanks gleenrp,
It creates the correct image properties but now I need a way to truncate the name on output.

Code: Select all

mogrify -transparent none -resize 50% -format PNG32 pngalpha--large.png
file result: pngalpha--large.PNG32

Is there a way to change the extension back to lowercase .png (not .PNG32) and truncate the name to pngalpha.png?

Also another bug exists where using this in a resize.bat dos script it will remove the resize % argument and turn it into a pixel width instead?
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: PNG Transparency Bug (mogrify)

Post by glennrp »

redkahuna wrote: Is there a way to change the extension back to lowercase .png (not .PNG32)
In recent versions (6.7.3-0 and later) you can use "-define png:format=png32" instead of "-format png32" and that does not change the extension.
redkahuna
Posts: 9
Joined: 2012-03-01T00:32:56-07:00
Authentication code: 8675308

Re: PNG Transparency Bug (mogrify)

Post by redkahuna »

Thanks glennrp!
Ipsquiggle
Posts: 1
Joined: 2012-08-01T12:51:11-07:00
Authentication code: 15

Re: PNG Transparency Bug (mogrify)

Post by Ipsquiggle »

So even though glennrp helpfully provided a workaround, this is still a glaring bug (using 6.7.8-5).

I can't imagine any circumstance where I would want mogrify to change the format of my image without me explicitly saying so, or unless an operation requires it (e.g. adding an alpha channel to a BMP24 could reasonably convert it to a BMP32). That is to say, this may be a more systemic issue than just the PNG32 case.

It's pretty weird to have to tell mogrify "Yeah, crop this png, oh and by the way, don't trash most of the information in the image, thanks."

Especially since it's already (apprently) working correctly with convert!

Thanks
Post Reply