I'm trying to convert an RGB image to a CMYK image using Java. 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. But the problem is if I put the image in the PDF, the image continues to appear black.

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.

Cheers,

Bigster

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top