読者です 読者をやめる 読者になる 読者になる

ImageIO で出るエラー

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;

public class Main {

    public static void main(String[] args) throws Exception {
        try (FileInputStream fis = new FileInputStream("test.jpg")) {
            BufferedImage bi = ImageIO.read(fis);
        }
    }
}

CMYK を読むとエラー

 Caused by: javax.imageio.IIOException: Incompatible color conversion
        at com.sun.imageio.plugins.jpeg.JPEGImageReader.checkColorConversion(JPEGImageReader.java:973)

カラースペースが特殊だとエラー

Caused by: java.lang.IllegalArgumentException: Numbers of source Raster bands and source color space components do not match
    at java.awt.image.ColorConvertOp.filter(ColorConvertOp.java:482)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.acceptPixels(JPEGImageReader.java:1263)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImage(Native Method)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1231)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1034)
    at javax.imageio.ImageIO.read(ImageIO.java:1448)
    at javax.imageio.ImageIO.read(ImageIO.java:1352)

参考: