java ImageIO : 无法读取 CMYK 颜色空间的图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5089324/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 09:21:08  来源:igfitidea点击:

ImageIO : cannot read image with CMYK color space

javajavax.imageiojai

提问by FranckJS

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

我在读取使用 ImageMagick 创建的特定 jpeg 图像(CMYK 颜色空间)时遇到问题:

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 :

我尝试使用 JAI 而不是 ImageIO 但它仍然不起作用:

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

Any idea to solve my problem?

有什么想法可以解决我的问题吗?

回答by Codo

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.

在 Java 中读取带有 CMYK 颜色的 JPEG 图像相当棘手。但我已经在这里发布了一个完整的解决方案。它还解决了深色变白的问题。

回答by FranckJS

Since I have found my image has a CMYK color space, I have found a solution on stackoverflow : Problem reading jpeg image using imageio

由于我发现我的图像具有 CMYK 颜色空间,因此我在 stackoverflow 上找到了解决方案:使用 imageio 读取 jpeg 图像时出现问题

Now, the problem is the quality of my resulting image... dark colors became white...

现在,问题是我生成的图像的质量……深色变成了白色……