Page 1 of 1

How to get 8-bit alpha with PNG32

Posted: 2013-04-11T15:36:46-07:00
by bricker
I need to generate PNG32 files with 8-bit alpha channels. I consistently get a 1-bit alpha channel with commands such as:

convert foo.jpg PNG32:out.png
convert foo.jpg -define png:format=png32 out.png
convert foo.jpg -define png:color-type=6 out.png
convert foo.jpg -type truecolormatte PNG32:out.png

and all combinations of those options. I have tried 6.8.4-8-Q16-x64-dll (latest precompiled Windows) and also Linux self compiled versions of 6.6.3-10, 6.7.5-6 and 6.8.4-8. Any suggestions would be greatly appreciated!

Re: How to get 8-bit alpha with PNG32

Posted: 2013-04-11T16:15:28-07:00
by glennrp
You are writing a PNG with an 8-bit alpha channel. "identify" reports that it's one-bit because it is all-opaque, which can be expressed with only one bit after it's read back into ImageMagick.

Re: How to get 8-bit alpha with PNG32

Posted: 2013-04-11T21:13:17-07:00
by anthony
Basically try it with an image that actually contains some real alpha transparency gradients.

Re: How to get 8-bit alpha with PNG32

Posted: 2013-04-16T07:02:46-07:00
by bricker
Adding variance in the alpha channel of course results in 8-bit alpha. I believe that identify is correctly reporting the 1-bit alpha channel as stored in the PNG, not after some internal conversion (which would make identify largely useless IMO). The acid test is the application consuming the PNGs, which insists on 8-bit alpha and rejects the PNGs with 1-bit alpha as produced in my original post. So I remain flummoxed as to why convert et al. aren't encoding 8-bit alpha as requested.