How to get 8-bit alpha with PNG32

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
bricker
Posts: 2
Joined: 2013-04-11T15:30:41-07:00
Authentication code: 6789

How to get 8-bit alpha with PNG32

Post 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!
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: How to get 8-bit alpha with PNG32

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to get 8-bit alpha with PNG32

Post by anthony »

Basically try it with an image that actually contains some real alpha transparency gradients.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
bricker
Posts: 2
Joined: 2013-04-11T15:30:41-07:00
Authentication code: 6789

Re: How to get 8-bit alpha with PNG32

Post 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.
Post Reply