Page 1 of 1

which command can judge whether a png pic has alpha channel ?

Posted: 2015-05-06T04:17:00-07:00
by zxsz4084
Dear Qins:
which command can judge whether a png pic has alpha channel ?

Re: which command can judge whether a png pic has alpha channel ?

Posted: 2015-05-06T05:35:18-07:00
by glennrp
My favorite is "pngcheck", which you can get fromhttp://www.libpng.org/pub/png/apps/pngcheck.html

Code: Select all

pngcheck file.png
On *nix, you have "file" and can type

Code: Select all

file file.png
(although this will miss PNG files where the alpha is conveyed via the tRNS chunk).

If you prefer to use ImageMagick, type

Code: Select all

identify -verbose file.png
and look for lines containing "png:IHDR.color_type:" and "png:tRNS"

Re: which command can judge whether a png pic has alpha channel ?

Posted: 2015-05-06T10:20:49-07:00
by fmw42
see string format %[channels] or %[opaque] at http://www.imagemagick.org/script/escape.php

Code: Select all

convert image -format " %[channels]" info:

Code: Select all

convert image -format " %[opaque]" info: