• Post Reply Bookmark Topic Watch Topic
  • New Topic

Encode JPEG as CMKY instead of RGB using JPEGEncodeParam?

 
Matt Wilcko
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a program that opens a jpeg, writes text on the image, and saves it as a jpeg. Only problem is that I need it as a CMYK jpeg instead of RGB. Any way to do this? I tried opening a CMYK file but java wont seem to do it. It seems to be fine with RGB and grayscale. I've seen mention of something referred to as COLOR_ID_CMYK. Is that what I need? How would I use it?
Here is a snippet from my code that writes the jpeg now.. only as RGB jpeg:
--------------------------
JPEGEncodeParam param = JPEGCodec.getDefaultJPEGEncodeParam(image);
param.setQuality(1.0f,false); //set quality to 100%
//set dpi using density
param.setDensityUnit(JPEGEncodeParam.DENSITY_UNIT_DOTS_INCH);
param.setXDensity(300);
param.setYDensity(300);
JPEGImageEncoder enc = JPEGCodec.createJPEGEncoder(fos, param);

try{
enc.encode(image);
fos.flush();
fos.close();
}catch (IOException e){
e.printStackTrace(System.err);
}
---------------------------
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!