ImageIO : cannot read image with CMYK color space

FranckJS picture FranckJS · Feb 23, 2011 · Viewed 12.6k times · Source

I have a problem to read a specific jpeg image (CMYK color space) which have been created with ImageMagick :

inputStream = new ByteArrayInputStream(bytesImage);
bufferedImage = ImageIO.read(inputStream); 
//IIOException : unsupported image type

I tried to use JAI instead of ImageIO but it still doesn't work :

seekableStream = new ByteArraySeekableStream(bytesImage);
bufferedImage = JAI.create("Stream", seekableStream).getAsBufferedImage();
//Unable to render RenderedOp for this operation

Any idea to solve my problem?

Answer

Codo picture Codo · Aug 26, 2012

Reading JPEG images with CMYK colors is rather tricky in Java. But I've posted a complete solution here. It solves the problem of dark colors becoming white as well.