Hi Francisco,

The JPEGImageEncoder/Decoder classes (in the com.sun.image.codec.jpeg
package) that you're using here are not supported.  Since JDK 1.4, the
Image I/O API is the supported mechanism for reading and writing
images, and the JPEG IIO plugins should be higher quality than the
older (unsupported) JPEG classes.

Using IIO, your code snippet would be greatly simplified, and I'm
hoping that there wouldn't be any problems related to CMYK:

import javax.imageio.*;
public static void main(String args[]) throws Exception {
       String inputImageFileName = "front_cmyk.jpg";
       String outputImageFileName = "front_" +
System.currentTimeMillis() + ".jpg";
       OutputStream out = new FileOutputStream(outputImageFileName);

       BufferedImage image = ImageIO.read(new File(inputImageFileName));
       ImageIO.write(image, "jpeg", out);

       out.close();
       System.out.println("output file name: " + outputImageFileName);
   }

For more information on Image I/O:
http://java.sun.com/j2se/1.5.0/docs/guide/imageio/

Thanks,
Chris

On Sep 4, 2003, at 2:46 AM, Francisco Hernandez wrote:
I'm having a bit of trouble opening a cmyk image and saving it again as
cmyk, it actually does save as cmyk but the colors are totally off

below is the code im using, I basically just want to open a cmyk image,
write some text and shapes onto the image (using Graphics2D), then
save it,
but I removed the part of the code where it writes on the image for
simplification of the code listing here



public static void main(String args[]) throws Exception {
       String inputImageFileName = "front_cmyk.jpg";
       String outputImageFileName = "front_" +
System.currentTimeMillis() + ".jpg";
       OutputStream out = new FileOutputStream(outputImageFileName);

       JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(new
FileInputStream(inputImageFileName));
       BufferedImage image = decoder.decodeAsBufferedImage();

       JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
       JPEGEncodeParam param =
encoder.getDefaultJPEGEncodeParam(image.getRaster(),
JPEGDecodeParam.COLOR_ID_CMYK);
       //JPEGEncodeParam param =
encoder.getDefaultJPEGEncodeParam(image);
       param.setQuality(1, false);

       encoder.encode(image.getRaster(), param);
       //encoder.encode(image, param);


out.close(); System.out.println("output file name: " + outputImageFileName); }

=======================================================================
====
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".

=========================================================================== 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