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

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
zxsz4084
Posts: 25
Joined: 2015-03-31T01:31:44-07:00
Authentication code: 6789

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

Post by zxsz4084 »

Dear Qins:
which command can judge whether a png pic has alpha channel ?
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

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

Post 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"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

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