Skip to main content

[JAI-IMAGEIO] covnert cmyk to rgb

15 replies [Last post]
Anonymous

Hi folks,

the whole day i spend in netbeans and the web to find a solution to
convert a cmyk-jpeg into rgb. The otherway works fine for me since
hours, but this is not what i need. :-(

after many new ideas and posibilitys, tools and coffees, finaly after
3pk. cigarettes i have this for convervting:

PlanarImage inputCMYK_ = JAI.create("fileload",cmykdatei);
BufferedImage inputCMYK = inputCMYK_.getAsBufferedImage();
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
ColorConvertOp op = new ColorConvertOp(cs, null);
BufferedImage bi = op.filter(inputCMYK, null);
ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );

but it fails with: Bogus input colorspace

for rgb2cmyk i uses this class:

--
/*
* cmyk_handles.java
*
* Created on January 13, 2007, 11:20 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package nextgen;

import com.sun.image.codec.jpeg.*;
import java.awt.*;
import java.awt.color.*;
import java.awt.image.*;
import java.io.*;
import java.util.*;
import javax.media.jai.*;

/**
*
* @author kriswolff
*/
public class rgb2cmyk_ICC {

private static boolean invert = false;
private static String rgbdatei = "/tmp/myimage.rgb.jpg";

/** Creates a new instance of cmyk_handles */
public rgb2cmyk_ICC() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int[] bitsCMYK = {8,8,8,8};

String cmykProfile = "/Library/Application Support/Adobe/
Color/Profiles/Photoshop4DefaultCMYK.icc"; // icc-profile cmyk
String rgbProfile = "/Library/Application Support/Adobe/
Color/Profiles/Recommended/AppleRGB.icc";// icc-profile rgb

// Dateiname f�r die Ausgabe
StringTokenizer st = new StringTokenizer(rgbdatei,".");
StringBuffer buffer = new StringBuffer();
while ( st.hasMoreTokens() ) {
buffer.append(st.nextToken());
buffer.append("_cmyk");
buffer.append(".jpg");
break;
}

try {

RenderedImage inputRGB = JAI.create("fileload",rgbdatei);

// Create a CMYK Color Space from cmykProfile
ICC_Profile p = ICC_Profile.getInstance(new
FileInputStream(cmykProfile));
ColorSpace csCMYK = new ICC_ColorSpace(p);

ColorModel colorModelCMYK = new ComponentColorModel
(csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TYPE_BYTE);

ImageLayout cmykLayout = new ImageLayout();
cmykLayout.setColorModel(colorModelCMYK);
RenderingHints hints = new RenderingHints
(JAI.KEY_IMAGE_LAYOUT,cmykLayout);
cmykLayout.setSampleModel
(colorModelCMYK.createCompatibleSampleModel(inputRGB.getWidth
(),inputRGB.getHeight()));

java.awt.image.renderable.ParameterBlock pb = new
java.awt.image.renderable.ParameterBlock();
pb.addSource(inputRGB);
pb.add(colorModelCMYK);
// convert the image from rgb-colorspace to cmyk-
colorspace with icc
PlanarImage out = JAI.create("ColorConvert",pb,hints);

// Damit photoshop die Bilddaten nicht invertiert
anzeigt erfolgt
// eine invertierung der Daten
pb = new java.awt.image.renderable.ParameterBlock();
pb.addSource(out);
PlanarImage out2 = JAI.create("invert",pb);

WritableRaster cmykRaster = out2.copyData();
// �ffnen des Output-Streams
OutputStream datei = new FileOutputStream(buffer.toString
());

JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder
(datei);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam
(cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
param.setQuality(1, false);
encoder.encode(cmykRaster, param);
datei.close();
System.out.println("Bild erfolgreich gespeichert");

} catch (Exception e) {
e.printStackTrace();
}
}
}
--

so, i tryed to swap all cmyk to rgb and rgb to cmyk but this takes me
into a long journy of errors and misunderstandable issues that takes
me further away than i ever thougt about.

So if anyone out there who is friendly and leads me into the light? I
am absolutly burned out with this image things.

Thank you very much in advanced.
ven.

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Brian Burkhalter

Has this problem been resolved yet or are you still stuck?

Brian

On Sun, 14 Jan 2007, Kris Wolff wrote:

> I spend a while in the code to understand the transforming part.
> I got it. But i can not render a image with this code either.
>
> The IIOMeterdate failed with a: ICC APP2 encountered without prior JFIF!
> exception. So i think this is just a mac thing, too - found something on the
> net. I checkd for what we need the metadate and found out, that this is
> needed to find out the "transform" value.
> I checked the dtd for app14Adobe ans I noiced that transform can only be 0, 1
> or 2.
>
> Easy to test by replacing the metadatapart.
>
> I tried with all of possible transform values and getting always the same
> result: a image with a single color, still cmyk with C:100% M:50% Y:50% K100%
> BUT: i resolved it. I take your code form the other test:
> BufferedImage i0 = j.readImage(new File("/tmp/2.JPG"));
> BufferedImage i1 = new BufferedImage(i0.getWidth(),i0.getHeight(),
> BufferedImage.TYPE_INT_ARGB);
> ImageIO.write(i1, "jpg", new File("/tmp/a2.jpg"));
>
> and replaced it with:
> BufferedImage i0 = j.readImage(new File("/tmp/2.JPG"));
> ImageIO.write(i0, "jpg", new File("/tmp/a2.jpg"));
>
> And than .. transform=2 works !! 0 and 1 changing colors.
>
> So lets take a look the the metadata. I found a api called
> "com.drew.metadata.*;" that works for me, but do not give the app14 node
> back.
> Do you know any other solution to get the metadata tree?
>
> So second question: i run a method to the rgb to find out the density:
> --
> int density = 0;
> int densityUnit = JPEGDecodeParam.DENSITY_UNIT_DOTS_INCH;
> FileInputStream fis = new FileInputStream( "/tmp/a2.jpg" );
> JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder( fis );
> JPEGDecodeParam decodeParam = decoder.getJPEGDecodeParam();
> if ( decodeParam.getMarker( JPEGDecodeParam.APP0_MARKER ) ) {
> density = decodeParam.getXDensity();
> densityUnit = decodeParam.getDensityUnit();
> }
> fis.close();
> System.out.println("Density "+ density +" "+ densityUnit);
> --
>
> I run this on the fresh generated image and get a desity of 1, i open this
> file in Phooshop, and save it back to the same file. run the desity-method
> again and get a resolution of 72
> by the way: the original has a resolution of 300dpi.
>
>
> Any suggestions?
>
>
> On Jan 14, 2007, at 6:05 AM, robert engels wrote:
>
>> Try this:
>>
>> http://archives.java.sun.com/cgi-bin/wa?A2=ind0409&L=java2d-interest&P=4893
>>
>> On Jan 13, 2007, at 10:56 PM, Kris Wolff wrote:
>>
>>> ok.
>>> thanks for your help. i am a huge step further. focusing on raster...
>>>
>>> if you find an example,
>>> pls. share it. I will search the archive once again.
>>>
>>> ven.
>>>
>>> On Jan 14, 2007, at 5:52 AM, robert engels wrote:
>>>
>>>> I think it is probably because you are on a Mac - so you don't have the
>>>> native libs, which also prevents ImageIO from loading the CMYK image.
>>>>
>>>> You'll have the check the archives on reading a CMYK image using ImageIO
>>>> and reading the Raster.
>>>>
>>>> On Jan 13, 2007, at 10:48 PM, Kris Wolff wrote:
>>>>
>>>>> Hm, and this works for you?
>>>>> I am getting a Unsupported Image Type while loading the CMYK image.
>>>>>
>>>>> its an CMYK/8 JPEG building with Photoshop. I tryed several CMYK-Images.
>>>>> No-Go. :-(
>>>>>
>>>>> --
>>>>> javax.imageio.IIOException: Unsupported Image Type
>>>>> at
>>>>> com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:889)
>>>>> at
>>>>> com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:864)
>>>>> at javax.imageio.ImageIO.read(ImageIO.java:1400)
>>>>> at javax.imageio.ImageIO.read(ImageIO.java:1286)
>>>>> --
>>>>>
>>>>> in: BufferedImage i0 = ImageIO.read(new File("/tmp/2.JPG"));
>>>>>
>>>>>
>>>>> ven.
>>>>>
>>>>>
>>>>>
>>>>> On Jan 14, 2007, at 5:29 AM, robert engels wrote:
>>>>>
>>>>>>
>>>>>> You need to use code like
>>>>>>
>>>>>> BufferedImage i0 = ImageIO.read(new File("somefilename.jpg"));
>>>>>> BufferedImage i1 = new
>>>>>> BufferedImage(i0.getWidth(),i0.getheight(),BufferedImage.INT_ARGB);
>>>>>> ImageIO.write(new File("newfilename.jpg","jpg",i1);
>>>>>>
>>>>>>
>>>>>> On Jan 13, 2007, at 10:20 PM, Kris Wolff wrote:
>>>>>>
>>>>>>> Hi agian,
>>>>>>>
>>>>>>> I tryed this on my laptop with
>>>>>>> java version "1.5.0_06"
>>>>>>>
>>>>>>> But i can't get it. If it possible you send me this lines. I am totaly
>>>>>>> out of ideas, just need a tiny kick into the right direktion, get over
>>>>>>> this part CMYK->RGB...
>>>>>>>
>>>>>>> So you said: read into BuffersImage and just write into a new on. I
>>>>>>> get This lines:
>>>>>>>
>>>>>>> You can see 2 ways i've tried. The first gets a:
>>>>>>> sun.awt.image.ImageFormatException: Unsupported color conversion
>>>>>>> request
>>>>>>> The second a:
>>>>>>> javax.imageio.IIOException: Unsupported Image Type
>>>>>>>
>>>>>>>
>>>>>>> public static void main(String[] args) {
>>>>>>> FileOutputStream fos = null;
>>>>>>> try {
>>>>>>>
>>>>>>> // VARIANT I / sun.awt.image.ImageFormatException:
>>>>>>> Unsupported color conversion request
>>>>>>> ImageIcon icon = new ImageIcon("/tmp/myimage.jpg");
>>>>>>> Image image = icon.getImage();
>>>>>>> BufferedImage cmyk =
>>>>>>> new BufferedImage(
>>>>>>> image.getWidth(null),
>>>>>>> image.getHeight(null),
>>>>>>> BufferedImage.TYPE_INT_ARGB);
>>>>>>>
>>>>>>> // VARIANT II / javax.imageio.IIOException: Unsupported
>>>>>>> Image Type
>>>>>>> //BufferedImage cmyk = ImageIO.read(new File());
>>>>>>>
>>>>>>> File outfile = new File("/tmp/aaa.jpg");
>>>>>>> fos = new FileOutputStream(outfile);
>>>>>>> ImageEncoder encoder =
>>>>>>> ImageCodec.createImageEncoder("JPEG",fos,null);
>>>>>>> PNGEncodeParam param = new PNGEncodeParam.RGB();
>>>>>>> encoder.setParam(param);
>>>>>>> encoder.encode(cmyk);
>>>>>>> fos.close();
>>>>>>> } catch (Exception e){
>>>>>>> e.printStackTrace();
>>>>>>> } finally {
>>>>>>> try {
>>>>>>> fos.close();
>>>>>>> } catch (Exception e){
>>>>>>> }
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Thank you so much! ! !
>>>>>>>
>>>>>>> ven.
>>>>>>>
>>>>>>>
>>>>>>> On Jan 14, 2007, at 2:45 AM, robert engels wrote:
>>>>>>>
>>>>>>>> Using ImageIO with JDK 1.5, you can read the CMYK jpg directly into a
>>>>>>>> BufferedImage.
>>>>>>>>
>>>>>>>> Then once you have a BufferedImage, write the BufferedImage into a
>>>>>>>> new RGB BufferedImage.
>>>>>>>>
>>>>>>>> Then write the RGB BufferedImage as a JPG using ImageIO.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:
>>>>>>>>
>>>>>>>>> Hi folks,
>>>>>>>>>
>>>>>>>>> the whole day i spend in netbeans and the web to find a solution to
>>>>>>>>> convert a cmyk-jpeg into rgb. The otherway works fine for me since
>>>>>>>>> hours, but this is not what i need. :-(
>>>>>>>>>
>>>>>>>>> after many new ideas and posibilitys, tools and coffees, finaly
>>>>>>>>> after 3pk. cigarettes i have this for convervting:
>>>>>>>>>
>>>>>>>>> PlanarImage inputCMYK_ = JAI.create("fileload",cmykdatei);
>>>>>>>>> BufferedImage inputCMYK =
>>>>>>>>> inputCMYK_.getAsBufferedImage();
>>>>>>>>> ColorSpace cs =
>>>>>>>>> ColorSpace.getInstance(ColorSpace.CS_GRAY);
>>>>>>>>> ColorConvertOp op = new ColorConvertOp(cs, null);
>>>>>>>>> BufferedImage bi = op.filter(inputCMYK, null);
>>>>>>>>> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>>>>>>>>>
>>>>>>>>> but it fails with: Bogus input colorspace
>>>>>>>>>
>>>>>>>>> for rgb2cmyk i uses this class:
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> /*
>>>>>>>>> * cmyk_handles.java
>>>>>>>>> *
>>>>>>>>> * Created on January 13, 2007, 11:20 PM
>>>>>>>>> *
>>>>>>>>> * To change this template, choose Tools | Template Manager
>>>>>>>>> * and open the template in the editor.
>>>>>>>>> */
>>>>>>>>>
>>>>>>>>> package nextgen;
>>>>>>>>>
>>>>>>>>> import com.sun.image.codec.jpeg.*;
>>>>>>>>> import java.awt.*;
>>>>>>>>> import java.awt.color.*;
>>>>>>>>> import java.awt.image.*;
>>>>>>>>> import java.io.*;
>>>>>>>>> import java.util.*;
>>>>>>>>> import javax.media.jai.*;
>>>>>>>>>
>>>>>>>>> /**
>>>>>>>>> *
>>>>>>>>> * @author kriswolff
>>>>>>>>> */
>>>>>>>>> public class rgb2cmyk_ICC {
>>>>>>>>>
>>>>>>>>> private static boolean invert = false;
>>>>>>>>> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>>>>>>>>>
>>>>>>>>> /** Creates a new instance of cmyk_handles */
>>>>>>>>> public rgb2cmyk_ICC() {
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> /**
>>>>>>>>> * @param args the command line arguments
>>>>>>>>> */
>>>>>>>>> public static void main(String[] args) {
>>>>>>>>> int[] bitsCMYK = {8,8,8,8};
>>>>>>>>>
>>>>>>>>> String cmykProfile = "/Library/Application
>>>>>>>>> Support/Adobe/Color/Profiles/Photoshop4DefaultCMYK.icc"; //
>>>>>>>>> icc-profile cmyk
>>>>>>>>> String rgbProfile = "/Library/Application
>>>>>>>>> Support/Adobe/Color/Profiles/Recommended/AppleRGB.icc";//
>>>>>>>>> icc-profile rgb
>>>>>>>>>
>>>>>>>>> // Dateiname fr die Ausgabe
>>>>>>>>> StringTokenizer st = new StringTokenizer(rgbdatei,".");
>>>>>>>>> StringBuffer buffer = new StringBuffer();
>>>>>>>>> while ( st.hasMoreTokens() ) {
>>>>>>>>> buffer.append(st.nextToken());
>>>>>>>>> buffer.append("_cmyk");
>>>>>>>>> buffer.append(".jpg");
>>>>>>>>> break;
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> try {
>>>>>>>>>
>>>>>>>>> RenderedImage inputRGB = JAI.create("fileload",rgbdatei);
>>>>>>>>>
>>>>>>>>> // Create a CMYK Color Space from cmykProfile
>>>>>>>>> ICC_Profile p = ICC_Profile.getInstance(new
>>>>>>>>> FileInputStream(cmykProfile));
>>>>>>>>> ColorSpace csCMYK = new ICC_ColorSpace(p);
>>>>>>>>>
>>>>>>>>> ColorModel colorModelCMYK = new
>>>>>>>>> ComponentColorModel(csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TYPE_BYTE);
>>>>>>>>>
>>>>>>>>> ImageLayout cmykLayout = new ImageLayout();
>>>>>>>>> cmykLayout.setColorModel(colorModelCMYK);
>>>>>>>>> RenderingHints hints = new
>>>>>>>>> RenderingHints(JAI.KEY_IMAGE_LAYOUT,cmykLayout);
>>>>>>>>> cmykLayout.setSampleModel(colorModelCMYK.createCompatibleSampleModel(inputRGB.getWidth(),inputRGB.getHeight()));
>>>>>>>>>
>>>>>>>>> java.awt.image.renderable.ParameterBlock pb = new
>>>>>>>>> java.awt.image.renderable.ParameterBlock();
>>>>>>>>> pb.addSource(inputRGB);
>>>>>>>>> pb.add(colorModelCMYK);
>>>>>>>>> // convert the image from rgb-colorspace to
>>>>>>>>> cmyk-colorspace with icc
>>>>>>>>> PlanarImage out = JAI.create("ColorConvert",pb,hints);
>>>>>>>>>
>>>>>>>>> // Damit photoshop die Bilddaten nicht invertiert anzeigt
>>>>>>>>> erfolgt
>>>>>>>>> // eine invertierung der Daten
>>>>>>>>> pb = new java.awt.image.renderable.ParameterBlock();
>>>>>>>>> pb.addSource(out);
>>>>>>>>> PlanarImage out2 = JAI.create("invert",pb);
>>>>>>>>>
>>>>>>>>> WritableRaster cmykRaster = out2.copyData();
>>>>>>>>> // ffnen des Output-Streams
>>>>>>>>> OutputStream datei = new
>>>>>>>>> FileOutputStream(buffer.toString());
>>>>>>>>>
>>>>>>>>> JPEGImageEncoder encoder =
>>>>>>>>> JPEGCodec.createJPEGEncoder(datei);
>>>>>>>>> JPEGEncodeParam param =
>>>>>>>>> encoder.getDefaultJPEGEncodeParam(cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
>>>>>>>>> param.setQuality(1, false);
>>>>>>>>> encoder.encode(cmykRaster, param);
>>>>>>>>> datei.close();
>>>>>>>>> System.out.println("Bild erfolgreich gespeichert");
>>>>>>>>>
>>>>>>>>> } catch (Exception e) {
>>>>>>>>> e.printStackTrace();
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> so, i tryed to swap all cmyk to rgb and rgb to cmyk but this takes
>>>>>>>>> me into a long journy of errors and misunderstandable issues that
>>>>>>>>> takes me further away than i ever thougt about.
>>>>>>>>>
>>>>>>>>> So if anyone out there who is friendly and leads me into the light?
>>>>>>>>> I am absolutly burned out with this image things.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thank you very much in advanced.
>>>>>>>>> ven.
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>> interest-unsubscribe@jai-imageio.dev.java.net
>>>>>>>>> For additional commands, e-mail:
>>>>>>>>> interest-help@jai-imageio.dev.java.net
>>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>>>>>>>> For additional commands, e-mail:
>>>>>>>> interest-help@jai-imageio.dev.java.net
>>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>>>>>>> For additional commands, e-mail:
>>>>>>> interest-help@jai-imageio.dev.java.net
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>>>>>> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>>>>> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>>>> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>>> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>>>
>>
>

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Kris Wolff

not allready resolved, but a huge step further.
I will post the finaly solution if u like when its done. Hopefully i
will spend this week aanother few hours to it.

On Jan 16, 2007, at 11:21 PM, Brian Burkhalter wrote:

> Has this problem been resolved yet or are you still stuck?
>
> Brian
>
> On Sun, 14 Jan 2007, Kris Wolff wrote:
>
>> I spend a while in the code to understand the transforming part.
>> I got it. But i can not render a image with this code either.
>>
>> The IIOMeterdate failed with a: ICC APP2 encountered without prior
>> JFIF! exception. So i think this is just a mac thing, too - found
>> something on the net. I checkd for what we need the metadate and
>> found out, that this is needed to find out the "transform" value.
>> I checked the dtd for app14Adobe ans I noiced that transform can
>> only be 0, 1 or 2.
>>
>> Easy to test by replacing the metadatapart.
>>
>> I tried with all of possible transform values and getting always
>> the same result: a image with a single color, still cmyk with C:
>> 100% M:50% Y:50% K100%
>> BUT: i resolved it. I take your code form the other test:
>> BufferedImage i0 = j.readImage(new File("/tmp/2.JPG"));
>> BufferedImage i1 = new BufferedImage(i0.getWidth(),i0.getHeight(),
>> BufferedImage.TYPE_INT_ARGB);
>> ImageIO.write(i1, "jpg", new File("/tmp/a2.jpg"));
>>
>> and replaced it with:
>> BufferedImage i0 = j.readImage(new File("/tmp/2.JPG"));
>> ImageIO.write(i0, "jpg", new File("/tmp/a2.jpg"));
>>
>> And than .. transform=2 works !! 0 and 1 changing colors.
>>
>> So lets take a look the the metadata. I found a api called
>> "com.drew.metadata.*;" that works for me, but do not give the
>> app14 node back.
>> Do you know any other solution to get the metadata tree?
>>
>> So second question: i run a method to the rgb to find out the
>> density:
>> --
>> int density = 0;
>> int densityUnit = JPEGDecodeParam.DENSITY_UNIT_DOTS_INCH;
>> FileInputStream fis = new FileInputStream( "/tmp/a2.jpg" );
>> JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder
>> ( fis );
>> JPEGDecodeParam decodeParam = decoder.getJPEGDecodeParam();
>> if ( decodeParam.getMarker
>> ( JPEGDecodeParam.APP0_MARKER ) ) {
>> density = decodeParam.getXDensity();
>> densityUnit = decodeParam.getDensityUnit();
>> }
>> fis.close();
>> System.out.println("Density "+ density +" "+ densityUnit);
>> --
>>
>> I run this on the fresh generated image and get a desity of 1, i
>> open this file in Phooshop, and save it back to the same file. run
>> the desity-method again and get a resolution of 72
>> by the way: the original has a resolution of 300dpi.
>>
>>
>> Any suggestions?
>>
>>
>> On Jan 14, 2007, at 6:05 AM, robert engels wrote:
>>
>>> Try this:
>>> http://archives.java.sun.com/cgi-bin/wa?A2=ind0409&L=java2d-
>>> interest&P=4893
>>> On Jan 13, 2007, at 10:56 PM, Kris Wolff wrote:
>>>> ok.
>>>> thanks for your help. i am a huge step further. focusing on
>>>> raster...
>>>> if you find an example,
>>>> pls. share it. I will search the archive once again.
>>>> ven.
>>>> On Jan 14, 2007, at 5:52 AM, robert engels wrote:
>>>>> I think it is probably because you are on a Mac - so you don't
>>>>> have the native libs, which also prevents ImageIO from loading
>>>>> the CMYK image.
>>>>> You'll have the check the archives on reading a CMYK image
>>>>> using ImageIO and reading the Raster.
>>>>> On Jan 13, 2007, at 10:48 PM, Kris Wolff wrote:
>>>>>> Hm, and this works for you?
>>>>>> I am getting a Unsupported Image Type while loading the CMYK
>>>>>> image.
>>>>>> its an CMYK/8 JPEG building with Photoshop. I tryed several
>>>>>> CMYK-Images. No-Go. :-(
>>>>>> --
>>>>>> javax.imageio.IIOException: Unsupported Image Type
>>>>>> at
>>>>>> com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal
>>>>>> (JPEGImageReader.java:889)
>>>>>> at com.sun.imageio.plugins.jpeg.JPEGImageReader.read
>>>>>> (JPEGImageReader.java:864)
>>>>>> at javax.imageio.ImageIO.read(ImageIO.java:1400)
>>>>>> at javax.imageio.ImageIO.read(ImageIO.java:1286)
>>>>>> --
>>>>>> in: BufferedImage i0 = ImageIO.read(new File("/tmp/2.JPG"));
>>>>>> ven.
>>>>>> On Jan 14, 2007, at 5:29 AM, robert engels wrote:
>>>>>>> You need to use code like
>>>>>>> BufferedImage i0 = ImageIO.read(new File("somefilename.jpg"));
>>>>>>> BufferedImage i1 = new BufferedImage(i0.getWidth
>>>>>>> (),i0.getheight(),BufferedImage.INT_ARGB);
>>>>>>> ImageIO.write(new File("newfilename.jpg","jpg",i1);
>>>>>>> On Jan 13, 2007, at 10:20 PM, Kris Wolff wrote:
>>>>>>>> Hi agian,
>>>>>>>> I tryed this on my laptop with
>>>>>>>> java version "1.5.0_06"
>>>>>>>> But i can't get it. If it possible you send me this lines. I
>>>>>>>> am totaly out of ideas, just need a tiny kick into the right
>>>>>>>> direktion, get over this part CMYK->RGB...
>>>>>>>> So you said: read into BuffersImage and just write into a
>>>>>>>> new on. I get This lines:
>>>>>>>> You can see 2 ways i've tried. The first gets a:
>>>>>>>> sun.awt.image.ImageFormatException: Unsupported color
>>>>>>>> conversion request
>>>>>>>> The second a:
>>>>>>>> javax.imageio.IIOException: Unsupported Image Type
>>>>>>>>
>>>>>>>> public static void main(String[] args) {
>>>>>>>> FileOutputStream fos = null;
>>>>>>>> try {
>>>>>>>>
>>>>>>>> // VARIANT I /
>>>>>>>> sun.awt.image.ImageFormatException: Unsupported color
>>>>>>>> conversion request
>>>>>>>> ImageIcon icon = new ImageIcon("/tmp/myimage.jpg");
>>>>>>>> Image image = icon.getImage();
>>>>>>>> BufferedImage cmyk =
>>>>>>>> new BufferedImage(
>>>>>>>> image.getWidth(null),
>>>>>>>> image.getHeight(null),
>>>>>>>> BufferedImage.TYPE_INT_ARGB);
>>>>>>>>
>>>>>>>> // VARIANT II / javax.imageio.IIOException:
>>>>>>>> Unsupported Image Type
>>>>>>>> //BufferedImage cmyk = ImageIO.read(new File());
>>>>>>>>
>>>>>>>> File outfile = new File("/tmp/aaa.jpg");
>>>>>>>> fos = new FileOutputStream(outfile);
>>>>>>>> ImageEncoder encoder =
>>>>>>>> ImageCodec.createImageEncoder("JPEG",fos,null);
>>>>>>>> PNGEncodeParam param = new PNGEncodeParam.RGB();
>>>>>>>> encoder.setParam(param);
>>>>>>>> encoder.encode(cmyk);
>>>>>>>> fos.close();
>>>>>>>> } catch (Exception e){
>>>>>>>> e.printStackTrace();
>>>>>>>> } finally {
>>>>>>>> try {
>>>>>>>> fos.close();
>>>>>>>> } catch (Exception e){
>>>>>>>> }
>>>>>>>> }
>>>>>>>> }
>>>>>>>> Thank you so much! ! !
>>>>>>>> ven.
>>>>>>>> On Jan 14, 2007, at 2:45 AM, robert engels wrote:
>>>>>>>>> Using ImageIO with JDK 1.5, you can read the CMYK jpg
>>>>>>>>> directly into a BufferedImage.
>>>>>>>>> Then once you have a BufferedImage, write the BufferedImage
>>>>>>>>> into a new RGB BufferedImage.
>>>>>>>>> Then write the RGB BufferedImage as a JPG using ImageIO.
>>>>>>>>> On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:
>>>>>>>>>> Hi folks,
>>>>>>>>>> the whole day i spend in netbeans and the web to find a
>>>>>>>>>> solution to convert a cmyk-jpeg into rgb. The otherway
>>>>>>>>>> works fine for me since hours, but this is not what i
>>>>>>>>>> need. :-(
>>>>>>>>>> after many new ideas and posibilitys, tools and coffees,
>>>>>>>>>> finaly after 3pk. cigarettes i have this for convervting:
>>>>>>>>>>
>>>>>>>>>> PlanarImage inputCMYK_ = JAI.create
>>>>>>>>>> ("fileload",cmykdatei);
>>>>>>>>>> BufferedImage inputCMYK =
>>>>>>>>>> inputCMYK_.getAsBufferedImage();
>>>>>>>>>> ColorSpace cs = ColorSpace.getInstance
>>>>>>>>>> (ColorSpace.CS_GRAY);
>>>>>>>>>> ColorConvertOp op = new ColorConvertOp(cs, null);
>>>>>>>>>> BufferedImage bi = op.filter(inputCMYK, null);
>>>>>>>>>> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>>>>>>>>>> but it fails with: Bogus input colorspace
>>>>>>>>>> for rgb2cmyk i uses this class:
>>>>>>>>>> --
>>>>>>>>>> /*
>>>>>>>>>> * cmyk_handles.java
>>>>>>>>>> *
>>>>>>>>>> * Created on January 13, 2007, 11:20 PM
>>>>>>>>>> *
>>>>>>>>>> * To change this template, choose Tools | Template Manager
>>>>>>>>>> * and open the template in the editor.
>>>>>>>>>> */
>>>>>>>>>> package nextgen;
>>>>>>>>>> import com.sun.image.codec.jpeg.*;
>>>>>>>>>> import java.awt.*;
>>>>>>>>>> import java.awt.color.*;
>>>>>>>>>> import java.awt.image.*;
>>>>>>>>>> import java.io.*;
>>>>>>>>>> import java.util.*;
>>>>>>>>>> import javax.media.jai.*;
>>>>>>>>>> /**
>>>>>>>>>> *
>>>>>>>>>> * @author kriswolff
>>>>>>>>>> */
>>>>>>>>>> public class rgb2cmyk_ICC {
>>>>>>>>>>
>>>>>>>>>> private static boolean invert = false;
>>>>>>>>>> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>>>>>>>>>>
>>>>>>>>>> /** Creates a new instance of cmyk_handles */
>>>>>>>>>> public rgb2cmyk_ICC() {
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> /**
>>>>>>>>>> * @param args the command line arguments
>>>>>>>>>> */
>>>>>>>>>> public static void main(String[] args) {
>>>>>>>>>> int[] bitsCMYK = {8,8,8,8};
>>>>>>>>>>
>>>>>>>>>> String cmykProfile = "/Library/Application Support/
>>>>>>>>>> Adobe/Color/Profiles/Photoshop4DefaultCMYK.icc"; // icc-
>>>>>>>>>> profile cmyk
>>>>>>>>>> String rgbProfile = "/Library/Application Support/
>>>>>>>>>> Adobe/Color/Profiles/Recommended/AppleRGB.icc";// icc-
>>>>>>>>>> profile rgb
>>>>>>>>>>
>>>>>>>>>> // Dateiname fr die Ausgabe
>>>>>>>>>> StringTokenizer st = new StringTokenizer
>>>>>>>>>> (rgbdatei,".");
>>>>>>>>>> StringBuffer buffer = new StringBuffer();
>>>>>>>>>> while ( st.hasMoreTokens() ) {
>>>>>>>>>> buffer.append(st.nextToken());
>>>>>>>>>> buffer.append("_cmyk");
>>>>>>>>>> buffer.append(".jpg");
>>>>>>>>>> break;
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> try {
>>>>>>>>>>
>>>>>>>>>> RenderedImage inputRGB = JAI.create
>>>>>>>>>> ("fileload",rgbdatei);
>>>>>>>>>>
>>>>>>>>>> // Create a CMYK Color Space from cmykProfile
>>>>>>>>>> ICC_Profile p = ICC_Profile.getInstance(new
>>>>>>>>>> FileInputStream(cmykProfile));
>>>>>>>>>> ColorSpace csCMYK = new ICC_ColorSpace(p);
>>>>>>>>>>
>>>>>>>>>> ColorModel colorModelCMYK = new
>>>>>>>>>> ComponentColorModel
>>>>>>>>>> (csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.T
>>>>>>>>>> YPE_BYTE);
>>>>>>>>>>
>>>>>>>>>> ImageLayout cmykLayout = new ImageLayout();
>>>>>>>>>> cmykLayout.setColorModel(colorModelCMYK);
>>>>>>>>>> RenderingHints hints = new RenderingHints
>>>>>>>>>> (JAI.KEY_IMAGE_LAYOUT,cmykLayout);
>>>>>>>>>> cmykLayout.setSampleModel
>>>>>>>>>> (colorModelCMYK.createCompatibleSampleModel
>>>>>>>>>> (inputRGB.getWidth(),inputRGB.getHeight()));
>>>>>>>>>>
>>>>>>>>>> java.awt.image.renderable.ParameterBlock pb =
>>>>>>>>>> new java.awt.image.renderable.ParameterBlock();
>>>>>>>>>> pb.addSource(inputRGB);
>>>>>>>>>> pb.add(colorModelCMYK);
>>>>>>>>>> // convert the image from rgb-colorspace to
>>>>>>>>>> cmyk-colorspace with icc
>>>>>>>>>> PlanarImage out = JAI.create
>>>>>>>>>> ("ColorConvert",pb,hints);
>>>>>>>>>>
>>>>>>>>>> // Damit photoshop die Bilddaten nicht
>>>>>>>>>> invertiert anzeigt erfolgt
>>>>>>>>>> // eine invertierung der Daten
>>>>>>>>>> pb = new
>>>>>>>>>> java.awt.image.renderable.ParameterBlock();
>>>>>>>>>> pb.addSource(out);
>>>>>>>>>> PlanarImage out2 = JAI.create("invert",pb);
>>>>>>>>>>
>>>>>>>>>> WritableRaster cmykRaster = out2.copyData();
>>>>>>>>>> // ffnen des Output-Streams
>>>>>>>>>> OutputStream datei = new FileOutputStream
>>>>>>>>>> (buffer.toString());
>>>>>>>>>>
>>>>>>>>>> JPEGImageEncoder encoder =
>>>>>>>>>> JPEGCodec.createJPEGEncoder(datei);
>>>>>>>>>> JPEGEncodeParam param =
>>>>>>>>>> encoder.getDefaultJPEGEncodeParam
>>>>>>>>>> (cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
>>>>>>>>>> param.setQuality(1, false);
>>>>>>>>>> encoder.encode(cmykRaster, param);
>>>>>>>>>> datei.close();
>>>>>>>>>> System.out.println("Bild erfolgreich
>>>>>>>>>> gespeichert");
>>>>>>>>>>
>>>>>>>>>> } catch (Exception e) {
>>>>>>>>>> e.printStackTrace();
>>>>>>>>>> }
>>>>>>>>>> }
>>>>>>>>>> }
>>>>>>>>>> --
>>>>>>>>>> so, i tryed to swap all cmyk to rgb and rgb to cmyk but
>>>>>>>>>> this takes me into a long journy of errors and
>>>>>>>>>> misunderstandable issues that takes me further away than i
>>>>>>>>>> ever thougt about.
>>>>>>>>>> So if anyone out there who is friendly and leads me into
>>>>>>>>>> the light? I am absolutly burned out with this image things.
>>>>>>>>>> Thank you very much in advanced.
>>>>>>>>>> ven.
>>>>>>>>>> -------------------------------------------------------------
>>>>>>>>>> --------
>>>>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>>>>>> imageio.dev.java.net
>>>>>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>>>>>> imageio.dev.java.net
>>>>>>>>> --------------------------------------------------------------
>>>>>>>>> -------
>>>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>>>>> imageio.dev.java.net
>>>>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>>>>> imageio.dev.java.net
>>>>>>>> ---------------------------------------------------------------
>>>>>>>> ------
>>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>>>> imageio.dev.java.net
>>>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>>>> imageio.dev.java.net
>>>>>>> ----------------------------------------------------------------
>>>>>>> -----
>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>>> imageio.dev.java.net
>>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>>> imageio.dev.java.net
>>>>>> -----------------------------------------------------------------
>>>>>> ----
>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>> imageio.dev.java.net
>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>> imageio.dev.java.net
>>>>> ------------------------------------------------------------------
>>>>> ---
>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>> imageio.dev.java.net
>>>>> For additional commands, e-mail: interest-help@jai-
>>>>> imageio.dev.java.net
>>>> -------------------------------------------------------------------
>>>> --
>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>> imageio.dev.java.net
>>>> For additional commands, e-mail: interest-help@jai-
>>>> imageio.dev.java.net
>>
>
> ----------------
> Brian Burkhalter
> Java Media, Imaging, and Graphics
> Sun Microsystems, Inc.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> This email message is for the sole use of the intended recipient(s)
> and may contain confidential and privileged information. Any
> unauthorized review, use, disclosure or distribution is prohibited.
> If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original message.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Brian Burkhalter

Thanks. Posting the resolution of a problem is always appreciated.

On Wed, 17 Jan 2007, Kris Wolff wrote:

> not allready resolved, but a huge step further.
> I will post the finaly solution if u like when its done. Hopefully i will
> spend this week aanother few hours to it.
>
> On Jan 16, 2007, at 11:21 PM, Brian Burkhalter wrote:
>
>> Has this problem been resolved yet or are you still stuck?
>>
>> Brian
>>
>> On Sun, 14 Jan 2007, Kris Wolff wrote:
>>
>>> I spend a while in the code to understand the transforming part.
>>> I got it. But i can not render a image with this code either.
>>>
>>> The IIOMeterdate failed with a: ICC APP2 encountered without prior JFIF!
>>> exception. So i think this is just a mac thing, too - found something on
>>> the net. I checkd for what we need the metadate and found out, that this
>>> is needed to find out the "transform" value.
>>> I checked the dtd for app14Adobe ans I noiced that transform can only be
>>> 0, 1 or 2.
>>>
>>> Easy to test by replacing the metadatapart.
>>>
>>> I tried with all of possible transform values and getting always the same
>>> result: a image with a single color, still cmyk with C:100% M:50% Y:50%
>>> K100%
>>> BUT: i resolved it. I take your code form the other test:
>>> BufferedImage i0 = j.readImage(new File("/tmp/2.JPG"));
>>> BufferedImage i1 = new BufferedImage(i0.getWidth(),i0.getHeight(),
>>> BufferedImage.TYPE_INT_ARGB);
>>> ImageIO.write(i1, "jpg", new File("/tmp/a2.jpg"));
>>>
>>> and replaced it with:
>>> BufferedImage i0 = j.readImage(new File("/tmp/2.JPG"));
>>> ImageIO.write(i0, "jpg", new File("/tmp/a2.jpg"));
>>>
>>> And than .. transform=2 works !! 0 and 1 changing colors.
>>>
>>> So lets take a look the the metadata. I found a api called
>>> "com.drew.metadata.*;" that works for me, but do not give the app14 node
>>> back.
>>> Do you know any other solution to get the metadata tree?
>>>
>>> So second question: i run a method to the rgb to find out the density:
>>> --
>>> int density = 0;
>>> int densityUnit = JPEGDecodeParam.DENSITY_UNIT_DOTS_INCH;
>>> FileInputStream fis = new FileInputStream( "/tmp/a2.jpg" );
>>> JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder( fis );
>>> JPEGDecodeParam decodeParam = decoder.getJPEGDecodeParam();
>>> if ( decodeParam.getMarker( JPEGDecodeParam.APP0_MARKER ) ) {
>>> density = decodeParam.getXDensity();
>>> densityUnit = decodeParam.getDensityUnit();
>>> }
>>> fis.close();
>>> System.out.println("Density "+ density +" "+ densityUnit);
>>> --
>>>
>>> I run this on the fresh generated image and get a desity of 1, i open this
>>> file in Phooshop, and save it back to the same file. run the desity-method
>>> again and get a resolution of 72
>>> by the way: the original has a resolution of 300dpi.
>>>
>>>
>>> Any suggestions?
>>>
>>>
>>> On Jan 14, 2007, at 6:05 AM, robert engels wrote:
>>>
>>>> Try this:
>>>> http://archives.java.sun.com/cgi-bin/wa?A2=ind0409&L=java2d-interest&P=4893
>>>> On Jan 13, 2007, at 10:56 PM, Kris Wolff wrote:
>>>>> ok.
>>>>> thanks for your help. i am a huge step further. focusing on raster...
>>>>> if you find an example,
>>>>> pls. share it. I will search the archive once again.
>>>>> ven.
>>>>> On Jan 14, 2007, at 5:52 AM, robert engels wrote:
>>>>>> I think it is probably because you are on a Mac - so you don't have the
>>>>>> native libs, which also prevents ImageIO from loading the CMYK image.
>>>>>> You'll have the check the archives on reading a CMYK image using
>>>>>> ImageIO and reading the Raster.
>>>>>> On Jan 13, 2007, at 10:48 PM, Kris Wolff wrote:
>>>>>>> Hm, and this works for you?
>>>>>>> I am getting a Unsupported Image Type while loading the CMYK image.
>>>>>>> its an CMYK/8 JPEG building with Photoshop. I tryed several
>>>>>>> CMYK-Images. No-Go. :-(
>>>>>>> --
>>>>>>> javax.imageio.IIOException: Unsupported Image Type
>>>>>>> at
>>>>>>> com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:889)
>>>>>>> at
>>>>>>> com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:864)
>>>>>>> at javax.imageio.ImageIO.read(ImageIO.java:1400)
>>>>>>> at javax.imageio.ImageIO.read(ImageIO.java:1286)
>>>>>>> --
>>>>>>> in: BufferedImage i0 = ImageIO.read(new File("/tmp/2.JPG"));
>>>>>>> ven.
>>>>>>> On Jan 14, 2007, at 5:29 AM, robert engels wrote:
>>>>>>>> You need to use code like
>>>>>>>> BufferedImage i0 = ImageIO.read(new File("somefilename.jpg"));
>>>>>>>> BufferedImage i1 = new
>>>>>>>> BufferedImage(i0.getWidth(),i0.getheight(),BufferedImage.INT_ARGB);
>>>>>>>> ImageIO.write(new File("newfilename.jpg","jpg",i1);
>>>>>>>> On Jan 13, 2007, at 10:20 PM, Kris Wolff wrote:
>>>>>>>>> Hi agian,
>>>>>>>>> I tryed this on my laptop with
>>>>>>>>> java version "1.5.0_06"
>>>>>>>>> But i can't get it. If it possible you send me this lines. I am
>>>>>>>>> totaly out of ideas, just need a tiny kick into the right direktion,
>>>>>>>>> get over this part CMYK->RGB...
>>>>>>>>> So you said: read into BuffersImage and just write into a new on. I
>>>>>>>>> get This lines:
>>>>>>>>> You can see 2 ways i've tried. The first gets a:
>>>>>>>>> sun.awt.image.ImageFormatException: Unsupported color conversion
>>>>>>>>> request
>>>>>>>>> The second a:
>>>>>>>>> javax.imageio.IIOException: Unsupported Image Type
>>>>>>>>>
>>>>>>>>> public static void main(String[] args) {
>>>>>>>>> FileOutputStream fos = null;
>>>>>>>>> try {
>>>>>>>>>
>>>>>>>>> // VARIANT I / sun.awt.image.ImageFormatException:
>>>>>>>>> Unsupported color conversion request
>>>>>>>>> ImageIcon icon = new ImageIcon("/tmp/myimage.jpg");
>>>>>>>>> Image image = icon.getImage();
>>>>>>>>> BufferedImage cmyk =
>>>>>>>>> new BufferedImage(
>>>>>>>>> image.getWidth(null),
>>>>>>>>> image.getHeight(null),
>>>>>>>>> BufferedImage.TYPE_INT_ARGB);
>>>>>>>>>
>>>>>>>>> // VARIANT II / javax.imageio.IIOException: Unsupported
>>>>>>>>> Image Type
>>>>>>>>> //BufferedImage cmyk = ImageIO.read(new File());
>>>>>>>>>
>>>>>>>>> File outfile = new File("/tmp/aaa.jpg");
>>>>>>>>> fos = new FileOutputStream(outfile);
>>>>>>>>> ImageEncoder encoder =
>>>>>>>>> ImageCodec.createImageEncoder("JPEG",fos,null);
>>>>>>>>> PNGEncodeParam param = new PNGEncodeParam.RGB();
>>>>>>>>> encoder.setParam(param);
>>>>>>>>> encoder.encode(cmyk);
>>>>>>>>> fos.close();
>>>>>>>>> } catch (Exception e){
>>>>>>>>> e.printStackTrace();
>>>>>>>>> } finally {
>>>>>>>>> try {
>>>>>>>>> fos.close();
>>>>>>>>> } catch (Exception e){
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>> Thank you so much! ! !
>>>>>>>>> ven.
>>>>>>>>> On Jan 14, 2007, at 2:45 AM, robert engels wrote:
>>>>>>>>>> Using ImageIO with JDK 1.5, you can read the CMYK jpg directly into
>>>>>>>>>> a BufferedImage.
>>>>>>>>>> Then once you have a BufferedImage, write the BufferedImage into a
>>>>>>>>>> new RGB BufferedImage.
>>>>>>>>>> Then write the RGB BufferedImage as a JPG using ImageIO.
>>>>>>>>>> On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:
>>>>>>>>>>> Hi folks,
>>>>>>>>>>> the whole day i spend in netbeans and the web to find a solution
>>>>>>>>>>> to convert a cmyk-jpeg into rgb. The otherway works fine for me
>>>>>>>>>>> since hours, but this is not what i need. :-(
>>>>>>>>>>> after many new ideas and posibilitys, tools and coffees, finaly
>>>>>>>>>>> after 3pk. cigarettes i have this for convervting:
>>>>>>>>>>>
>>>>>>>>>>> PlanarImage inputCMYK_ =
>>>>>>>>>>> JAI.create("fileload",cmykdatei);
>>>>>>>>>>> BufferedImage inputCMYK =
>>>>>>>>>>> inputCMYK_.getAsBufferedImage();
>>>>>>>>>>> ColorSpace cs =
>>>>>>>>>>> ColorSpace.getInstance(ColorSpace.CS_GRAY);
>>>>>>>>>>> ColorConvertOp op = new ColorConvertOp(cs, null);
>>>>>>>>>>> BufferedImage bi = op.filter(inputCMYK, null);
>>>>>>>>>>> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>>>>>>>>>>> but it fails with: Bogus input colorspace
>>>>>>>>>>> for rgb2cmyk i uses this class:
>>>>>>>>>>> --
>>>>>>>>>>> /*
>>>>>>>>>>> * cmyk_handles.java
>>>>>>>>>>> *
>>>>>>>>>>> * Created on January 13, 2007, 11:20 PM
>>>>>>>>>>> *
>>>>>>>>>>> * To change this template, choose Tools | Template Manager
>>>>>>>>>>> * and open the template in the editor.
>>>>>>>>>>> */
>>>>>>>>>>> package nextgen;
>>>>>>>>>>> import com.sun.image.codec.jpeg.*;
>>>>>>>>>>> import java.awt.*;
>>>>>>>>>>> import java.awt.color.*;
>>>>>>>>>>> import java.awt.image.*;
>>>>>>>>>>> import java.io.*;
>>>>>>>>>>> import java.util.*;
>>>>>>>>>>> import javax.media.jai.*;
>>>>>>>>>>> /**
>>>>>>>>>>> *
>>>>>>>>>>> * @author kriswolff
>>>>>>>>>>> */
>>>>>>>>>>> public class rgb2cmyk_ICC {
>>>>>>>>>>>
>>>>>>>>>>> private static boolean invert = false;
>>>>>>>>>>> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>>>>>>>>>>>
>>>>>>>>>>> /** Creates a new instance of cmyk_handles */
>>>>>>>>>>> public rgb2cmyk_ICC() {
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> /**
>>>>>>>>>>> * @param args the command line arguments
>>>>>>>>>>> */
>>>>>>>>>>> public static void main(String[] args) {
>>>>>>>>>>> int[] bitsCMYK = {8,8,8,8};
>>>>>>>>>>>
>>>>>>>>>>> String cmykProfile = "/Library/Application
>>>>>>>>>>> Support/Adobe/Color/Profiles/Photoshop4DefaultCMYK.icc"; //
>>>>>>>>>>> icc-profile cmyk
>>>>>>>>>>> String rgbProfile = "/Library/Application
>>>>>>>>>>> Support/Adobe/Color/Profiles/Recommended/AppleRGB.icc";//
>>>>>>>>>>> icc-profile rgb
>>>>>>>>>>>
>>>>>>>>>>> // Dateiname fr die Ausgabe
>>>>>>>>>>> StringTokenizer st = new StringTokenizer(rgbdatei,".");
>>>>>>>>>>> StringBuffer buffer = new StringBuffer();
>>>>>>>>>>> while ( st.hasMoreTokens() ) {
>>>>>>>>>>> buffer.append(st.nextToken());
>>>>>>>>>>> buffer.append("_cmyk");
>>>>>>>>>>> buffer.append(".jpg");
>>>>>>>>>>> break;
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> try {
>>>>>>>>>>>
>>>>>>>>>>> RenderedImage inputRGB =
>>>>>>>>>>> JAI.create("fileload",rgbdatei);
>>>>>>>>>>>
>>>>>>>>>>> // Create a CMYK Color Space from cmykProfile
>>>>>>>>>>> ICC_Profile p = ICC_Profile.getInstance(new
>>>>>>>>>>> FileInputStream(cmykProfile));
>>>>>>>>>>> ColorSpace csCMYK = new ICC_ColorSpace(p);
>>>>>>>>>>>
>>>>>>>>>>> ColorModel colorModelCMYK = new
>>>>>>>>>>> ComponentColorModel(csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TYPE_BYTE);
>>>>>>>>>>>
>>>>>>>>>>> ImageLayout cmykLayout = new ImageLayout();
>>>>>>>>>>> cmykLayout.setColorModel(colorModelCMYK);
>>>>>>>>>>> RenderingHints hints = new
>>>>>>>>>>> RenderingHints(JAI.KEY_IMAGE_LAYOUT,cmykLayout);
>>>>>>>>>>> cmykLayout.setSampleModel(colorModelCMYK.createCompatibleSampleModel(inputRGB.getWidth(),inputRGB.getHeight()));
>>>>>>>>>>>
>>>>>>>>>>> java.awt.image.renderable.ParameterBlock pb = new
>>>>>>>>>>> java.awt.image.renderable.ParameterBlock();
>>>>>>>>>>> pb.addSource(inputRGB);
>>>>>>>>>>> pb.add(colorModelCMYK);
>>>>>>>>>>> // convert the image from rgb-colorspace to
>>>>>>>>>>> cmyk-colorspace with icc
>>>>>>>>>>> PlanarImage out = JAI.create("ColorConvert",pb,hints);
>>>>>>>>>>>
>>>>>>>>>>> // Damit photoshop die Bilddaten nicht invertiert
>>>>>>>>>>> anzeigt erfolgt
>>>>>>>>>>> // eine invertierung der Daten
>>>>>>>>>>> pb = new java.awt.image.renderable.ParameterBlock();
>>>>>>>>>>> pb.addSource(out);
>>>>>>>>>>> PlanarImage out2 = JAI.create("invert",pb);
>>>>>>>>>>>
>>>>>>>>>>> WritableRaster cmykRaster = out2.copyData();
>>>>>>>>>>> // ffnen des Output-Streams
>>>>>>>>>>> OutputStream datei = new
>>>>>>>>>>> FileOutputStream(buffer.toString());
>>>>>>>>>>>
>>>>>>>>>>> JPEGImageEncoder encoder =
>>>>>>>>>>> JPEGCodec.createJPEGEncoder(datei);
>>>>>>>>>>> JPEGEncodeParam param =
>>>>>>>>>>> encoder.getDefaultJPEGEncodeParam(cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
>>>>>>>>>>> param.setQuality(1, false);
>>>>>>>>>>> encoder.encode(cmykRaster, param);
>>>>>>>>>>> datei.close();
>>>>>>>>>>> System.out.println("Bild erfolgreich gespeichert");
>>>>>>>>>>>
>>>>>>>>>>> } catch (Exception e) {
>>>>>>>>>>> e.printStackTrace();
>>>>>>>>>>> }
>>>>>>>>>>> }
>>>>>>>>>>> }
>>>>>>>>>>> --
>>>>>>>>>>> so, i tryed to swap all cmyk to rgb and rgb to cmyk but this takes
>>>>>>>>>>> me into a long journy of errors and misunderstandable issues that
>>>>>>>>>>> takes me further away than i ever thougt about.
>>>>>>>>>>> So if anyone out there who is friendly and leads me into the
>>>>>>>>>>> light? I am absolutly burned out with this image things.
>>>>>>>>>>> Thank you very much in advanced.
>>>>>>>>>>> ven.
>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>>> interest-unsubscribe@jai-imageio.dev.java.net
>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>> interest-help@jai-imageio.dev.java.net
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>> interest-unsubscribe@jai-imageio.dev.java.net
>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>> interest-help@jai-imageio.dev.java.net
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>> interest-unsubscribe@jai-imageio.dev.java.net
>>>>>>>>> For additional commands, e-mail:
>>>>>>>>> interest-help@jai-imageio.dev.java.net
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>>>>>>>> For additional commands, e-mail:
>>>>>>>> interest-help@jai-imageio.dev.java.net
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>>>>>>> For additional commands, e-mail:
>>>>>>> interest-help@jai-imageio.dev.java.net
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>>>>>> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>>>>> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>>>
>>
>> ----------------
>> Brian Burkhalter
>> Java Media, Imaging, and Graphics
>> Sun Microsystems, Inc.
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> This email message is for the sole use of the intended recipient(s)
>> and may contain confidential and privileged information. Any
>> unauthorized review, use, disclosure or distribution is prohibited.
>> If you are not the intended recipient, please contact the sender by
>> reply email and destroy all copies of the original message.
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

shmert
Offline
Joined: 2006-03-15

Hi, i'm having very similar problems to yours, if you have any sample code, it would be greatly appreciated. Thanks!

Kris Wolff

Hi agian,

I tryed this on my laptop with
java version "1.5.0_06"

But i can't get it. If it possible you send me this lines. I am
totaly out of ideas, just need a tiny kick into the right direktion,
get over this part CMYK->RGB...

So you said: read into BuffersImage and just write into a new on. I
get This lines:

You can see 2 ways i've tried. The first gets a:
sun.awt.image.ImageFormatException: Unsupported color conversion request
The second a:
javax.imageio.IIOException: Unsupported Image Type

public static void main(String[] args) {
FileOutputStream fos = null;
try {

// VARIANT I / sun.awt.image.ImageFormatException:
Unsupported color conversion request
ImageIcon icon = new ImageIcon("/tmp/myimage.jpg");
Image image = icon.getImage();
BufferedImage cmyk =
new BufferedImage(
image.getWidth(null),
image.getHeight(null),
BufferedImage.TYPE_INT_ARGB);

// VARIANT II / javax.imageio.IIOException: Unsupported
Image Type
//BufferedImage cmyk = ImageIO.read(new File());

File outfile = new File("/tmp/aaa.jpg");
fos = new FileOutputStream(outfile);
ImageEncoder encoder = ImageCodec.createImageEncoder
("JPEG",fos,null);
PNGEncodeParam param = new PNGEncodeParam.RGB();
encoder.setParam(param);
encoder.encode(cmyk);
fos.close();
} catch (Exception e){
e.printStackTrace();
} finally {
try {
fos.close();
} catch (Exception e){
}
}
}

Thank you so much! ! !

ven.

On Jan 14, 2007, at 2:45 AM, robert engels wrote:

> Using ImageIO with JDK 1.5, you can read the CMYK jpg directly into
> a BufferedImage.
>
> Then once you have a BufferedImage, write the BufferedImage into a
> new RGB BufferedImage.
>
> Then write the RGB BufferedImage as a JPG using ImageIO.
>
>
> On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:
>
>> Hi folks,
>>
>> the whole day i spend in netbeans and the web to find a solution
>> to convert a cmyk-jpeg into rgb. The otherway works fine for me
>> since hours, but this is not what i need. :-(
>>
>> after many new ideas and posibilitys, tools and coffees, finaly
>> after 3pk. cigarettes i have this for convervting:
>>
>> PlanarImage inputCMYK_ = JAI.create("fileload",cmykdatei);
>> BufferedImage inputCMYK = inputCMYK_.getAsBufferedImage
>> ();
>> ColorSpace cs = ColorSpace.getInstance
>> (ColorSpace.CS_GRAY);
>> ColorConvertOp op = new ColorConvertOp(cs, null);
>> BufferedImage bi = op.filter(inputCMYK, null);
>> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>>
>> but it fails with: Bogus input colorspace
>>
>> for rgb2cmyk i uses this class:
>>
>> --
>> /*
>> * cmyk_handles.java
>> *
>> * Created on January 13, 2007, 11:20 PM
>> *
>> * To change this template, choose Tools | Template Manager
>> * and open the template in the editor.
>> */
>>
>> package nextgen;
>>
>> import com.sun.image.codec.jpeg.*;
>> import java.awt.*;
>> import java.awt.color.*;
>> import java.awt.image.*;
>> import java.io.*;
>> import java.util.*;
>> import javax.media.jai.*;
>>
>> /**
>> *
>> * @author kriswolff
>> */
>> public class rgb2cmyk_ICC {
>>
>> private static boolean invert = false;
>> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>>
>> /** Creates a new instance of cmyk_handles */
>> public rgb2cmyk_ICC() {
>> }
>>
>> /**
>> * @param args the command line arguments
>> */
>> public static void main(String[] args) {
>> int[] bitsCMYK = {8,8,8,8};
>>
>> String cmykProfile = "/Library/Application Support/Adobe/
>> Color/Profiles/Photoshop4DefaultCMYK.icc"; // icc-profile cmyk
>> String rgbProfile = "/Library/Application Support/Adobe/
>> Color/Profiles/Recommended/AppleRGB.icc";// icc-profile rgb
>>
>> // Dateiname f�r die Ausgabe
>> StringTokenizer st = new StringTokenizer(rgbdatei,".");
>> StringBuffer buffer = new StringBuffer();
>> while ( st.hasMoreTokens() ) {
>> buffer.append(st.nextToken());
>> buffer.append("_cmyk");
>> buffer.append(".jpg");
>> break;
>> }
>>
>> try {
>>
>> RenderedImage inputRGB = JAI.create("fileload",rgbdatei);
>>
>> // Create a CMYK Color Space from cmykProfile
>> ICC_Profile p = ICC_Profile.getInstance(new
>> FileInputStream(cmykProfile));
>> ColorSpace csCMYK = new ICC_ColorSpace(p);
>>
>> ColorModel colorModelCMYK = new ComponentColorModel
>> (csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TYPE_BYTE
>> );
>>
>> ImageLayout cmykLayout = new ImageLayout();
>> cmykLayout.setColorModel(colorModelCMYK);
>> RenderingHints hints = new RenderingHints
>> (JAI.KEY_IMAGE_LAYOUT,cmykLayout);
>> cmykLayout.setSampleModel
>> (colorModelCMYK.createCompatibleSampleModel(inputRGB.getWidth
>> (),inputRGB.getHeight()));
>>
>> java.awt.image.renderable.ParameterBlock pb = new
>> java.awt.image.renderable.ParameterBlock();
>> pb.addSource(inputRGB);
>> pb.add(colorModelCMYK);
>> // convert the image from rgb-colorspace to cmyk-
>> colorspace with icc
>> PlanarImage out = JAI.create("ColorConvert",pb,hints);
>>
>> // Damit photoshop die Bilddaten nicht invertiert
>> anzeigt erfolgt
>> // eine invertierung der Daten
>> pb = new java.awt.image.renderable.ParameterBlock();
>> pb.addSource(out);
>> PlanarImage out2 = JAI.create("invert",pb);
>>
>> WritableRaster cmykRaster = out2.copyData();
>> // �ffnen des Output-Streams
>> OutputStream datei = new FileOutputStream
>> (buffer.toString());
>>
>> JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder
>> (datei);
>> JPEGEncodeParam param =
>> encoder.getDefaultJPEGEncodeParam
>> (cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
>> param.setQuality(1, false);
>> encoder.encode(cmykRaster, param);
>> datei.close();
>> System.out.println("Bild erfolgreich gespeichert");
>>
>> } catch (Exception e) {
>> e.printStackTrace();
>> }
>> }
>> }
>> --
>>
>>
>> so, i tryed to swap all cmyk to rgb and rgb to cmyk but this takes
>> me into a long journy of errors and misunderstandable issues that
>> takes me further away than i ever thougt about.
>>
>> So if anyone out there who is friendly and leads me into the
>> light? I am absolutly burned out with this image things.
>>
>>
>> Thank you very much in advanced.
>> ven.
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>> For additional commands, e-mail: interest-help@jai-
>> imageio.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

robert engels

You need to use code like

BufferedImage i0 = ImageIO.read(new File("somefilename.jpg"));
BufferedImage i1 = new BufferedImage(i0.getWidth(),i0.getheight
(),BufferedImage.INT_ARGB);
ImageIO.write(new File("newfilename.jpg","jpg",i1);

On Jan 13, 2007, at 10:20 PM, Kris Wolff wrote:

> Hi agian,
>
> I tryed this on my laptop with
> java version "1.5.0_06"
>
> But i can't get it. If it possible you send me this lines. I am
> totaly out of ideas, just need a tiny kick into the right
> direktion, get over this part CMYK->RGB...
>
> So you said: read into BuffersImage and just write into a new on. I
> get This lines:
>
> You can see 2 ways i've tried. The first gets a:
> sun.awt.image.ImageFormatException: Unsupported color conversion
> request
> The second a:
> javax.imageio.IIOException: Unsupported Image Type
>
>
> public static void main(String[] args) {
> FileOutputStream fos = null;
> try {
>
> // VARIANT I / sun.awt.image.ImageFormatException:
> Unsupported color conversion request
> ImageIcon icon = new ImageIcon("/tmp/myimage.jpg");
> Image image = icon.getImage();
> BufferedImage cmyk =
> new BufferedImage(
> image.getWidth(null),
> image.getHeight(null),
> BufferedImage.TYPE_INT_ARGB);
>
> // VARIANT II / javax.imageio.IIOException: Unsupported
> Image Type
> //BufferedImage cmyk = ImageIO.read(new File());
>
> File outfile = new File("/tmp/aaa.jpg");
> fos = new FileOutputStream(outfile);
> ImageEncoder encoder = ImageCodec.createImageEncoder
> ("JPEG",fos,null);
> PNGEncodeParam param = new PNGEncodeParam.RGB();
> encoder.setParam(param);
> encoder.encode(cmyk);
> fos.close();
> } catch (Exception e){
> e.printStackTrace();
> } finally {
> try {
> fos.close();
> } catch (Exception e){
> }
> }
> }
>
>
>
> Thank you so much! ! !
>
> ven.
>
>
> On Jan 14, 2007, at 2:45 AM, robert engels wrote:
>
>> Using ImageIO with JDK 1.5, you can read the CMYK jpg directly
>> into a BufferedImage.
>>
>> Then once you have a BufferedImage, write the BufferedImage into a
>> new RGB BufferedImage.
>>
>> Then write the RGB BufferedImage as a JPG using ImageIO.
>>
>>
>> On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:
>>
>>> Hi folks,
>>>
>>> the whole day i spend in netbeans and the web to find a solution
>>> to convert a cmyk-jpeg into rgb. The otherway works fine for me
>>> since hours, but this is not what i need. :-(
>>>
>>> after many new ideas and posibilitys, tools and coffees, finaly
>>> after 3pk. cigarettes i have this for convervting:
>>>
>>> PlanarImage inputCMYK_ = JAI.create
>>> ("fileload",cmykdatei);
>>> BufferedImage inputCMYK =
>>> inputCMYK_.getAsBufferedImage();
>>> ColorSpace cs = ColorSpace.getInstance
>>> (ColorSpace.CS_GRAY);
>>> ColorConvertOp op = new ColorConvertOp(cs, null);
>>> BufferedImage bi = op.filter(inputCMYK, null);
>>> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>>>
>>> but it fails with: Bogus input colorspace
>>>
>>> for rgb2cmyk i uses this class:
>>>
>>> --
>>> /*
>>> * cmyk_handles.java
>>> *
>>> * Created on January 13, 2007, 11:20 PM
>>> *
>>> * To change this template, choose Tools | Template Manager
>>> * and open the template in the editor.
>>> */
>>>
>>> package nextgen;
>>>
>>> import com.sun.image.codec.jpeg.*;
>>> import java.awt.*;
>>> import java.awt.color.*;
>>> import java.awt.image.*;
>>> import java.io.*;
>>> import java.util.*;
>>> import javax.media.jai.*;
>>>
>>> /**
>>> *
>>> * @author kriswolff
>>> */
>>> public class rgb2cmyk_ICC {
>>>
>>> private static boolean invert = false;
>>> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>>>
>>> /** Creates a new instance of cmyk_handles */
>>> public rgb2cmyk_ICC() {
>>> }
>>>
>>> /**
>>> * @param args the command line arguments
>>> */
>>> public static void main(String[] args) {
>>> int[] bitsCMYK = {8,8,8,8};
>>>
>>> String cmykProfile = "/Library/Application Support/Adobe/
>>> Color/Profiles/Photoshop4DefaultCMYK.icc"; // icc-profile cmyk
>>> String rgbProfile = "/Library/Application Support/Adobe/
>>> Color/Profiles/Recommended/AppleRGB.icc";// icc-profile rgb
>>>
>>> // Dateiname f�r die Ausgabe
>>> StringTokenizer st = new StringTokenizer(rgbdatei,".");
>>> StringBuffer buffer = new StringBuffer();
>>> while ( st.hasMoreTokens() ) {
>>> buffer.append(st.nextToken());
>>> buffer.append("_cmyk");
>>> buffer.append(".jpg");
>>> break;
>>> }
>>>
>>> try {
>>>
>>> RenderedImage inputRGB = JAI.create
>>> ("fileload",rgbdatei);
>>>
>>> // Create a CMYK Color Space from cmykProfile
>>> ICC_Profile p = ICC_Profile.getInstance(new
>>> FileInputStream(cmykProfile));
>>> ColorSpace csCMYK = new ICC_ColorSpace(p);
>>>
>>> ColorModel colorModelCMYK = new ComponentColorModel
>>> (csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TYPE_BYT
>>> E);
>>>
>>> ImageLayout cmykLayout = new ImageLayout();
>>> cmykLayout.setColorModel(colorModelCMYK);
>>> RenderingHints hints = new RenderingHints
>>> (JAI.KEY_IMAGE_LAYOUT,cmykLayout);
>>> cmykLayout.setSampleModel
>>> (colorModelCMYK.createCompatibleSampleModel(inputRGB.getWidth
>>> (),inputRGB.getHeight()));
>>>
>>> java.awt.image.renderable.ParameterBlock pb = new
>>> java.awt.image.renderable.ParameterBlock();
>>> pb.addSource(inputRGB);
>>> pb.add(colorModelCMYK);
>>> // convert the image from rgb-colorspace to cmyk-
>>> colorspace with icc
>>> PlanarImage out = JAI.create("ColorConvert",pb,hints);
>>>
>>> // Damit photoshop die Bilddaten nicht invertiert
>>> anzeigt erfolgt
>>> // eine invertierung der Daten
>>> pb = new java.awt.image.renderable.ParameterBlock();
>>> pb.addSource(out);
>>> PlanarImage out2 = JAI.create("invert",pb);
>>>
>>> WritableRaster cmykRaster = out2.copyData();
>>> // �ffnen des Output-Streams
>>> OutputStream datei = new FileOutputStream
>>> (buffer.toString());
>>>
>>> JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder
>>> (datei);
>>> JPEGEncodeParam param =
>>> encoder.getDefaultJPEGEncodeParam
>>> (cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
>>> param.setQuality(1, false);
>>> encoder.encode(cmykRaster, param);
>>> datei.close();
>>> System.out.println("Bild erfolgreich gespeichert");
>>>
>>> } catch (Exception e) {
>>> e.printStackTrace();
>>> }
>>> }
>>> }
>>> --
>>>
>>>
>>> so, i tryed to swap all cmyk to rgb and rgb to cmyk but this
>>> takes me into a long journy of errors and misunderstandable
>>> issues that takes me further away than i ever thougt about.
>>>
>>> So if anyone out there who is friendly and leads me into the
>>> light? I am absolutly burned out with this image things.
>>>
>>>
>>> Thank you very much in advanced.
>>> ven.
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>> imageio.dev.java.net
>>> For additional commands, e-mail: interest-help@jai-
>>> imageio.dev.java.net
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>> For additional commands, e-mail: interest-help@jai-
>> imageio.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Kris Wolff

Hm, and this works for you?
I am getting a Unsupported Image Type while loading the CMYK image.

its an CMYK/8 JPEG building with Photoshop. I tryed several CMYK-
Images. No-Go. :-(

--
javax.imageio.IIOException: Unsupported Image Type
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal
(JPEGImageReader.java:889)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read
(JPEGImageReader.java:864)
at javax.imageio.ImageIO.read(ImageIO.java:1400)
at javax.imageio.ImageIO.read(ImageIO.java:1286)
--

in: BufferedImage i0 = ImageIO.read(new File("/tmp/2.JPG"));

ven.

On Jan 14, 2007, at 5:29 AM, robert engels wrote:

>
> You need to use code like
>
> BufferedImage i0 = ImageIO.read(new File("somefilename.jpg"));
> BufferedImage i1 = new BufferedImage(i0.getWidth(),i0.getheight
> (),BufferedImage.INT_ARGB);
> ImageIO.write(new File("newfilename.jpg","jpg",i1);
>
>
> On Jan 13, 2007, at 10:20 PM, Kris Wolff wrote:
>
>> Hi agian,
>>
>> I tryed this on my laptop with
>> java version "1.5.0_06"
>>
>> But i can't get it. If it possible you send me this lines. I am
>> totaly out of ideas, just need a tiny kick into the right
>> direktion, get over this part CMYK->RGB...
>>
>> So you said: read into BuffersImage and just write into a new on.
>> I get This lines:
>>
>> You can see 2 ways i've tried. The first gets a:
>> sun.awt.image.ImageFormatException: Unsupported color conversion
>> request
>> The second a:
>> javax.imageio.IIOException: Unsupported Image Type
>>
>>
>> public static void main(String[] args) {
>> FileOutputStream fos = null;
>> try {
>>
>> // VARIANT I / sun.awt.image.ImageFormatException:
>> Unsupported color conversion request
>> ImageIcon icon = new ImageIcon("/tmp/myimage.jpg");
>> Image image = icon.getImage();
>> BufferedImage cmyk =
>> new BufferedImage(
>> image.getWidth(null),
>> image.getHeight(null),
>> BufferedImage.TYPE_INT_ARGB);
>>
>> // VARIANT II / javax.imageio.IIOException:
>> Unsupported Image Type
>> //BufferedImage cmyk = ImageIO.read(new File());
>>
>> File outfile = new File("/tmp/aaa.jpg");
>> fos = new FileOutputStream(outfile);
>> ImageEncoder encoder = ImageCodec.createImageEncoder
>> ("JPEG",fos,null);
>> PNGEncodeParam param = new PNGEncodeParam.RGB();
>> encoder.setParam(param);
>> encoder.encode(cmyk);
>> fos.close();
>> } catch (Exception e){
>> e.printStackTrace();
>> } finally {
>> try {
>> fos.close();
>> } catch (Exception e){
>> }
>> }
>> }
>>
>>
>>
>> Thank you so much! ! !
>>
>> ven.
>>
>>
>> On Jan 14, 2007, at 2:45 AM, robert engels wrote:
>>
>>> Using ImageIO with JDK 1.5, you can read the CMYK jpg directly
>>> into a BufferedImage.
>>>
>>> Then once you have a BufferedImage, write the BufferedImage into
>>> a new RGB BufferedImage.
>>>
>>> Then write the RGB BufferedImage as a JPG using ImageIO.
>>>
>>>
>>> On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:
>>>
>>>> Hi folks,
>>>>
>>>> the whole day i spend in netbeans and the web to find a solution
>>>> to convert a cmyk-jpeg into rgb. The otherway works fine for me
>>>> since hours, but this is not what i need. :-(
>>>>
>>>> after many new ideas and posibilitys, tools and coffees, finaly
>>>> after 3pk. cigarettes i have this for convervting:
>>>>
>>>> PlanarImage inputCMYK_ = JAI.create
>>>> ("fileload",cmykdatei);
>>>> BufferedImage inputCMYK =
>>>> inputCMYK_.getAsBufferedImage();
>>>> ColorSpace cs = ColorSpace.getInstance
>>>> (ColorSpace.CS_GRAY);
>>>> ColorConvertOp op = new ColorConvertOp(cs, null);
>>>> BufferedImage bi = op.filter(inputCMYK, null);
>>>> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>>>>
>>>> but it fails with: Bogus input colorspace
>>>>
>>>> for rgb2cmyk i uses this class:
>>>>
>>>> --
>>>> /*
>>>> * cmyk_handles.java
>>>> *
>>>> * Created on January 13, 2007, 11:20 PM
>>>> *
>>>> * To change this template, choose Tools | Template Manager
>>>> * and open the template in the editor.
>>>> */
>>>>
>>>> package nextgen;
>>>>
>>>> import com.sun.image.codec.jpeg.*;
>>>> import java.awt.*;
>>>> import java.awt.color.*;
>>>> import java.awt.image.*;
>>>> import java.io.*;
>>>> import java.util.*;
>>>> import javax.media.jai.*;
>>>>
>>>> /**
>>>> *
>>>> * @author kriswolff
>>>> */
>>>> public class rgb2cmyk_ICC {
>>>>
>>>> private static boolean invert = false;
>>>> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>>>>
>>>> /** Creates a new instance of cmyk_handles */
>>>> public rgb2cmyk_ICC() {
>>>> }
>>>>
>>>> /**
>>>> * @param args the command line arguments
>>>> */
>>>> public static void main(String[] args) {
>>>> int[] bitsCMYK = {8,8,8,8};
>>>>
>>>> String cmykProfile = "/Library/Application Support/Adobe/
>>>> Color/Profiles/Photoshop4DefaultCMYK.icc"; // icc-profile cmyk
>>>> String rgbProfile = "/Library/Application Support/Adobe/
>>>> Color/Profiles/Recommended/AppleRGB.icc";// icc-profile rgb
>>>>
>>>> // Dateiname f�r die Ausgabe
>>>> StringTokenizer st = new StringTokenizer(rgbdatei,".");
>>>> StringBuffer buffer = new StringBuffer();
>>>> while ( st.hasMoreTokens() ) {
>>>> buffer.append(st.nextToken());
>>>> buffer.append("_cmyk");
>>>> buffer.append(".jpg");
>>>> break;
>>>> }
>>>>
>>>> try {
>>>>
>>>> RenderedImage inputRGB = JAI.create
>>>> ("fileload",rgbdatei);
>>>>
>>>> // Create a CMYK Color Space from cmykProfile
>>>> ICC_Profile p = ICC_Profile.getInstance(new
>>>> FileInputStream(cmykProfile));
>>>> ColorSpace csCMYK = new ICC_ColorSpace(p);
>>>>
>>>> ColorModel colorModelCMYK = new ComponentColorModel
>>>> (csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TYPE_BY
>>>> TE);
>>>>
>>>> ImageLayout cmykLayout = new ImageLayout();
>>>> cmykLayout.setColorModel(colorModelCMYK);
>>>> RenderingHints hints = new RenderingHints
>>>> (JAI.KEY_IMAGE_LAYOUT,cmykLayout);
>>>> cmykLayout.setSampleModel
>>>> (colorModelCMYK.createCompatibleSampleModel(inputRGB.getWidth
>>>> (),inputRGB.getHeight()));
>>>>
>>>> java.awt.image.renderable.ParameterBlock pb = new
>>>> java.awt.image.renderable.ParameterBlock();
>>>> pb.addSource(inputRGB);
>>>> pb.add(colorModelCMYK);
>>>> // convert the image from rgb-colorspace to cmyk-
>>>> colorspace with icc
>>>> PlanarImage out = JAI.create("ColorConvert",pb,hints);
>>>>
>>>> // Damit photoshop die Bilddaten nicht invertiert
>>>> anzeigt erfolgt
>>>> // eine invertierung der Daten
>>>> pb = new java.awt.image.renderable.ParameterBlock();
>>>> pb.addSource(out);
>>>> PlanarImage out2 = JAI.create("invert",pb);
>>>>
>>>> WritableRaster cmykRaster = out2.copyData();
>>>> // �ffnen des Output-Streams
>>>> OutputStream datei = new FileOutputStream
>>>> (buffer.toString());
>>>>
>>>> JPEGImageEncoder encoder =
>>>> JPEGCodec.createJPEGEncoder(datei);
>>>> JPEGEncodeParam param =
>>>> encoder.getDefaultJPEGEncodeParam
>>>> (cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
>>>> param.setQuality(1, false);
>>>> encoder.encode(cmykRaster, param);
>>>> datei.close();
>>>> System.out.println("Bild erfolgreich gespeichert");
>>>>
>>>> } catch (Exception e) {
>>>> e.printStackTrace();
>>>> }
>>>> }
>>>> }
>>>> --
>>>>
>>>>
>>>> so, i tryed to swap all cmyk to rgb and rgb to cmyk but this
>>>> takes me into a long journy of errors and misunderstandable
>>>> issues that takes me further away than i ever thougt about.
>>>>
>>>> So if anyone out there who is friendly and leads me into the
>>>> light? I am absolutly burned out with this image things.
>>>>
>>>>
>>>> Thank you very much in advanced.
>>>> ven.
>>>> -------------------------------------------------------------------
>>>> --
>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>> imageio.dev.java.net
>>>> For additional commands, e-mail: interest-help@jai-
>>>> imageio.dev.java.net
>>>>
>>>
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>> imageio.dev.java.net
>>> For additional commands, e-mail: interest-help@jai-
>>> imageio.dev.java.net
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>> For additional commands, e-mail: interest-help@jai-
>> imageio.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

robert engels

I think it is probably because you are on a Mac - so you don't have
the native libs, which also prevents ImageIO from loading the CMYK
image.

You'll have the check the archives on reading a CMYK image using
ImageIO and reading the Raster.

On Jan 13, 2007, at 10:48 PM, Kris Wolff wrote:

> Hm, and this works for you?
> I am getting a Unsupported Image Type while loading the CMYK image.
>
> its an CMYK/8 JPEG building with Photoshop. I tryed several CMYK-
> Images. No-Go. :-(
>
> --
> javax.imageio.IIOException: Unsupported Image Type
> at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal
> (JPEGImageReader.java:889)
> at com.sun.imageio.plugins.jpeg.JPEGImageReader.read
> (JPEGImageReader.java:864)
> at javax.imageio.ImageIO.read(ImageIO.java:1400)
> at javax.imageio.ImageIO.read(ImageIO.java:1286)
> --
>
> in: BufferedImage i0 = ImageIO.read(new File("/tmp/2.JPG"));
>
>
> ven.
>
>
>
> On Jan 14, 2007, at 5:29 AM, robert engels wrote:
>
>>
>> You need to use code like
>>
>> BufferedImage i0 = ImageIO.read(new File("somefilename.jpg"));
>> BufferedImage i1 = new BufferedImage(i0.getWidth(),i0.getheight
>> (),BufferedImage.INT_ARGB);
>> ImageIO.write(new File("newfilename.jpg","jpg",i1);
>>
>>
>> On Jan 13, 2007, at 10:20 PM, Kris Wolff wrote:
>>
>>> Hi agian,
>>>
>>> I tryed this on my laptop with
>>> java version "1.5.0_06"
>>>
>>> But i can't get it. If it possible you send me this lines. I am
>>> totaly out of ideas, just need a tiny kick into the right
>>> direktion, get over this part CMYK->RGB...
>>>
>>> So you said: read into BuffersImage and just write into a new on.
>>> I get This lines:
>>>
>>> You can see 2 ways i've tried. The first gets a:
>>> sun.awt.image.ImageFormatException: Unsupported color conversion
>>> request
>>> The second a:
>>> javax.imageio.IIOException: Unsupported Image Type
>>>
>>>
>>> public static void main(String[] args) {
>>> FileOutputStream fos = null;
>>> try {
>>>
>>> // VARIANT I / sun.awt.image.ImageFormatException:
>>> Unsupported color conversion request
>>> ImageIcon icon = new ImageIcon("/tmp/myimage.jpg");
>>> Image image = icon.getImage();
>>> BufferedImage cmyk =
>>> new BufferedImage(
>>> image.getWidth(null),
>>> image.getHeight(null),
>>> BufferedImage.TYPE_INT_ARGB);
>>>
>>> // VARIANT II / javax.imageio.IIOException:
>>> Unsupported Image Type
>>> //BufferedImage cmyk = ImageIO.read(new File());
>>>
>>> File outfile = new File("/tmp/aaa.jpg");
>>> fos = new FileOutputStream(outfile);
>>> ImageEncoder encoder = ImageCodec.createImageEncoder
>>> ("JPEG",fos,null);
>>> PNGEncodeParam param = new PNGEncodeParam.RGB();
>>> encoder.setParam(param);
>>> encoder.encode(cmyk);
>>> fos.close();
>>> } catch (Exception e){
>>> e.printStackTrace();
>>> } finally {
>>> try {
>>> fos.close();
>>> } catch (Exception e){
>>> }
>>> }
>>> }
>>>
>>>
>>>
>>> Thank you so much! ! !
>>>
>>> ven.
>>>
>>>
>>> On Jan 14, 2007, at 2:45 AM, robert engels wrote:
>>>
>>>> Using ImageIO with JDK 1.5, you can read the CMYK jpg directly
>>>> into a BufferedImage.
>>>>
>>>> Then once you have a BufferedImage, write the BufferedImage into
>>>> a new RGB BufferedImage.
>>>>
>>>> Then write the RGB BufferedImage as a JPG using ImageIO.
>>>>
>>>>
>>>> On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:
>>>>
>>>>> Hi folks,
>>>>>
>>>>> the whole day i spend in netbeans and the web to find a
>>>>> solution to convert a cmyk-jpeg into rgb. The otherway works
>>>>> fine for me since hours, but this is not what i need. :-(
>>>>>
>>>>> after many new ideas and posibilitys, tools and coffees, finaly
>>>>> after 3pk. cigarettes i have this for convervting:
>>>>>
>>>>> PlanarImage inputCMYK_ = JAI.create
>>>>> ("fileload",cmykdatei);
>>>>> BufferedImage inputCMYK =
>>>>> inputCMYK_.getAsBufferedImage();
>>>>> ColorSpace cs = ColorSpace.getInstance
>>>>> (ColorSpace.CS_GRAY);
>>>>> ColorConvertOp op = new ColorConvertOp(cs, null);
>>>>> BufferedImage bi = op.filter(inputCMYK, null);
>>>>> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>>>>>
>>>>> but it fails with: Bogus input colorspace
>>>>>
>>>>> for rgb2cmyk i uses this class:
>>>>>
>>>>> --
>>>>> /*
>>>>> * cmyk_handles.java
>>>>> *
>>>>> * Created on January 13, 2007, 11:20 PM
>>>>> *
>>>>> * To change this template, choose Tools | Template Manager
>>>>> * and open the template in the editor.
>>>>> */
>>>>>
>>>>> package nextgen;
>>>>>
>>>>> import com.sun.image.codec.jpeg.*;
>>>>> import java.awt.*;
>>>>> import java.awt.color.*;
>>>>> import java.awt.image.*;
>>>>> import java.io.*;
>>>>> import java.util.*;
>>>>> import javax.media.jai.*;
>>>>>
>>>>> /**
>>>>> *
>>>>> * @author kriswolff
>>>>> */
>>>>> public class rgb2cmyk_ICC {
>>>>>
>>>>> private static boolean invert = false;
>>>>> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>>>>>
>>>>> /** Creates a new instance of cmyk_handles */
>>>>> public rgb2cmyk_ICC() {
>>>>> }
>>>>>
>>>>> /**
>>>>> * @param args the command line arguments
>>>>> */
>>>>> public static void main(String[] args) {
>>>>> int[] bitsCMYK = {8,8,8,8};
>>>>>
>>>>> String cmykProfile = "/Library/Application Support/
>>>>> Adobe/Color/Profiles/Photoshop4DefaultCMYK.icc"; // icc-profile
>>>>> cmyk
>>>>> String rgbProfile = "/Library/Application Support/Adobe/
>>>>> Color/Profiles/Recommended/AppleRGB.icc";// icc-profile rgb
>>>>>
>>>>> // Dateiname f�r die Ausgabe
>>>>> StringTokenizer st = new StringTokenizer(rgbdatei,".");
>>>>> StringBuffer buffer = new StringBuffer();
>>>>> while ( st.hasMoreTokens() ) {
>>>>> buffer.append(st.nextToken());
>>>>> buffer.append("_cmyk");
>>>>> buffer.append(".jpg");
>>>>> break;
>>>>> }
>>>>>
>>>>> try {
>>>>>
>>>>> RenderedImage inputRGB = JAI.create
>>>>> ("fileload",rgbdatei);
>>>>>
>>>>> // Create a CMYK Color Space from cmykProfile
>>>>> ICC_Profile p = ICC_Profile.getInstance(new
>>>>> FileInputStream(cmykProfile));
>>>>> ColorSpace csCMYK = new ICC_ColorSpace(p);
>>>>>
>>>>> ColorModel colorModelCMYK = new ComponentColorModel
>>>>> (csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TYPE_B
>>>>> YTE);
>>>>>
>>>>> ImageLayout cmykLayout = new ImageLayout();
>>>>> cmykLayout.setColorModel(colorModelCMYK);
>>>>> RenderingHints hints = new RenderingHints
>>>>> (JAI.KEY_IMAGE_LAYOUT,cmykLayout);
>>>>> cmykLayout.setSampleModel
>>>>> (colorModelCMYK.createCompatibleSampleModel(inputRGB.getWidth
>>>>> (),inputRGB.getHeight()));
>>>>>
>>>>> java.awt.image.renderable.ParameterBlock pb = new
>>>>> java.awt.image.renderable.ParameterBlock();
>>>>> pb.addSource(inputRGB);
>>>>> pb.add(colorModelCMYK);
>>>>> // convert the image from rgb-colorspace to cmyk-
>>>>> colorspace with icc
>>>>> PlanarImage out = JAI.create("ColorConvert",pb,hints);
>>>>>
>>>>> // Damit photoshop die Bilddaten nicht invertiert
>>>>> anzeigt erfolgt
>>>>> // eine invertierung der Daten
>>>>> pb = new java.awt.image.renderable.ParameterBlock();
>>>>> pb.addSource(out);
>>>>> PlanarImage out2 = JAI.create("invert",pb);
>>>>>
>>>>> WritableRaster cmykRaster = out2.copyData();
>>>>> // �ffnen des Output-Streams
>>>>> OutputStream datei = new FileOutputStream
>>>>> (buffer.toString());
>>>>>
>>>>> JPEGImageEncoder encoder =
>>>>> JPEGCodec.createJPEGEncoder(datei);
>>>>> JPEGEncodeParam param =
>>>>> encoder.getDefaultJPEGEncodeParam
>>>>> (cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
>>>>> param.setQuality(1, false);
>>>>> encoder.encode(cmykRaster, param);
>>>>> datei.close();
>>>>> System.out.println("Bild erfolgreich gespeichert");
>>>>>
>>>>> } catch (Exception e) {
>>>>> e.printStackTrace();
>>>>> }
>>>>> }
>>>>> }
>>>>> --
>>>>>
>>>>>
>>>>> so, i tryed to swap all cmyk to rgb and rgb to cmyk but this
>>>>> takes me into a long journy of errors and misunderstandable
>>>>> issues that takes me further away than i ever thougt about.
>>>>>
>>>>> So if anyone out there who is friendly and leads me into the
>>>>> light? I am absolutly burned out with this image things.
>>>>>
>>>>>
>>>>> Thank you very much in advanced.
>>>>> ven.
>>>>> ------------------------------------------------------------------
>>>>> ---
>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>> imageio.dev.java.net
>>>>> For additional commands, e-mail: interest-help@jai-
>>>>> imageio.dev.java.net
>>>>>
>>>>
>>>> -------------------------------------------------------------------
>>>> --
>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>> imageio.dev.java.net
>>>> For additional commands, e-mail: interest-help@jai-
>>>> imageio.dev.java.net
>>>>
>>>
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>> imageio.dev.java.net
>>> For additional commands, e-mail: interest-help@jai-
>>> imageio.dev.java.net
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>> For additional commands, e-mail: interest-help@jai-
>> imageio.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Kris Wolff

ok.
thanks for your help. i am a huge step further. focusing on raster...

if you find an example,
pls. share it. I will search the archive once again.

ven.

On Jan 14, 2007, at 5:52 AM, robert engels wrote:

> I think it is probably because you are on a Mac - so you don't have
> the native libs, which also prevents ImageIO from loading the CMYK
> image.
>
> You'll have the check the archives on reading a CMYK image using
> ImageIO and reading the Raster.
>
> On Jan 13, 2007, at 10:48 PM, Kris Wolff wrote:
>
>> Hm, and this works for you?
>> I am getting a Unsupported Image Type while loading the CMYK image.
>>
>> its an CMYK/8 JPEG building with Photoshop. I tryed several CMYK-
>> Images. No-Go. :-(
>>
>> --
>> javax.imageio.IIOException: Unsupported Image Type
>> at
>> com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal
>> (JPEGImageReader.java:889)
>> at com.sun.imageio.plugins.jpeg.JPEGImageReader.read
>> (JPEGImageReader.java:864)
>> at javax.imageio.ImageIO.read(ImageIO.java:1400)
>> at javax.imageio.ImageIO.read(ImageIO.java:1286)
>> --
>>
>> in: BufferedImage i0 = ImageIO.read(new File("/tmp/2.JPG"));
>>
>>
>> ven.
>>
>>
>>
>> On Jan 14, 2007, at 5:29 AM, robert engels wrote:
>>
>>>
>>> You need to use code like
>>>
>>> BufferedImage i0 = ImageIO.read(new File("somefilename.jpg"));
>>> BufferedImage i1 = new BufferedImage(i0.getWidth(),i0.getheight
>>> (),BufferedImage.INT_ARGB);
>>> ImageIO.write(new File("newfilename.jpg","jpg",i1);
>>>
>>>
>>> On Jan 13, 2007, at 10:20 PM, Kris Wolff wrote:
>>>
>>>> Hi agian,
>>>>
>>>> I tryed this on my laptop with
>>>> java version "1.5.0_06"
>>>>
>>>> But i can't get it. If it possible you send me this lines. I am
>>>> totaly out of ideas, just need a tiny kick into the right
>>>> direktion, get over this part CMYK->RGB...
>>>>
>>>> So you said: read into BuffersImage and just write into a new
>>>> on. I get This lines:
>>>>
>>>> You can see 2 ways i've tried. The first gets a:
>>>> sun.awt.image.ImageFormatException: Unsupported color conversion
>>>> request
>>>> The second a:
>>>> javax.imageio.IIOException: Unsupported Image Type
>>>>
>>>>
>>>> public static void main(String[] args) {
>>>> FileOutputStream fos = null;
>>>> try {
>>>>
>>>> // VARIANT I / sun.awt.image.ImageFormatException:
>>>> Unsupported color conversion request
>>>> ImageIcon icon = new ImageIcon("/tmp/myimage.jpg");
>>>> Image image = icon.getImage();
>>>> BufferedImage cmyk =
>>>> new BufferedImage(
>>>> image.getWidth(null),
>>>> image.getHeight(null),
>>>> BufferedImage.TYPE_INT_ARGB);
>>>>
>>>> // VARIANT II / javax.imageio.IIOException:
>>>> Unsupported Image Type
>>>> //BufferedImage cmyk = ImageIO.read(new File());
>>>>
>>>> File outfile = new File("/tmp/aaa.jpg");
>>>> fos = new FileOutputStream(outfile);
>>>> ImageEncoder encoder = ImageCodec.createImageEncoder
>>>> ("JPEG",fos,null);
>>>> PNGEncodeParam param = new PNGEncodeParam.RGB();
>>>> encoder.setParam(param);
>>>> encoder.encode(cmyk);
>>>> fos.close();
>>>> } catch (Exception e){
>>>> e.printStackTrace();
>>>> } finally {
>>>> try {
>>>> fos.close();
>>>> } catch (Exception e){
>>>> }
>>>> }
>>>> }
>>>>
>>>>
>>>>
>>>> Thank you so much! ! !
>>>>
>>>> ven.
>>>>
>>>>
>>>> On Jan 14, 2007, at 2:45 AM, robert engels wrote:
>>>>
>>>>> Using ImageIO with JDK 1.5, you can read the CMYK jpg directly
>>>>> into a BufferedImage.
>>>>>
>>>>> Then once you have a BufferedImage, write the BufferedImage
>>>>> into a new RGB BufferedImage.
>>>>>
>>>>> Then write the RGB BufferedImage as a JPG using ImageIO.
>>>>>
>>>>>
>>>>> On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:
>>>>>
>>>>>> Hi folks,
>>>>>>
>>>>>> the whole day i spend in netbeans and the web to find a
>>>>>> solution to convert a cmyk-jpeg into rgb. The otherway works
>>>>>> fine for me since hours, but this is not what i need. :-(
>>>>>>
>>>>>> after many new ideas and posibilitys, tools and coffees,
>>>>>> finaly after 3pk. cigarettes i have this for convervting:
>>>>>>
>>>>>> PlanarImage inputCMYK_ = JAI.create
>>>>>> ("fileload",cmykdatei);
>>>>>> BufferedImage inputCMYK =
>>>>>> inputCMYK_.getAsBufferedImage();
>>>>>> ColorSpace cs = ColorSpace.getInstance
>>>>>> (ColorSpace.CS_GRAY);
>>>>>> ColorConvertOp op = new ColorConvertOp(cs, null);
>>>>>> BufferedImage bi = op.filter(inputCMYK, null);
>>>>>> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>>>>>>
>>>>>> but it fails with: Bogus input colorspace
>>>>>>
>>>>>> for rgb2cmyk i uses this class:
>>>>>>
>>>>>> --
>>>>>> /*
>>>>>> * cmyk_handles.java
>>>>>> *
>>>>>> * Created on January 13, 2007, 11:20 PM
>>>>>> *
>>>>>> * To change this template, choose Tools | Template Manager
>>>>>> * and open the template in the editor.
>>>>>> */
>>>>>>
>>>>>> package nextgen;
>>>>>>
>>>>>> import com.sun.image.codec.jpeg.*;
>>>>>> import java.awt.*;
>>>>>> import java.awt.color.*;
>>>>>> import java.awt.image.*;
>>>>>> import java.io.*;
>>>>>> import java.util.*;
>>>>>> import javax.media.jai.*;
>>>>>>
>>>>>> /**
>>>>>> *
>>>>>> * @author kriswolff
>>>>>> */
>>>>>> public class rgb2cmyk_ICC {
>>>>>>
>>>>>> private static boolean invert = false;
>>>>>> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>>>>>>
>>>>>> /** Creates a new instance of cmyk_handles */
>>>>>> public rgb2cmyk_ICC() {
>>>>>> }
>>>>>>
>>>>>> /**
>>>>>> * @param args the command line arguments
>>>>>> */
>>>>>> public static void main(String[] args) {
>>>>>> int[] bitsCMYK = {8,8,8,8};
>>>>>>
>>>>>> String cmykProfile = "/Library/Application Support/
>>>>>> Adobe/Color/Profiles/Photoshop4DefaultCMYK.icc"; // icc-
>>>>>> profile cmyk
>>>>>> String rgbProfile = "/Library/Application Support/
>>>>>> Adobe/Color/Profiles/Recommended/AppleRGB.icc";// icc-profile rgb
>>>>>>
>>>>>> // Dateiname f�r die Ausgabe
>>>>>> StringTokenizer st = new StringTokenizer(rgbdatei,".");
>>>>>> StringBuffer buffer = new StringBuffer();
>>>>>> while ( st.hasMoreTokens() ) {
>>>>>> buffer.append(st.nextToken());
>>>>>> buffer.append("_cmyk");
>>>>>> buffer.append(".jpg");
>>>>>> break;
>>>>>> }
>>>>>>
>>>>>> try {
>>>>>>
>>>>>> RenderedImage inputRGB = JAI.create
>>>>>> ("fileload",rgbdatei);
>>>>>>
>>>>>> // Create a CMYK Color Space from cmykProfile
>>>>>> ICC_Profile p = ICC_Profile.getInstance(new
>>>>>> FileInputStream(cmykProfile));
>>>>>> ColorSpace csCMYK = new ICC_ColorSpace(p);
>>>>>>
>>>>>> ColorModel colorModelCMYK = new ComponentColorModel
>>>>>> (csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TYPE_
>>>>>> BYTE);
>>>>>>
>>>>>> ImageLayout cmykLayout = new ImageLayout();
>>>>>> cmykLayout.setColorModel(colorModelCMYK);
>>>>>> RenderingHints hints = new RenderingHints
>>>>>> (JAI.KEY_IMAGE_LAYOUT,cmykLayout);
>>>>>> cmykLayout.setSampleModel
>>>>>> (colorModelCMYK.createCompatibleSampleModel(inputRGB.getWidth
>>>>>> (),inputRGB.getHeight()));
>>>>>>
>>>>>> java.awt.image.renderable.ParameterBlock pb = new
>>>>>> java.awt.image.renderable.ParameterBlock();
>>>>>> pb.addSource(inputRGB);
>>>>>> pb.add(colorModelCMYK);
>>>>>> // convert the image from rgb-colorspace to cmyk-
>>>>>> colorspace with icc
>>>>>> PlanarImage out = JAI.create
>>>>>> ("ColorConvert",pb,hints);
>>>>>>
>>>>>> // Damit photoshop die Bilddaten nicht invertiert
>>>>>> anzeigt erfolgt
>>>>>> // eine invertierung der Daten
>>>>>> pb = new java.awt.image.renderable.ParameterBlock();
>>>>>> pb.addSource(out);
>>>>>> PlanarImage out2 = JAI.create("invert",pb);
>>>>>>
>>>>>> WritableRaster cmykRaster = out2.copyData();
>>>>>> // �ffnen des Output-Streams
>>>>>> OutputStream datei = new FileOutputStream
>>>>>> (buffer.toString());
>>>>>>
>>>>>> JPEGImageEncoder encoder =
>>>>>> JPEGCodec.createJPEGEncoder(datei);
>>>>>> JPEGEncodeParam param =
>>>>>> encoder.getDefaultJPEGEncodeParam
>>>>>> (cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
>>>>>> param.setQuality(1, false);
>>>>>> encoder.encode(cmykRaster, param);
>>>>>> datei.close();
>>>>>> System.out.println("Bild erfolgreich gespeichert");
>>>>>>
>>>>>> } catch (Exception e) {
>>>>>> e.printStackTrace();
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>> --
>>>>>>
>>>>>>
>>>>>> so, i tryed to swap all cmyk to rgb and rgb to cmyk but this
>>>>>> takes me into a long journy of errors and misunderstandable
>>>>>> issues that takes me further away than i ever thougt about.
>>>>>>
>>>>>> So if anyone out there who is friendly and leads me into the
>>>>>> light? I am absolutly burned out with this image things.
>>>>>>
>>>>>>
>>>>>> Thank you very much in advanced.
>>>>>> ven.
>>>>>> -----------------------------------------------------------------
>>>>>> ----
>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>> imageio.dev.java.net
>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>> imageio.dev.java.net
>>>>>>
>>>>>
>>>>> ------------------------------------------------------------------
>>>>> ---
>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>> imageio.dev.java.net
>>>>> For additional commands, e-mail: interest-help@jai-
>>>>> imageio.dev.java.net
>>>>>
>>>>
>>>> -------------------------------------------------------------------
>>>> --
>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>> imageio.dev.java.net
>>>> For additional commands, e-mail: interest-help@jai-
>>>> imageio.dev.java.net
>>>>
>>>
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>> imageio.dev.java.net
>>> For additional commands, e-mail: interest-help@jai-
>>> imageio.dev.java.net
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>> For additional commands, e-mail: interest-help@jai-
>> imageio.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

robert engels

Try this:

http://archives.java.sun.com/cgi-bin/wa?A2=ind0409&L=java2d-
interest&P=4893

On Jan 13, 2007, at 10:56 PM, Kris Wolff wrote:

> ok.
> thanks for your help. i am a huge step further. focusing on raster...
>
> if you find an example,
> pls. share it. I will search the archive once again.
>
> ven.
>
> On Jan 14, 2007, at 5:52 AM, robert engels wrote:
>
>> I think it is probably because you are on a Mac - so you don't
>> have the native libs, which also prevents ImageIO from loading the
>> CMYK image.
>>
>> You'll have the check the archives on reading a CMYK image using
>> ImageIO and reading the Raster.
>>
>> On Jan 13, 2007, at 10:48 PM, Kris Wolff wrote:
>>
>>> Hm, and this works for you?
>>> I am getting a Unsupported Image Type while loading the CMYK image.
>>>
>>> its an CMYK/8 JPEG building with Photoshop. I tryed several CMYK-
>>> Images. No-Go. :-(
>>>
>>> --
>>> javax.imageio.IIOException: Unsupported Image Type
>>> at
>>> com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal
>>> (JPEGImageReader.java:889)
>>> at com.sun.imageio.plugins.jpeg.JPEGImageReader.read
>>> (JPEGImageReader.java:864)
>>> at javax.imageio.ImageIO.read(ImageIO.java:1400)
>>> at javax.imageio.ImageIO.read(ImageIO.java:1286)
>>> --
>>>
>>> in: BufferedImage i0 = ImageIO.read(new File("/tmp/2.JPG"));
>>>
>>>
>>> ven.
>>>
>>>
>>>
>>> On Jan 14, 2007, at 5:29 AM, robert engels wrote:
>>>
>>>>
>>>> You need to use code like
>>>>
>>>> BufferedImage i0 = ImageIO.read(new File("somefilename.jpg"));
>>>> BufferedImage i1 = new BufferedImage(i0.getWidth(),i0.getheight
>>>> (),BufferedImage.INT_ARGB);
>>>> ImageIO.write(new File("newfilename.jpg","jpg",i1);
>>>>
>>>>
>>>> On Jan 13, 2007, at 10:20 PM, Kris Wolff wrote:
>>>>
>>>>> Hi agian,
>>>>>
>>>>> I tryed this on my laptop with
>>>>> java version "1.5.0_06"
>>>>>
>>>>> But i can't get it. If it possible you send me this lines. I am
>>>>> totaly out of ideas, just need a tiny kick into the right
>>>>> direktion, get over this part CMYK->RGB...
>>>>>
>>>>> So you said: read into BuffersImage and just write into a new
>>>>> on. I get This lines:
>>>>>
>>>>> You can see 2 ways i've tried. The first gets a:
>>>>> sun.awt.image.ImageFormatException: Unsupported color
>>>>> conversion request
>>>>> The second a:
>>>>> javax.imageio.IIOException: Unsupported Image Type
>>>>>
>>>>>
>>>>> public static void main(String[] args) {
>>>>> FileOutputStream fos = null;
>>>>> try {
>>>>>
>>>>> // VARIANT I / sun.awt.image.ImageFormatException:
>>>>> Unsupported color conversion request
>>>>> ImageIcon icon = new ImageIcon("/tmp/myimage.jpg");
>>>>> Image image = icon.getImage();
>>>>> BufferedImage cmyk =
>>>>> new BufferedImage(
>>>>> image.getWidth(null),
>>>>> image.getHeight(null),
>>>>> BufferedImage.TYPE_INT_ARGB);
>>>>>
>>>>> // VARIANT II / javax.imageio.IIOException:
>>>>> Unsupported Image Type
>>>>> //BufferedImage cmyk = ImageIO.read(new File());
>>>>>
>>>>> File outfile = new File("/tmp/aaa.jpg");
>>>>> fos = new FileOutputStream(outfile);
>>>>> ImageEncoder encoder = ImageCodec.createImageEncoder
>>>>> ("JPEG",fos,null);
>>>>> PNGEncodeParam param = new PNGEncodeParam.RGB();
>>>>> encoder.setParam(param);
>>>>> encoder.encode(cmyk);
>>>>> fos.close();
>>>>> } catch (Exception e){
>>>>> e.printStackTrace();
>>>>> } finally {
>>>>> try {
>>>>> fos.close();
>>>>> } catch (Exception e){
>>>>> }
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> Thank you so much! ! !
>>>>>
>>>>> ven.
>>>>>
>>>>>
>>>>> On Jan 14, 2007, at 2:45 AM, robert engels wrote:
>>>>>
>>>>>> Using ImageIO with JDK 1.5, you can read the CMYK jpg directly
>>>>>> into a BufferedImage.
>>>>>>
>>>>>> Then once you have a BufferedImage, write the BufferedImage
>>>>>> into a new RGB BufferedImage.
>>>>>>
>>>>>> Then write the RGB BufferedImage as a JPG using ImageIO.
>>>>>>
>>>>>>
>>>>>> On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:
>>>>>>
>>>>>>> Hi folks,
>>>>>>>
>>>>>>> the whole day i spend in netbeans and the web to find a
>>>>>>> solution to convert a cmyk-jpeg into rgb. The otherway works
>>>>>>> fine for me since hours, but this is not what i need. :-(
>>>>>>>
>>>>>>> after many new ideas and posibilitys, tools and coffees,
>>>>>>> finaly after 3pk. cigarettes i have this for convervting:
>>>>>>>
>>>>>>> PlanarImage inputCMYK_ = JAI.create
>>>>>>> ("fileload",cmykdatei);
>>>>>>> BufferedImage inputCMYK =
>>>>>>> inputCMYK_.getAsBufferedImage();
>>>>>>> ColorSpace cs = ColorSpace.getInstance
>>>>>>> (ColorSpace.CS_GRAY);
>>>>>>> ColorConvertOp op = new ColorConvertOp(cs, null);
>>>>>>> BufferedImage bi = op.filter(inputCMYK, null);
>>>>>>> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>>>>>>>
>>>>>>> but it fails with: Bogus input colorspace
>>>>>>>
>>>>>>> for rgb2cmyk i uses this class:
>>>>>>>
>>>>>>> --
>>>>>>> /*
>>>>>>> * cmyk_handles.java
>>>>>>> *
>>>>>>> * Created on January 13, 2007, 11:20 PM
>>>>>>> *
>>>>>>> * To change this template, choose Tools | Template Manager
>>>>>>> * and open the template in the editor.
>>>>>>> */
>>>>>>>
>>>>>>> package nextgen;
>>>>>>>
>>>>>>> import com.sun.image.codec.jpeg.*;
>>>>>>> import java.awt.*;
>>>>>>> import java.awt.color.*;
>>>>>>> import java.awt.image.*;
>>>>>>> import java.io.*;
>>>>>>> import java.util.*;
>>>>>>> import javax.media.jai.*;
>>>>>>>
>>>>>>> /**
>>>>>>> *
>>>>>>> * @author kriswolff
>>>>>>> */
>>>>>>> public class rgb2cmyk_ICC {
>>>>>>>
>>>>>>> private static boolean invert = false;
>>>>>>> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>>>>>>>
>>>>>>> /** Creates a new instance of cmyk_handles */
>>>>>>> public rgb2cmyk_ICC() {
>>>>>>> }
>>>>>>>
>>>>>>> /**
>>>>>>> * @param args the command line arguments
>>>>>>> */
>>>>>>> public static void main(String[] args) {
>>>>>>> int[] bitsCMYK = {8,8,8,8};
>>>>>>>
>>>>>>> String cmykProfile = "/Library/Application Support/
>>>>>>> Adobe/Color/Profiles/Photoshop4DefaultCMYK.icc"; // icc-
>>>>>>> profile cmyk
>>>>>>> String rgbProfile = "/Library/Application Support/
>>>>>>> Adobe/Color/Profiles/Recommended/AppleRGB.icc";// icc-profile
>>>>>>> rgb
>>>>>>>
>>>>>>> // Dateiname f�r die Ausgabe
>>>>>>> StringTokenizer st = new StringTokenizer(rgbdatei,".");
>>>>>>> StringBuffer buffer = new StringBuffer();
>>>>>>> while ( st.hasMoreTokens() ) {
>>>>>>> buffer.append(st.nextToken());
>>>>>>> buffer.append("_cmyk");
>>>>>>> buffer.append(".jpg");
>>>>>>> break;
>>>>>>> }
>>>>>>>
>>>>>>> try {
>>>>>>>
>>>>>>> RenderedImage inputRGB = JAI.create
>>>>>>> ("fileload",rgbdatei);
>>>>>>>
>>>>>>> // Create a CMYK Color Space from cmykProfile
>>>>>>> ICC_Profile p = ICC_Profile.getInstance(new
>>>>>>> FileInputStream(cmykProfile));
>>>>>>> ColorSpace csCMYK = new ICC_ColorSpace(p);
>>>>>>>
>>>>>>> ColorModel colorModelCMYK = new
>>>>>>> ComponentColorModel
>>>>>>> (csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TYPE
>>>>>>> _BYTE);
>>>>>>>
>>>>>>> ImageLayout cmykLayout = new ImageLayout();
>>>>>>> cmykLayout.setColorModel(colorModelCMYK);
>>>>>>> RenderingHints hints = new RenderingHints
>>>>>>> (JAI.KEY_IMAGE_LAYOUT,cmykLayout);
>>>>>>> cmykLayout.setSampleModel
>>>>>>> (colorModelCMYK.createCompatibleSampleModel(inputRGB.getWidth
>>>>>>> (),inputRGB.getHeight()));
>>>>>>>
>>>>>>> java.awt.image.renderable.ParameterBlock pb = new
>>>>>>> java.awt.image.renderable.ParameterBlock();
>>>>>>> pb.addSource(inputRGB);
>>>>>>> pb.add(colorModelCMYK);
>>>>>>> // convert the image from rgb-colorspace to cmyk-
>>>>>>> colorspace with icc
>>>>>>> PlanarImage out = JAI.create
>>>>>>> ("ColorConvert",pb,hints);
>>>>>>>
>>>>>>> // Damit photoshop die Bilddaten nicht invertiert
>>>>>>> anzeigt erfolgt
>>>>>>> // eine invertierung der Daten
>>>>>>> pb = new java.awt.image.renderable.ParameterBlock();
>>>>>>> pb.addSource(out);
>>>>>>> PlanarImage out2 = JAI.create("invert",pb);
>>>>>>>
>>>>>>> WritableRaster cmykRaster = out2.copyData();
>>>>>>> // �ffnen des Output-Streams
>>>>>>> OutputStream datei = new FileOutputStream
>>>>>>> (buffer.toString());
>>>>>>>
>>>>>>> JPEGImageEncoder encoder =
>>>>>>> JPEGCodec.createJPEGEncoder(datei);
>>>>>>> JPEGEncodeParam param =
>>>>>>> encoder.getDefaultJPEGEncodeParam
>>>>>>> (cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
>>>>>>> param.setQuality(1, false);
>>>>>>> encoder.encode(cmykRaster, param);
>>>>>>> datei.close();
>>>>>>> System.out.println("Bild erfolgreich gespeichert");
>>>>>>>
>>>>>>> } catch (Exception e) {
>>>>>>> e.printStackTrace();
>>>>>>> }
>>>>>>> }
>>>>>>> }
>>>>>>> --
>>>>>>>
>>>>>>>
>>>>>>> so, i tryed to swap all cmyk to rgb and rgb to cmyk but this
>>>>>>> takes me into a long journy of errors and misunderstandable
>>>>>>> issues that takes me further away than i ever thougt about.
>>>>>>>
>>>>>>> So if anyone out there who is friendly and leads me into the
>>>>>>> light? I am absolutly burned out with this image things.
>>>>>>>
>>>>>>>
>>>>>>> Thank you very much in advanced.
>>>>>>> ven.
>>>>>>> ----------------------------------------------------------------
>>>>>>> -----
>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>>> imageio.dev.java.net
>>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>>> imageio.dev.java.net
>>>>>>>
>>>>>>
>>>>>> -----------------------------------------------------------------
>>>>>> ----
>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>> imageio.dev.java.net
>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>> imageio.dev.java.net
>>>>>>
>>>>>
>>>>> ------------------------------------------------------------------
>>>>> ---
>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>> imageio.dev.java.net
>>>>> For additional commands, e-mail: interest-help@jai-
>>>>> imageio.dev.java.net
>>>>>
>>>>
>>>> -------------------------------------------------------------------
>>>> --
>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>> imageio.dev.java.net
>>>> For additional commands, e-mail: interest-help@jai-
>>>> imageio.dev.java.net
>>>>
>>>
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>> imageio.dev.java.net
>>> For additional commands, e-mail: interest-help@jai-
>>> imageio.dev.java.net
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>> For additional commands, e-mail: interest-help@jai-
>> imageio.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

[att1.html]

Kris Wolff

I spend a while in the code to understand the transforming part.
I got it. But i can not render a image with this code either.

The IIOMeterdate failed with a: ICC APP2 encountered without prior
JFIF! exception. So i think this is just a mac thing, too - found
something on the net. I checkd for what we need the metadate and
found out, that this is needed to find out the "transform" value.
I checked the dtd for app14Adobe ans I noiced that transform can only
be 0, 1 or 2.

Easy to test by replacing the metadatapart.

I tried with all of possible transform values and getting always the
same result: a image with a single color, still cmyk with C:100% M:
50% Y:50% K100%
BUT: i resolved it. I take your code form the other test:
BufferedImage i0 = j.readImage(new File("/tmp/2.JPG"));
BufferedImage i1 = new BufferedImage(i0.getWidth(),i0.getHeight(),
BufferedImage.TYPE_INT_ARGB);
ImageIO.write(i1, "jpg", new File("/tmp/a2.jpg"));

and replaced it with:
BufferedImage i0 = j.readImage(new File("/tmp/2.JPG"));
ImageIO.write(i0, "jpg", new File("/tmp/a2.jpg"));

And than .. transform=2 works !! 0 and 1 changing colors.

So lets take a look the the metadata. I found a api called
"com.drew.metadata.*;" that works for me, but do not give the app14
node back.
Do you know any other solution to get the metadata tree?

So second question: i run a method to the rgb to find out the density:
--
int density = 0;
int densityUnit = JPEGDecodeParam.DENSITY_UNIT_DOTS_INCH;
FileInputStream fis = new FileInputStream( "/tmp/a2.jpg" );
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder
( fis );
JPEGDecodeParam decodeParam = decoder.getJPEGDecodeParam();
if ( decodeParam.getMarker
( JPEGDecodeParam.APP0_MARKER ) ) {
density = decodeParam.getXDensity();
densityUnit = decodeParam.getDensityUnit();
}
fis.close();
System.out.println("Density "+ density +" "+ densityUnit);
--

I run this on the fresh generated image and get a desity of 1, i open
this file in Phooshop, and save it back to the same file. run the
desity-method again and get a resolution of 72
by the way: the original has a resolution of 300dpi.

Any suggestions?

On Jan 14, 2007, at 6:05 AM, robert engels wrote:

> Try this:
>
> http://archives.java.sun.com/cgi-bin/wa?A2=ind0409&L=java2d-
> interest&P=4893
>
> On Jan 13, 2007, at 10:56 PM, Kris Wolff wrote:
>
>> ok.
>> thanks for your help. i am a huge step further. focusing on raster...
>>
>> if you find an example,
>> pls. share it. I will search the archive once again.
>>
>> ven.
>>
>> On Jan 14, 2007, at 5:52 AM, robert engels wrote:
>>
>>> I think it is probably because you are on a Mac - so you don't
>>> have the native libs, which also prevents ImageIO from loading
>>> the CMYK image.
>>>
>>> You'll have the check the archives on reading a CMYK image using
>>> ImageIO and reading the Raster.
>>>
>>> On Jan 13, 2007, at 10:48 PM, Kris Wolff wrote:
>>>
>>>> Hm, and this works for you?
>>>> I am getting a Unsupported Image Type while loading the CMYK image.
>>>>
>>>> its an CMYK/8 JPEG building with Photoshop. I tryed several CMYK-
>>>> Images. No-Go. :-(
>>>>
>>>> --
>>>> javax.imageio.IIOException: Unsupported Image Type
>>>> at
>>>> com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal
>>>> (JPEGImageReader.java:889)
>>>> at com.sun.imageio.plugins.jpeg.JPEGImageReader.read
>>>> (JPEGImageReader.java:864)
>>>> at javax.imageio.ImageIO.read(ImageIO.java:1400)
>>>> at javax.imageio.ImageIO.read(ImageIO.java:1286)
>>>> --
>>>>
>>>> in: BufferedImage i0 = ImageIO.read(new File("/tmp/2.JPG"));
>>>>
>>>>
>>>> ven.
>>>>
>>>>
>>>>
>>>> On Jan 14, 2007, at 5:29 AM, robert engels wrote:
>>>>
>>>>>
>>>>> You need to use code like
>>>>>
>>>>> BufferedImage i0 = ImageIO.read(new File("somefilename.jpg"));
>>>>> BufferedImage i1 = new BufferedImage(i0.getWidth(),i0.getheight
>>>>> (),BufferedImage.INT_ARGB);
>>>>> ImageIO.write(new File("newfilename.jpg","jpg",i1);
>>>>>
>>>>>
>>>>> On Jan 13, 2007, at 10:20 PM, Kris Wolff wrote:
>>>>>
>>>>>> Hi agian,
>>>>>>
>>>>>> I tryed this on my laptop with
>>>>>> java version "1.5.0_06"
>>>>>>
>>>>>> But i can't get it. If it possible you send me this lines. I
>>>>>> am totaly out of ideas, just need a tiny kick into the right
>>>>>> direktion, get over this part CMYK->RGB...
>>>>>>
>>>>>> So you said: read into BuffersImage and just write into a new
>>>>>> on. I get This lines:
>>>>>>
>>>>>> You can see 2 ways i've tried. The first gets a:
>>>>>> sun.awt.image.ImageFormatException: Unsupported color
>>>>>> conversion request
>>>>>> The second a:
>>>>>> javax.imageio.IIOException: Unsupported Image Type
>>>>>>
>>>>>>
>>>>>> public static void main(String[] args) {
>>>>>> FileOutputStream fos = null;
>>>>>> try {
>>>>>>
>>>>>> // VARIANT I / sun.awt.image.ImageFormatException:
>>>>>> Unsupported color conversion request
>>>>>> ImageIcon icon = new ImageIcon("/tmp/myimage.jpg");
>>>>>> Image image = icon.getImage();
>>>>>> BufferedImage cmyk =
>>>>>> new BufferedImage(
>>>>>> image.getWidth(null),
>>>>>> image.getHeight(null),
>>>>>> BufferedImage.TYPE_INT_ARGB);
>>>>>>
>>>>>> // VARIANT II / javax.imageio.IIOException:
>>>>>> Unsupported Image Type
>>>>>> //BufferedImage cmyk = ImageIO.read(new File());
>>>>>>
>>>>>> File outfile = new File("/tmp/aaa.jpg");
>>>>>> fos = new FileOutputStream(outfile);
>>>>>> ImageEncoder encoder =
>>>>>> ImageCodec.createImageEncoder("JPEG",fos,null);
>>>>>> PNGEncodeParam param = new PNGEncodeParam.RGB();
>>>>>> encoder.setParam(param);
>>>>>> encoder.encode(cmyk);
>>>>>> fos.close();
>>>>>> } catch (Exception e){
>>>>>> e.printStackTrace();
>>>>>> } finally {
>>>>>> try {
>>>>>> fos.close();
>>>>>> } catch (Exception e){
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thank you so much! ! !
>>>>>>
>>>>>> ven.
>>>>>>
>>>>>>
>>>>>> On Jan 14, 2007, at 2:45 AM, robert engels wrote:
>>>>>>
>>>>>>> Using ImageIO with JDK 1.5, you can read the CMYK jpg
>>>>>>> directly into a BufferedImage.
>>>>>>>
>>>>>>> Then once you have a BufferedImage, write the BufferedImage
>>>>>>> into a new RGB BufferedImage.
>>>>>>>
>>>>>>> Then write the RGB BufferedImage as a JPG using ImageIO.
>>>>>>>
>>>>>>>
>>>>>>> On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:
>>>>>>>
>>>>>>>> Hi folks,
>>>>>>>>
>>>>>>>> the whole day i spend in netbeans and the web to find a
>>>>>>>> solution to convert a cmyk-jpeg into rgb. The otherway works
>>>>>>>> fine for me since hours, but this is not what i need. :-(
>>>>>>>>
>>>>>>>> after many new ideas and posibilitys, tools and coffees,
>>>>>>>> finaly after 3pk. cigarettes i have this for convervting:
>>>>>>>>
>>>>>>>> PlanarImage inputCMYK_ = JAI.create
>>>>>>>> ("fileload",cmykdatei);
>>>>>>>> BufferedImage inputCMYK =
>>>>>>>> inputCMYK_.getAsBufferedImage();
>>>>>>>> ColorSpace cs = ColorSpace.getInstance
>>>>>>>> (ColorSpace.CS_GRAY);
>>>>>>>> ColorConvertOp op = new ColorConvertOp(cs, null);
>>>>>>>> BufferedImage bi = op.filter(inputCMYK, null);
>>>>>>>> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>>>>>>>>
>>>>>>>> but it fails with: Bogus input colorspace
>>>>>>>>
>>>>>>>> for rgb2cmyk i uses this class:
>>>>>>>>
>>>>>>>> --
>>>>>>>> /*
>>>>>>>> * cmyk_handles.java
>>>>>>>> *
>>>>>>>> * Created on January 13, 2007, 11:20 PM
>>>>>>>> *
>>>>>>>> * To change this template, choose Tools | Template Manager
>>>>>>>> * and open the template in the editor.
>>>>>>>> */
>>>>>>>>
>>>>>>>> package nextgen;
>>>>>>>>
>>>>>>>> import com.sun.image.codec.jpeg.*;
>>>>>>>> import java.awt.*;
>>>>>>>> import java.awt.color.*;
>>>>>>>> import java.awt.image.*;
>>>>>>>> import java.io.*;
>>>>>>>> import java.util.*;
>>>>>>>> import javax.media.jai.*;
>>>>>>>>
>>>>>>>> /**
>>>>>>>> *
>>>>>>>> * @author kriswolff
>>>>>>>> */
>>>>>>>> public class rgb2cmyk_ICC {
>>>>>>>>
>>>>>>>> private static boolean invert = false;
>>>>>>>> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>>>>>>>>
>>>>>>>> /** Creates a new instance of cmyk_handles */
>>>>>>>> public rgb2cmyk_ICC() {
>>>>>>>> }
>>>>>>>>
>>>>>>>> /**
>>>>>>>> * @param args the command line arguments
>>>>>>>> */
>>>>>>>> public static void main(String[] args) {
>>>>>>>> int[] bitsCMYK = {8,8,8,8};
>>>>>>>>
>>>>>>>> String cmykProfile = "/Library/Application Support/
>>>>>>>> Adobe/Color/Profiles/Photoshop4DefaultCMYK.icc"; // icc-
>>>>>>>> profile cmyk
>>>>>>>> String rgbProfile = "/Library/Application Support/
>>>>>>>> Adobe/Color/Profiles/Recommended/AppleRGB.icc";// icc-
>>>>>>>> profile rgb
>>>>>>>>
>>>>>>>> // Dateiname f�r die Ausgabe
>>>>>>>> StringTokenizer st = new StringTokenizer(rgbdatei,".");
>>>>>>>> StringBuffer buffer = new StringBuffer();
>>>>>>>> while ( st.hasMoreTokens() ) {
>>>>>>>> buffer.append(st.nextToken());
>>>>>>>> buffer.append("_cmyk");
>>>>>>>> buffer.append(".jpg");
>>>>>>>> break;
>>>>>>>> }
>>>>>>>>
>>>>>>>> try {
>>>>>>>>
>>>>>>>> RenderedImage inputRGB = JAI.create
>>>>>>>> ("fileload",rgbdatei);
>>>>>>>>
>>>>>>>> // Create a CMYK Color Space from cmykProfile
>>>>>>>> ICC_Profile p = ICC_Profile.getInstance(new
>>>>>>>> FileInputStream(cmykProfile));
>>>>>>>> ColorSpace csCMYK = new ICC_ColorSpace(p);
>>>>>>>>
>>>>>>>> ColorModel colorModelCMYK = new
>>>>>>>> ComponentColorModel
>>>>>>>> (csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TYP
>>>>>>>> E_BYTE);
>>>>>>>>
>>>>>>>> ImageLayout cmykLayout = new ImageLayout();
>>>>>>>> cmykLayout.setColorModel(colorModelCMYK);
>>>>>>>> RenderingHints hints = new RenderingHints
>>>>>>>> (JAI.KEY_IMAGE_LAYOUT,cmykLayout);
>>>>>>>> cmykLayout.setSampleModel
>>>>>>>> (colorModelCMYK.createCompatibleSampleModel(inputRGB.getWidth
>>>>>>>> (),inputRGB.getHeight()));
>>>>>>>>
>>>>>>>> java.awt.image.renderable.ParameterBlock pb =
>>>>>>>> new java.awt.image.renderable.ParameterBlock();
>>>>>>>> pb.addSource(inputRGB);
>>>>>>>> pb.add(colorModelCMYK);
>>>>>>>> // convert the image from rgb-colorspace to cmyk-
>>>>>>>> colorspace with icc
>>>>>>>> PlanarImage out = JAI.create
>>>>>>>> ("ColorConvert",pb,hints);
>>>>>>>>
>>>>>>>> // Damit photoshop die Bilddaten nicht
>>>>>>>> invertiert anzeigt erfolgt
>>>>>>>> // eine invertierung der Daten
>>>>>>>> pb = new java.awt.image.renderable.ParameterBlock
>>>>>>>> ();
>>>>>>>> pb.addSource(out);
>>>>>>>> PlanarImage out2 = JAI.create("invert",pb);
>>>>>>>>
>>>>>>>> WritableRaster cmykRaster = out2.copyData();
>>>>>>>> // �ffnen des Output-Streams
>>>>>>>> OutputStream datei = new FileOutputStream
>>>>>>>> (buffer.toString());
>>>>>>>>
>>>>>>>> JPEGImageEncoder encoder =
>>>>>>>> JPEGCodec.createJPEGEncoder(datei);
>>>>>>>> JPEGEncodeParam param =
>>>>>>>> encoder.getDefaultJPEGEncodeParam
>>>>>>>> (cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
>>>>>>>> param.setQuality(1, false);
>>>>>>>> encoder.encode(cmykRaster, param);
>>>>>>>> datei.close();
>>>>>>>> System.out.println("Bild erfolgreich gespeichert");
>>>>>>>>
>>>>>>>> } catch (Exception e) {
>>>>>>>> e.printStackTrace();
>>>>>>>> }
>>>>>>>> }
>>>>>>>> }
>>>>>>>> --
>>>>>>>>
>>>>>>>>
>>>>>>>> so, i tryed to swap all cmyk to rgb and rgb to cmyk but this
>>>>>>>> takes me into a long journy of errors and misunderstandable
>>>>>>>> issues that takes me further away than i ever thougt about.
>>>>>>>>
>>>>>>>> So if anyone out there who is friendly and leads me into the
>>>>>>>> light? I am absolutly burned out with this image things.
>>>>>>>>
>>>>>>>>
>>>>>>>> Thank you very much in advanced.
>>>>>>>> ven.
>>>>>>>> ---------------------------------------------------------------
>>>>>>>> ------
>>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>>>> imageio.dev.java.net
>>>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>>>> imageio.dev.java.net
>>>>>>>>
>>>>>>>
>>>>>>> ----------------------------------------------------------------
>>>>>>> -----
>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>>> imageio.dev.java.net
>>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>>> imageio.dev.java.net
>>>>>>>
>>>>>>
>>>>>> -----------------------------------------------------------------
>>>>>> ----
>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>> imageio.dev.java.net
>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>> imageio.dev.java.net
>>>>>>
>>>>>
>>>>> ------------------------------------------------------------------
>>>>> ---
>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>> imageio.dev.java.net
>>>>> For additional commands, e-mail: interest-help@jai-
>>>>> imageio.dev.java.net
>>>>>
>>>>
>>>> -------------------------------------------------------------------
>>>> --
>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>> imageio.dev.java.net
>>>> For additional commands, e-mail: interest-help@jai-
>>>> imageio.dev.java.net
>>>>
>>>
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>> imageio.dev.java.net
>>> For additional commands, e-mail: interest-help@jai-
>>> imageio.dev.java.net
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>> For additional commands, e-mail: interest-help@jai-
>> imageio.dev.java.net
>>
>

[att1.html]

robert engels

Sorry, but you have consumed all of my resources on this. The code I
pointed you to last should work. I suggest more reading of the archives.

Good luck.

On Jan 14, 2007, at 6:44 AM, Kris Wolff wrote:

> I spend a while in the code to understand the transforming part.
> I got it. But i can not render a image with this code either.
>
> The IIOMeterdate failed with a: ICC APP2 encountered without prior
> JFIF! exception. So i think this is just a mac thing, too - found
> something on the net. I checkd for what we need the metadate and
> found out, that this is needed to find out the "transform" value.
> I checked the dtd for app14Adobe ans I noiced that transform can
> only be 0, 1 or 2.
>
> Easy to test by replacing the metadatapart.
>
> I tried with all of possible transform values and getting always
> the same result: a image with a single color, still cmyk with C:
> 100% M:50% Y:50% K100%
> BUT: i resolved it. I take your code form the other test:
> BufferedImage i0 = j.readImage(new File("/tmp/2.JPG"));
> BufferedImage i1 = new BufferedImage(i0.getWidth(),i0.getHeight(),
> BufferedImage.TYPE_INT_ARGB);
> ImageIO.write(i1, "jpg", new File("/tmp/a2.jpg"));
>
> and replaced it with:
> BufferedImage i0 = j.readImage(new File("/tmp/2.JPG"));
> ImageIO.write(i0, "jpg", new File("/tmp/a2.jpg"));
>
> And than .. transform=2 works !! 0 and 1 changing colors.
>
> So lets take a look the the metadata. I found a api called
> "com.drew.metadata.*;" that works for me, but do not give the app14
> node back.
> Do you know any other solution to get the metadata tree?
>
> So second question: i run a method to the rgb to find out the density:
> --
> int density = 0;
> int densityUnit = JPEGDecodeParam.DENSITY_UNIT_DOTS_INCH;
> FileInputStream fis = new FileInputStream( "/tmp/
> a2.jpg" );
> JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder
> ( fis );
> JPEGDecodeParam decodeParam = decoder.getJPEGDecodeParam
> ();
> if ( decodeParam.getMarker
> ( JPEGDecodeParam.APP0_MARKER ) ) {
> density = decodeParam.getXDensity();
> densityUnit = decodeParam.getDensityUnit();
> }
> fis.close();
> System.out.println("Density "+ density +" "+ densityUnit);
> --
>
> I run this on the fresh generated image and get a desity of 1, i
> open this file in Phooshop, and save it back to the same file. run
> the desity-method again and get a resolution of 72
> by the way: the original has a resolution of 300dpi.
>
>
> Any suggestions?
>
>
> On Jan 14, 2007, at 6:05 AM, robert engels wrote:
>
>> Try this:
>>
>> http://archives.java.sun.com/cgi-bin/wa?A2=ind0409&L=java2d-
>> interest&P=4893
>>
>> On Jan 13, 2007, at 10:56 PM, Kris Wolff wrote:
>>
>>> ok.
>>> thanks for your help. i am a huge step further. focusing on
>>> raster...
>>>
>>> if you find an example,
>>> pls. share it. I will search the archive once again.
>>>
>>> ven.
>>>
>>> On Jan 14, 2007, at 5:52 AM, robert engels wrote:
>>>
>>>> I think it is probably because you are on a Mac - so you don't
>>>> have the native libs, which also prevents ImageIO from loading
>>>> the CMYK image.
>>>>
>>>> You'll have the check the archives on reading a CMYK image using
>>>> ImageIO and reading the Raster.
>>>>
>>>> On Jan 13, 2007, at 10:48 PM, Kris Wolff wrote:
>>>>
>>>>> Hm, and this works for you?
>>>>> I am getting a Unsupported Image Type while loading the CMYK
>>>>> image.
>>>>>
>>>>> its an CMYK/8 JPEG building with Photoshop. I tryed several
>>>>> CMYK-Images. No-Go. :-(
>>>>>
>>>>> --
>>>>> javax.imageio.IIOException: Unsupported Image Type
>>>>> at
>>>>> com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal
>>>>> (JPEGImageReader.java:889)
>>>>> at com.sun.imageio.plugins.jpeg.JPEGImageReader.read
>>>>> (JPEGImageReader.java:864)
>>>>> at javax.imageio.ImageIO.read(ImageIO.java:1400)
>>>>> at javax.imageio.ImageIO.read(ImageIO.java:1286)
>>>>> --
>>>>>
>>>>> in: BufferedImage i0 = ImageIO.read(new File("/tmp/2.JPG"));
>>>>>
>>>>>
>>>>> ven.
>>>>>
>>>>>
>>>>>
>>>>> On Jan 14, 2007, at 5:29 AM, robert engels wrote:
>>>>>
>>>>>>
>>>>>> You need to use code like
>>>>>>
>>>>>> BufferedImage i0 = ImageIO.read(new File("somefilename.jpg"));
>>>>>> BufferedImage i1 = new BufferedImage(i0.getWidth(),i0.getheight
>>>>>> (),BufferedImage.INT_ARGB);
>>>>>> ImageIO.write(new File("newfilename.jpg","jpg",i1);
>>>>>>
>>>>>>
>>>>>> On Jan 13, 2007, at 10:20 PM, Kris Wolff wrote:
>>>>>>
>>>>>>> Hi agian,
>>>>>>>
>>>>>>> I tryed this on my laptop with
>>>>>>> java version "1.5.0_06"
>>>>>>>
>>>>>>> But i can't get it. If it possible you send me this lines. I
>>>>>>> am totaly out of ideas, just need a tiny kick into the right
>>>>>>> direktion, get over this part CMYK->RGB...
>>>>>>>
>>>>>>> So you said: read into BuffersImage and just write into a new
>>>>>>> on. I get This lines:
>>>>>>>
>>>>>>> You can see 2 ways i've tried. The first gets a:
>>>>>>> sun.awt.image.ImageFormatException: Unsupported color
>>>>>>> conversion request
>>>>>>> The second a:
>>>>>>> javax.imageio.IIOException: Unsupported Image Type
>>>>>>>
>>>>>>>
>>>>>>> public static void main(String[] args) {
>>>>>>> FileOutputStream fos = null;
>>>>>>> try {
>>>>>>>
>>>>>>> // VARIANT I /
>>>>>>> sun.awt.image.ImageFormatException: Unsupported color
>>>>>>> conversion request
>>>>>>> ImageIcon icon = new ImageIcon("/tmp/myimage.jpg");
>>>>>>> Image image = icon.getImage();
>>>>>>> BufferedImage cmyk =
>>>>>>> new BufferedImage(
>>>>>>> image.getWidth(null),
>>>>>>> image.getHeight(null),
>>>>>>> BufferedImage.TYPE_INT_ARGB);
>>>>>>>
>>>>>>> // VARIANT II / javax.imageio.IIOException:
>>>>>>> Unsupported Image Type
>>>>>>> //BufferedImage cmyk = ImageIO.read(new File());
>>>>>>>
>>>>>>> File outfile = new File("/tmp/aaa.jpg");
>>>>>>> fos = new FileOutputStream(outfile);
>>>>>>> ImageEncoder encoder =
>>>>>>> ImageCodec.createImageEncoder("JPEG",fos,null);
>>>>>>> PNGEncodeParam param = new PNGEncodeParam.RGB();
>>>>>>> encoder.setParam(param);
>>>>>>> encoder.encode(cmyk);
>>>>>>> fos.close();
>>>>>>> } catch (Exception e){
>>>>>>> e.printStackTrace();
>>>>>>> } finally {
>>>>>>> try {
>>>>>>> fos.close();
>>>>>>> } catch (Exception e){
>>>>>>> }
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Thank you so much! ! !
>>>>>>>
>>>>>>> ven.
>>>>>>>
>>>>>>>
>>>>>>> On Jan 14, 2007, at 2:45 AM, robert engels wrote:
>>>>>>>
>>>>>>>> Using ImageIO with JDK 1.5, you can read the CMYK jpg
>>>>>>>> directly into a BufferedImage.
>>>>>>>>
>>>>>>>> Then once you have a BufferedImage, write the BufferedImage
>>>>>>>> into a new RGB BufferedImage.
>>>>>>>>
>>>>>>>> Then write the RGB BufferedImage as a JPG using ImageIO.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:
>>>>>>>>
>>>>>>>>> Hi folks,
>>>>>>>>>
>>>>>>>>> the whole day i spend in netbeans and the web to find a
>>>>>>>>> solution to convert a cmyk-jpeg into rgb. The otherway
>>>>>>>>> works fine for me since hours, but this is not what i
>>>>>>>>> need. :-(
>>>>>>>>>
>>>>>>>>> after many new ideas and posibilitys, tools and coffees,
>>>>>>>>> finaly after 3pk. cigarettes i have this for convervting:
>>>>>>>>>
>>>>>>>>> PlanarImage inputCMYK_ = JAI.create
>>>>>>>>> ("fileload",cmykdatei);
>>>>>>>>> BufferedImage inputCMYK =
>>>>>>>>> inputCMYK_.getAsBufferedImage();
>>>>>>>>> ColorSpace cs = ColorSpace.getInstance
>>>>>>>>> (ColorSpace.CS_GRAY);
>>>>>>>>> ColorConvertOp op = new ColorConvertOp(cs, null);
>>>>>>>>> BufferedImage bi = op.filter(inputCMYK, null);
>>>>>>>>> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>>>>>>>>>
>>>>>>>>> but it fails with: Bogus input colorspace
>>>>>>>>>
>>>>>>>>> for rgb2cmyk i uses this class:
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> /*
>>>>>>>>> * cmyk_handles.java
>>>>>>>>> *
>>>>>>>>> * Created on January 13, 2007, 11:20 PM
>>>>>>>>> *
>>>>>>>>> * To change this template, choose Tools | Template Manager
>>>>>>>>> * and open the template in the editor.
>>>>>>>>> */
>>>>>>>>>
>>>>>>>>> package nextgen;
>>>>>>>>>
>>>>>>>>> import com.sun.image.codec.jpeg.*;
>>>>>>>>> import java.awt.*;
>>>>>>>>> import java.awt.color.*;
>>>>>>>>> import java.awt.image.*;
>>>>>>>>> import java.io.*;
>>>>>>>>> import java.util.*;
>>>>>>>>> import javax.media.jai.*;
>>>>>>>>>
>>>>>>>>> /**
>>>>>>>>> *
>>>>>>>>> * @author kriswolff
>>>>>>>>> */
>>>>>>>>> public class rgb2cmyk_ICC {
>>>>>>>>>
>>>>>>>>> private static boolean invert = false;
>>>>>>>>> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>>>>>>>>>
>>>>>>>>> /** Creates a new instance of cmyk_handles */
>>>>>>>>> public rgb2cmyk_ICC() {
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> /**
>>>>>>>>> * @param args the command line arguments
>>>>>>>>> */
>>>>>>>>> public static void main(String[] args) {
>>>>>>>>> int[] bitsCMYK = {8,8,8,8};
>>>>>>>>>
>>>>>>>>> String cmykProfile = "/Library/Application Support/
>>>>>>>>> Adobe/Color/Profiles/Photoshop4DefaultCMYK.icc"; // icc-
>>>>>>>>> profile cmyk
>>>>>>>>> String rgbProfile = "/Library/Application Support/
>>>>>>>>> Adobe/Color/Profiles/Recommended/AppleRGB.icc";// icc-
>>>>>>>>> profile rgb
>>>>>>>>>
>>>>>>>>> // Dateiname f�r die Ausgabe
>>>>>>>>> StringTokenizer st = new StringTokenizer
>>>>>>>>> (rgbdatei,".");
>>>>>>>>> StringBuffer buffer = new StringBuffer();
>>>>>>>>> while ( st.hasMoreTokens() ) {
>>>>>>>>> buffer.append(st.nextToken());
>>>>>>>>> buffer.append("_cmyk");
>>>>>>>>> buffer.append(".jpg");
>>>>>>>>> break;
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> try {
>>>>>>>>>
>>>>>>>>> RenderedImage inputRGB = JAI.create
>>>>>>>>> ("fileload",rgbdatei);
>>>>>>>>>
>>>>>>>>> // Create a CMYK Color Space from cmykProfile
>>>>>>>>> ICC_Profile p = ICC_Profile.getInstance(new
>>>>>>>>> FileInputStream(cmykProfile));
>>>>>>>>> ColorSpace csCMYK = new ICC_ColorSpace(p);
>>>>>>>>>
>>>>>>>>> ColorModel colorModelCMYK = new
>>>>>>>>> ComponentColorModel
>>>>>>>>> (csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TY
>>>>>>>>> PE_BYTE);
>>>>>>>>>
>>>>>>>>> ImageLayout cmykLayout = new ImageLayout();
>>>>>>>>> cmykLayout.setColorModel(colorModelCMYK);
>>>>>>>>> RenderingHints hints = new RenderingHints
>>>>>>>>> (JAI.KEY_IMAGE_LAYOUT,cmykLayout);
>>>>>>>>> cmykLayout.setSampleModel
>>>>>>>>> (colorModelCMYK.createCompatibleSampleModel
>>>>>>>>> (inputRGB.getWidth(),inputRGB.getHeight()));
>>>>>>>>>
>>>>>>>>> java.awt.image.renderable.ParameterBlock pb =
>>>>>>>>> new java.awt.image.renderable.ParameterBlock();
>>>>>>>>> pb.addSource(inputRGB);
>>>>>>>>> pb.add(colorModelCMYK);
>>>>>>>>> // convert the image from rgb-colorspace to
>>>>>>>>> cmyk-colorspace with icc
>>>>>>>>> PlanarImage out = JAI.create
>>>>>>>>> ("ColorConvert",pb,hints);
>>>>>>>>>
>>>>>>>>> // Damit photoshop die Bilddaten nicht
>>>>>>>>> invertiert anzeigt erfolgt
>>>>>>>>> // eine invertierung der Daten
>>>>>>>>> pb = new
>>>>>>>>> java.awt.image.renderable.ParameterBlock();
>>>>>>>>> pb.addSource(out);
>>>>>>>>> PlanarImage out2 = JAI.create("invert",pb);
>>>>>>>>>
>>>>>>>>> WritableRaster cmykRaster = out2.copyData();
>>>>>>>>> // �ffnen des Output-Streams
>>>>>>>>> OutputStream datei = new FileOutputStream
>>>>>>>>> (buffer.toString());
>>>>>>>>>
>>>>>>>>> JPEGImageEncoder encoder =
>>>>>>>>> JPEGCodec.createJPEGEncoder(datei);
>>>>>>>>> JPEGEncodeParam param =
>>>>>>>>> encoder.getDefaultJPEGEncodeParam
>>>>>>>>> (cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
>>>>>>>>> param.setQuality(1, false);
>>>>>>>>> encoder.encode(cmykRaster, param);
>>>>>>>>> datei.close();
>>>>>>>>> System.out.println("Bild erfolgreich
>>>>>>>>> gespeichert");
>>>>>>>>>
>>>>>>>>> } catch (Exception e) {
>>>>>>>>> e.printStackTrace();
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> so, i tryed to swap all cmyk to rgb and rgb to cmyk but
>>>>>>>>> this takes me into a long journy of errors and
>>>>>>>>> misunderstandable issues that takes me further away than i
>>>>>>>>> ever thougt about.
>>>>>>>>>
>>>>>>>>> So if anyone out there who is friendly and leads me into
>>>>>>>>> the light? I am absolutly burned out with this image things.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thank you very much in advanced.
>>>>>>>>> ven.
>>>>>>>>> --------------------------------------------------------------
>>>>>>>>> -------
>>>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>>>>> imageio.dev.java.net
>>>>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>>>>> imageio.dev.java.net
>>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------
>>>>>>>> ------
>>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>>>> imageio.dev.java.net
>>>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>>>> imageio.dev.java.net
>>>>>>>>
>>>>>>>
>>>>>>> ----------------------------------------------------------------
>>>>>>> -----
>>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>>> imageio.dev.java.net
>>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>>> imageio.dev.java.net
>>>>>>>
>>>>>>
>>>>>> -----------------------------------------------------------------
>>>>>> ----
>>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>>> imageio.dev.java.net
>>>>>> For additional commands, e-mail: interest-help@jai-
>>>>>> imageio.dev.java.net
>>>>>>
>>>>>
>>>>> ------------------------------------------------------------------
>>>>> ---
>>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>>> imageio.dev.java.net
>>>>> For additional commands, e-mail: interest-help@jai-
>>>>> imageio.dev.java.net
>>>>>
>>>>
>>>> -------------------------------------------------------------------
>>>> --
>>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>>> imageio.dev.java.net
>>>> For additional commands, e-mail: interest-help@jai-
>>>> imageio.dev.java.net
>>>>
>>>
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>> imageio.dev.java.net
>>> For additional commands, e-mail: interest-help@jai-
>>> imageio.dev.java.net
>>>
>>
>

[att1.html]

robert engels

Using ImageIO with JDK 1.5, you can read the CMYK jpg directly into a
BufferedImage.

Then once you have a BufferedImage, write the BufferedImage into a
new RGB BufferedImage.

Then write the RGB BufferedImage as a JPG using ImageIO.

On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:

> Hi folks,
>
> the whole day i spend in netbeans and the web to find a solution to
> convert a cmyk-jpeg into rgb. The otherway works fine for me since
> hours, but this is not what i need. :-(
>
> after many new ideas and posibilitys, tools and coffees, finaly
> after 3pk. cigarettes i have this for convervting:
>
> PlanarImage inputCMYK_ = JAI.create("fileload",cmykdatei);
> BufferedImage inputCMYK = inputCMYK_.getAsBufferedImage();
> ColorSpace cs = ColorSpace.getInstance
> (ColorSpace.CS_GRAY);
> ColorConvertOp op = new ColorConvertOp(cs, null);
> BufferedImage bi = op.filter(inputCMYK, null);
> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>
> but it fails with: Bogus input colorspace
>
> for rgb2cmyk i uses this class:
>
> --
> /*
> * cmyk_handles.java
> *
> * Created on January 13, 2007, 11:20 PM
> *
> * To change this template, choose Tools | Template Manager
> * and open the template in the editor.
> */
>
> package nextgen;
>
> import com.sun.image.codec.jpeg.*;
> import java.awt.*;
> import java.awt.color.*;
> import java.awt.image.*;
> import java.io.*;
> import java.util.*;
> import javax.media.jai.*;
>
> /**
> *
> * @author kriswolff
> */
> public class rgb2cmyk_ICC {
>
> private static boolean invert = false;
> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>
> /** Creates a new instance of cmyk_handles */
> public rgb2cmyk_ICC() {
> }
>
> /**
> * @param args the command line arguments
> */
> public static void main(String[] args) {
> int[] bitsCMYK = {8,8,8,8};
>
> String cmykProfile = "/Library/Application Support/Adobe/
> Color/Profiles/Photoshop4DefaultCMYK.icc"; // icc-profile cmyk
> String rgbProfile = "/Library/Application Support/Adobe/
> Color/Profiles/Recommended/AppleRGB.icc";// icc-profile rgb
>
> // Dateiname f�r die Ausgabe
> StringTokenizer st = new StringTokenizer(rgbdatei,".");
> StringBuffer buffer = new StringBuffer();
> while ( st.hasMoreTokens() ) {
> buffer.append(st.nextToken());
> buffer.append("_cmyk");
> buffer.append(".jpg");
> break;
> }
>
> try {
>
> RenderedImage inputRGB = JAI.create("fileload",rgbdatei);
>
> // Create a CMYK Color Space from cmykProfile
> ICC_Profile p = ICC_Profile.getInstance(new
> FileInputStream(cmykProfile));
> ColorSpace csCMYK = new ICC_ColorSpace(p);
>
> ColorModel colorModelCMYK = new ComponentColorModel
> (csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TYPE_BYTE)
> ;
>
> ImageLayout cmykLayout = new ImageLayout();
> cmykLayout.setColorModel(colorModelCMYK);
> RenderingHints hints = new RenderingHints
> (JAI.KEY_IMAGE_LAYOUT,cmykLayout);
> cmykLayout.setSampleModel
> (colorModelCMYK.createCompatibleSampleModel(inputRGB.getWidth
> (),inputRGB.getHeight()));
>
> java.awt.image.renderable.ParameterBlock pb = new
> java.awt.image.renderable.ParameterBlock();
> pb.addSource(inputRGB);
> pb.add(colorModelCMYK);
> // convert the image from rgb-colorspace to cmyk-
> colorspace with icc
> PlanarImage out = JAI.create("ColorConvert",pb,hints);
>
> // Damit photoshop die Bilddaten nicht invertiert
> anzeigt erfolgt
> // eine invertierung der Daten
> pb = new java.awt.image.renderable.ParameterBlock();
> pb.addSource(out);
> PlanarImage out2 = JAI.create("invert",pb);
>
> WritableRaster cmykRaster = out2.copyData();
> // �ffnen des Output-Streams
> OutputStream datei = new FileOutputStream
> (buffer.toString());
>
> JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder
> (datei);
> JPEGEncodeParam param =
> encoder.getDefaultJPEGEncodeParam
> (cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
> param.setQuality(1, false);
> encoder.encode(cmykRaster, param);
> datei.close();
> System.out.println("Bild erfolgreich gespeichert");
>
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
> --
>
>
> so, i tryed to swap all cmyk to rgb and rgb to cmyk but this takes
> me into a long journy of errors and misunderstandable issues that
> takes me further away than i ever thougt about.
>
> So if anyone out there who is friendly and leads me into the light?
> I am absolutly burned out with this image things.
>
>
> Thank you very much in advanced.
> ven.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Kris Wolff

Hi Robert,

thanx for your reply. Do you know any workaround for java 1.4? I can
not change the version of the mac cluster :-(

ven.

On Jan 14, 2007, at 2:45 AM, robert engels wrote:

> Using ImageIO with JDK 1.5, you can read the CMYK jpg directly into
> a BufferedImage.
>
> Then once you have a BufferedImage, write the BufferedImage into a
> new RGB BufferedImage.
>
> Then write the RGB BufferedImage as a JPG using ImageIO.
>
>
> On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:
>
>> Hi folks,
>>
>> the whole day i spend in netbeans and the web to find a solution
>> to convert a cmyk-jpeg into rgb. The otherway works fine for me
>> since hours, but this is not what i need. :-(
>>
>> after many new ideas and posibilitys, tools and coffees, finaly
>> after 3pk. cigarettes i have this for convervting:
>>
>> PlanarImage inputCMYK_ = JAI.create("fileload",cmykdatei);
>> BufferedImage inputCMYK = inputCMYK_.getAsBufferedImage
>> ();
>> ColorSpace cs = ColorSpace.getInstance
>> (ColorSpace.CS_GRAY);
>> ColorConvertOp op = new ColorConvertOp(cs, null);
>> BufferedImage bi = op.filter(inputCMYK, null);
>> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>>
>> but it fails with: Bogus input colorspace
>>
>> for rgb2cmyk i uses this class:
>>
>> --
>> /*
>> * cmyk_handles.java
>> *
>> * Created on January 13, 2007, 11:20 PM
>> *
>> * To change this template, choose Tools | Template Manager
>> * and open the template in the editor.
>> */
>>
>> package nextgen;
>>
>> import com.sun.image.codec.jpeg.*;
>> import java.awt.*;
>> import java.awt.color.*;
>> import java.awt.image.*;
>> import java.io.*;
>> import java.util.*;
>> import javax.media.jai.*;
>>
>> /**
>> *
>> * @author kriswolff
>> */
>> public class rgb2cmyk_ICC {
>>
>> private static boolean invert = false;
>> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>>
>> /** Creates a new instance of cmyk_handles */
>> public rgb2cmyk_ICC() {
>> }
>>
>> /**
>> * @param args the command line arguments
>> */
>> public static void main(String[] args) {
>> int[] bitsCMYK = {8,8,8,8};
>>
>> String cmykProfile = "/Library/Application Support/Adobe/
>> Color/Profiles/Photoshop4DefaultCMYK.icc"; // icc-profile cmyk
>> String rgbProfile = "/Library/Application Support/Adobe/
>> Color/Profiles/Recommended/AppleRGB.icc";// icc-profile rgb
>>
>> // Dateiname f�r die Ausgabe
>> StringTokenizer st = new StringTokenizer(rgbdatei,".");
>> StringBuffer buffer = new StringBuffer();
>> while ( st.hasMoreTokens() ) {
>> buffer.append(st.nextToken());
>> buffer.append("_cmyk");
>> buffer.append(".jpg");
>> break;
>> }
>>
>> try {
>>
>> RenderedImage inputRGB = JAI.create("fileload",rgbdatei);
>>
>> // Create a CMYK Color Space from cmykProfile
>> ICC_Profile p = ICC_Profile.getInstance(new
>> FileInputStream(cmykProfile));
>> ColorSpace csCMYK = new ICC_ColorSpace(p);
>>
>> ColorModel colorModelCMYK = new ComponentColorModel
>> (csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TYPE_BYTE
>> );
>>
>> ImageLayout cmykLayout = new ImageLayout();
>> cmykLayout.setColorModel(colorModelCMYK);
>> RenderingHints hints = new RenderingHints
>> (JAI.KEY_IMAGE_LAYOUT,cmykLayout);
>> cmykLayout.setSampleModel
>> (colorModelCMYK.createCompatibleSampleModel(inputRGB.getWidth
>> (),inputRGB.getHeight()));
>>
>> java.awt.image.renderable.ParameterBlock pb = new
>> java.awt.image.renderable.ParameterBlock();
>> pb.addSource(inputRGB);
>> pb.add(colorModelCMYK);
>> // convert the image from rgb-colorspace to cmyk-
>> colorspace with icc
>> PlanarImage out = JAI.create("ColorConvert",pb,hints);
>>
>> // Damit photoshop die Bilddaten nicht invertiert
>> anzeigt erfolgt
>> // eine invertierung der Daten
>> pb = new java.awt.image.renderable.ParameterBlock();
>> pb.addSource(out);
>> PlanarImage out2 = JAI.create("invert",pb);
>>
>> WritableRaster cmykRaster = out2.copyData();
>> // �ffnen des Output-Streams
>> OutputStream datei = new FileOutputStream
>> (buffer.toString());
>>
>> JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder
>> (datei);
>> JPEGEncodeParam param =
>> encoder.getDefaultJPEGEncodeParam
>> (cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
>> param.setQuality(1, false);
>> encoder.encode(cmykRaster, param);
>> datei.close();
>> System.out.println("Bild erfolgreich gespeichert");
>>
>> } catch (Exception e) {
>> e.printStackTrace();
>> }
>> }
>> }
>> --
>>
>>
>> so, i tryed to swap all cmyk to rgb and rgb to cmyk but this takes
>> me into a long journy of errors and misunderstandable issues that
>> takes me further away than i ever thougt about.
>>
>> So if anyone out there who is friendly and leads me into the
>> light? I am absolutly burned out with this image things.
>>
>>
>> Thank you very much in advanced.
>> ven.
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>> For additional commands, e-mail: interest-help@jai-
>> imageio.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

robert engels

check the archives, there is information on reading the raster
(without the profile), and then some code to convert to an RGB jpeg

On Jan 13, 2007, at 8:52 PM, Kris Wolff wrote:

> Hi Robert,
>
> thanx for your reply. Do you know any workaround for java 1.4? I
> can not change the version of the mac cluster :-(
>
> ven.
>
> On Jan 14, 2007, at 2:45 AM, robert engels wrote:
>
>> Using ImageIO with JDK 1.5, you can read the CMYK jpg directly
>> into a BufferedImage.
>>
>> Then once you have a BufferedImage, write the BufferedImage into a
>> new RGB BufferedImage.
>>
>> Then write the RGB BufferedImage as a JPG using ImageIO.
>>
>>
>> On Jan 13, 2007, at 7:36 PM, Kris Wolff wrote:
>>
>>> Hi folks,
>>>
>>> the whole day i spend in netbeans and the web to find a solution
>>> to convert a cmyk-jpeg into rgb. The otherway works fine for me
>>> since hours, but this is not what i need. :-(
>>>
>>> after many new ideas and posibilitys, tools and coffees, finaly
>>> after 3pk. cigarettes i have this for convervting:
>>>
>>> PlanarImage inputCMYK_ = JAI.create
>>> ("fileload",cmykdatei);
>>> BufferedImage inputCMYK =
>>> inputCMYK_.getAsBufferedImage();
>>> ColorSpace cs = ColorSpace.getInstance
>>> (ColorSpace.CS_GRAY);
>>> ColorConvertOp op = new ColorConvertOp(cs, null);
>>> BufferedImage bi = op.filter(inputCMYK, null);
>>> ImageIO.write(bi, "JPEG", new File("/tmp/b.jpg") );
>>>
>>> but it fails with: Bogus input colorspace
>>>
>>> for rgb2cmyk i uses this class:
>>>
>>> --
>>> /*
>>> * cmyk_handles.java
>>> *
>>> * Created on January 13, 2007, 11:20 PM
>>> *
>>> * To change this template, choose Tools | Template Manager
>>> * and open the template in the editor.
>>> */
>>>
>>> package nextgen;
>>>
>>> import com.sun.image.codec.jpeg.*;
>>> import java.awt.*;
>>> import java.awt.color.*;
>>> import java.awt.image.*;
>>> import java.io.*;
>>> import java.util.*;
>>> import javax.media.jai.*;
>>>
>>> /**
>>> *
>>> * @author kriswolff
>>> */
>>> public class rgb2cmyk_ICC {
>>>
>>> private static boolean invert = false;
>>> private static String rgbdatei = "/tmp/myimage.rgb.jpg";
>>>
>>> /** Creates a new instance of cmyk_handles */
>>> public rgb2cmyk_ICC() {
>>> }
>>>
>>> /**
>>> * @param args the command line arguments
>>> */
>>> public static void main(String[] args) {
>>> int[] bitsCMYK = {8,8,8,8};
>>>
>>> String cmykProfile = "/Library/Application Support/Adobe/
>>> Color/Profiles/Photoshop4DefaultCMYK.icc"; // icc-profile cmyk
>>> String rgbProfile = "/Library/Application Support/Adobe/
>>> Color/Profiles/Recommended/AppleRGB.icc";// icc-profile rgb
>>>
>>> // Dateiname f�r die Ausgabe
>>> StringTokenizer st = new StringTokenizer(rgbdatei,".");
>>> StringBuffer buffer = new StringBuffer();
>>> while ( st.hasMoreTokens() ) {
>>> buffer.append(st.nextToken());
>>> buffer.append("_cmyk");
>>> buffer.append(".jpg");
>>> break;
>>> }
>>>
>>> try {
>>>
>>> RenderedImage inputRGB = JAI.create
>>> ("fileload",rgbdatei);
>>>
>>> // Create a CMYK Color Space from cmykProfile
>>> ICC_Profile p = ICC_Profile.getInstance(new
>>> FileInputStream(cmykProfile));
>>> ColorSpace csCMYK = new ICC_ColorSpace(p);
>>>
>>> ColorModel colorModelCMYK = new ComponentColorModel
>>> (csCMYK,bitsCMYK,false,false,Transparency.OPAQUE,DataBuffer.TYPE_BYT
>>> E);
>>>
>>> ImageLayout cmykLayout = new ImageLayout();
>>> cmykLayout.setColorModel(colorModelCMYK);
>>> RenderingHints hints = new RenderingHints
>>> (JAI.KEY_IMAGE_LAYOUT,cmykLayout);
>>> cmykLayout.setSampleModel
>>> (colorModelCMYK.createCompatibleSampleModel(inputRGB.getWidth
>>> (),inputRGB.getHeight()));
>>>
>>> java.awt.image.renderable.ParameterBlock pb = new
>>> java.awt.image.renderable.ParameterBlock();
>>> pb.addSource(inputRGB);
>>> pb.add(colorModelCMYK);
>>> // convert the image from rgb-colorspace to cmyk-
>>> colorspace with icc
>>> PlanarImage out = JAI.create("ColorConvert",pb,hints);
>>>
>>> // Damit photoshop die Bilddaten nicht invertiert
>>> anzeigt erfolgt
>>> // eine invertierung der Daten
>>> pb = new java.awt.image.renderable.ParameterBlock();
>>> pb.addSource(out);
>>> PlanarImage out2 = JAI.create("invert",pb);
>>>
>>> WritableRaster cmykRaster = out2.copyData();
>>> // �ffnen des Output-Streams
>>> OutputStream datei = new FileOutputStream
>>> (buffer.toString());
>>>
>>> JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder
>>> (datei);
>>> JPEGEncodeParam param =
>>> encoder.getDefaultJPEGEncodeParam
>>> (cmykRaster,JPEGEncodeParam.COLOR_ID_CMYK);
>>> param.setQuality(1, false);
>>> encoder.encode(cmykRaster, param);
>>> datei.close();
>>> System.out.println("Bild erfolgreich gespeichert");
>>>
>>> } catch (Exception e) {
>>> e.printStackTrace();
>>> }
>>> }
>>> }
>>> --
>>>
>>>
>>> so, i tryed to swap all cmyk to rgb and rgb to cmyk but this
>>> takes me into a long journy of errors and misunderstandable
>>> issues that takes me further away than i ever thougt about.
>>>
>>> So if anyone out there who is friendly and leads me into the
>>> light? I am absolutly burned out with this image things.
>>>
>>>
>>> Thank you very much in advanced.
>>> ven.
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: interest-unsubscribe@jai-
>>> imageio.dev.java.net
>>> For additional commands, e-mail: interest-help@jai-
>>> imageio.dev.java.net
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>> For additional commands, e-mail: interest-help@jai-
>> imageio.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net