Hi,

I asked this question before at the jai mailing list but was directed to this mailing list.

I just started to use Jai and I have a question about converting images to cmyk.

We have to prepare images to be printed by a press and these image need to use the icc color profile for the press to be used.

We start with images that people can upload, these will mostlikely be RGB images.

In the application the uploaded image will be converted to the colorspace used by the press, using the icc profile for this press.

We have color converted an rgb image to the color space using the icc profile that comes with Jai (cmyk.pf) using code based on the code in post:

https://jai.dev.java.net/servlets/ReadMsg?list=interest&msgNo=1271

 

The result is a CMYK image, but the value for K is 0, also when I define a black RGB image. RGB (0,0,0) results in (255, 255, 255, 0).

Althought this is a black CMYK image, this would not be usauble in printing because having to use 3 layers of ink which results in a not good black (more like brownish). You would want to use just black Ink so the result of the color conversion that I am looking for is (0,0,0,255).

We also used icc profiles for commercial printing press for uncoated and coated paper and for these icc profiles the conversion for RGB (0,0,0) results in (163,129,127,241 uncoated) and (238,213,206,229 coated). More K is used here but still a lot of other colors are used in creating black.

 

Using the color calculator on http://www.easyrgb.com/calculator.php gives cmyk(0,0,0,1) for rgb(0,0,0).

So somehow something is going wrong with the color conversion.

I have included the code we used for the conversion below:

PlanarImage planarImage = JAI.create("fileload", imageName);

ColorModel colorModelInput = planarImage.getColorModel ();

ColorSpace colorSpaceInput = colorModelInput.getColorSpace();

CC_Profile profileOutput = ICC_Profile.getInstance("CMYK.pf");

ColorSpace colorspaceOutput = new ICC_ColorSpace( profileOutput);

ImageManipulator imageManipulator = new ImageManipulator();

PlanarImage planarImageProfile = imageManipulator.convertColorSpace(planarImage,colorSpaceInput,colorspaceOutput );

 

 

public PlanarImage convertColorSpace(PlanarImage planarImageInput, ColorSpace colorSpaceInput, ColorSpace colorSpaceOutput ) {

ColorModel colorModelInput = RasterFactory.createComponentColorModel(planarImageInput.getSampleModel ().getDataType(), colorSpaceInput,

false, false, Transparency.OPAQUE);

ImageLayout imageLayoutInput = new ImageLayout();

imageLayoutInput.setColorModel(colorModelInput);

RenderingHints RenderingHintsInput = new RenderingHints( JAI.KEY_IMAGE_LAYOUT, imageLayoutInput);

ParameterBlock parameterBlockInput = new ParameterBlock();

parameterBlockInput.addSource(planarImageInput);

parameterBlockInput.add (planarImageInput.getSampleModel().getDataType());

PlanarImage planarInputImageInputWithProfile = JAI.create("format", parameterBlockInput, RenderingHintsInput);

 

ColorModel colorModelOutput = RasterFactory.createComponentColorModel(planarInputImageInputWithProfile.getSampleModel().getDataType(), colorSpaceOutput, false, false, Transparency.OPAQUE);

ImageLayout imageLayoutOutput = new ImageLayout();

imageLayoutOutput.setSampleModel(colorModelOutput.createCompatibleSampleModel(planarInputImageInputWithProfile.getWidth(), planarInputImageInputWithProfile.getHeight()));

RenderingHints renderingHintsOutput = new RenderingHints( JAI.KEY_IMAGE_LAYOUT, imageLayoutOutput);

ParameterBlock parameterBlockOutput = new ParameterBlock();

parameterBlockOutput.addSource(planarInputImageInputWithProfile);

parameterBlockOutput.add (colorModelOutput);

return JAI.create("ColorConvert", parameterBlockOutput, renderingHintsOutput);

}

 

Am I doing something wrong with the colorconversion and is there a better way to do this?

I was also wondering how it is possible to embed the icc profile in the image.

My guess is that first, the image needs to be converted to the color space of the icc profile (using the icc profile) and after that somehow add the icc profile to the image.

But if that is the case, is the color adjustment that is happening because of the ICC profile not happening twice (while converting from rgb to cmyk and when using the icc profile printing the image)?

From the answer at the Jai mailing list to the question above, I understand that the icc profile is used to translate the raw image data of the converted (previously converted using the icc profile) image to the colorspace of the device using the icc profile so that the icc is not used twice. is this a correct understanding?

Greetings

Roland

=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to