I am attempting to convert a jpeg image in rgb to CMYK colorspace. The only problem is my final output is always a black image. But interesting enough the preview application in MAC shows the image correctly. There does not seem to be an example of a successful rgb to cmyk conversion anywhere I've looked so far. Below is the code i'm using to attempt the conversion. This code works fine If i'm performing the conversion to rgb using RGB ICC Profile. Any guidance is greatly appreciated.
import javax.imageio.ImageIO;
public class TestClass {
public static void main(String[] args) throws Exception {
BufferedImage cmykImage = ImageIO.read(new File(
"CMYK_Sample.jpg"));
BufferedImage rgbImage = null;
ColorSpace cpace = new ICC_ColorSpace(ICC_Profile.getInstance(TestClass.class.getClassLoader().getResourceAsStream("icc/USWebCoatedSWOP.icc")));
ColorConvertOp op = new ColorConvertOp(cpace, null);
rgbImage = op.filter(cmykImage, null);
ImageIO.write(rgbImage, "JPEG", new File("CMYK_Sample_RGB_OUTPUT2.jpg"));
}
}