简体   繁体   English

使用Java将RGB转换为CMYK

[英]RGB TO CMYK conversion using Java

I'm trying to convert an RGB image to a CMYK image using Java. 我正在尝试使用Java将RGB图像转换为CMYK图像。 I've looked at this code: 我看了下面的代码:

BufferedImage rgbImage = ImageIO.read(new File("d:\\Temp\\IMG_1748x2480.jpg"));
BufferedImage cmykImage = null;
ColorSpace cpace = new ICC_ColorSpace(ICC_Profile.getInstance(
                   TestConvertRGBToCMYK.class.getClassLoader().getResourceAsStream(
                   "CMYK_Profiles/USWebCoatedSWOP.icc")));
ColorConvertOp op = new ColorConvertOp(rgbImage.getColorModel().getColorSpace(), cpace, null);
cmykImage = op.filter(rgbImage, null);    
ImageIO.write(cmykImage, "JPEG", new File("d:\\Temp\\CMYK_Sample_RGB_OUTPUT2.jpg"));

But the problem is that the result image appears black. 但是问题是结果图像显示为黑色。 After reading the Google point of view (posts) I've read that this is normal, because the views aren't compatible with the CMYK images, but PDF views are. 阅读Google的观点(帖子)后,我读到这是正常现象,因为视图与CMYK图像不兼容,而PDF视图却与之兼容。 But the problem is if I put the image in the PDF, the image continues to appear black. 但是问题是,如果将图像放入PDF中,图像将继续显示为黑色。

Does any one have any idea for what is going one? 有人对前进的方向有任何想法吗? Or have any other converter that does a better conversion? 还是有其他转换器可以实现更好的转换?

Just an update of my problem. 只是我的问题的更新。

Use ImageMagick software and i get all my problems resolved. 使用ImageMagick软件,我可以解决所有问题。

Cheers, 干杯,

Bigster 比格斯特

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM