The ImageMagik command:
identify -format '%[channels]' foo.png
will print rgba
or rgb
if there is or is not an alpha channel, respectively.
There could be an alpha channel present with no data in it which wouldn't actually have any transparency, but that is a bit more complicated.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…