Reliable way to check if image is Grey scale
问题 I am currently working on one use case where i need to determine if uploaded image is Grey Scale or RGB. I found couple of ways to identify this, but not sure if they are reliable and can be used collectively to confirm image is grey scale or not. Part 1: Read Image and get NumberDataElements using Raster. BufferedImage image = ImageIO.read(file); Raster ras = image.getRaster(); int elem = ras.getNumDataElements(); I observed value of elem is "1" in some cases, but not in all. Part 2: Check