You can check if the color model of the image includes an alpha channel:
BufferedImage img = ImageIO.read(/* from somewhere */); if (img.getColorModel().hasAlpha()) { // img has alpha channel } else { // no alpha channel }
Please note: this code only detects images saved with the alpha channel. Images with an alpha channel can still be completely opaque (i.e. alpha = 1 for all pixels).
source share