PNG Transparency Fields

Started by blue-j, December 08, 2021, 12:07:03 AM

Previous topic - Next topic

blue-j

Hi again!

Just as I was trying to do with GIFs, I am zooming in on transparency flags in PNGs, and I've found areas of ExifTool's coverage that could be improved.  I hope I can tee up the resources to make it easier to assess.

I've tested with PNGs with varying kinds of transparency, and ExifTool 12.36 seems to report a value of "0" no matter what, or binary data.

I've leveraged a variety of references for details on the possible values in the tRNS chunk:

https://docs.oracle.com/javase/8/docs/api/javax/imageio/metadata/doc-files/png_metadata.html
http://www.libpng.org/pub/png/book/chapter08.html#png.ch08.div.5

They appear to provide more detail than the canonical document:  http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.Anc-trns

My apologies in advance if I am being daft!  :p

- J

Phil Harvey

ExifTool could decode all of the tRNS entries, like this:

> exiftool ~/Desktop/Archive/ -colortype -transparency
======== /Users/phil/Desktop/Archive/clouds-transparent.png
Color Type                      : Palette
Transparency                    : 0
======== /Users/phil/Desktop/Archive/coffee-cup-background-removed.png
Color Type                      : Palette
Transparency                    : 0 3 3 3 129 192 129 66 192 192 192 66 192 192
192 192 129 192 192 66 129 192 192 192 66 66 192 66 192 129 66
======== /Users/phil/Desktop/Archive/alpha_test_5_layers.png
Color Type                      : Palette
Transparency                    : 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
0
======== /Users/phil/Desktop/Archive/google-logo-transparent.png
Color Type                      : Palette
Transparency                    : 0 128 128 128 128 128 128 128 128 128 128 128
128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
128 128 128 128 128 128 128 128
======== /Users/phil/Desktop/Archive/woz-signature-transparent.png
Color Type                      : Palette
Transparency                    : 0 1 128 1 128 128 128 128 128 128 128 128 128
128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
======== /Users/phil/Desktop/Archive/new-york-city-transparent.png
Color Type                      : Palette
Transparency                    : 0 128 128 128 1 128 128 1 128 128 128 128 128
128 128 128 128 128 128
======== /Users/phil/Desktop/Archive/desert-transparent.png
Color Type                      : Palette
Transparency                    : 0
======== /Users/phil/Desktop/Archive/alpha_test_5_layers_24.png
Color Type                      : RGB with Alpha
    1 directories scanned
    8 image files read


But I don't know how useful that would be.

The best documentation I found on tRNS is here:  http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).