Convert CMYK to RGB for MS Word?

Greetings! I've designed a logo for a client using Illustrator CS6. There is the 4-color version in CMYK .eps as well as 1-color, 2-color, and KO versions. Everything looks and acts as it should and will no doubt be perfect for offset printing (my main area of experience). However, once delivered to the client they were anxious to put them into use and immediately dropped the 4-color version into a word document and made a pdf for email distribution. When I received it I had to groan, the colors had shifted to the obscene.
My guess is that what the client needs is a set of the logos that are converted to RGB. I'm also thinking that since the logos might be re-sized for various uses, keeping the art in the .eps format (as opposed to a raster format) makes sense. Is that true?
And,
Is there an easy way to convert the original CMYK eps files to RGB within Illustrator?
I'm wide open to suggestions for best practices regarding artwork for use in MS Office applications.
Thanks!
Tim

Since you're already familiar with a print workflow, your profiles are probably correct for this conversion. The only caveat would be how Word deals with color. I don't use Word, so I have no idea about that. Best practice would be to learn how your client is going to use the files you supply, and test each application.

Similar Messages

  • How to convert CMYK to RGB programmatically.

    Hi,
    I have a CMYK colorspace in indesign, i want to convert that as RGB color space, I got some codes, but I am getting incorrect data.
    Some of the codes which I tried are given below
            double cyan = 35.0;
            double magenta = 29.0;
            double yellow = 0.0;
            double black = 16.0;
            cyan = Math.min(255, cyan + black); //black is from K
            magenta = Math.min(255, magenta + black);
            yellow = Math.min(255, yellow + black);
            l_res[0] = 255 - cyan;
            l_res[1] = 255 - magenta;
            l_res[2] = 255 - yellow;
    @Override
        public float[] toRGB(float[] p_colorvalue) {
            float[] l_res = {0,0,0};
            if (p_colorvalue.length >= 4)
                float l_black = (float)1.0 - p_colorvalue[3];
                l_res[0] = l_black * ((float)1.0 - p_colorvalue[0]);
                l_res[1] = l_black * ((float)1.0 - p_colorvalue[1]);
                l_res[2] = l_black * ((float)1.0 - p_colorvalue[2]);
            return (l_res);
    The values are C=35, M = 29, Y = 0, K = 16 in CMYK color space and the correct RGB values are R = 142, G = 148, B = 186.
    In adobe indesign, using swatches we can change the mode to CMYK or to RGB.
    But I want to do that programmatically, Can I get any algorithm to convert CMYK to RGB which will give the correct RGB values.
    And one more question, if the alpha value for RGB is 1 then what will be the alpha value for CMYK?
    Can anyone help me to solve these issues... Thanks in advance.

    All you have to do is loop thru the swatches and change the space to RGB. Below is an AppleScript, but it shouldn't be too difficult to come up with the equivalent JavaScript. Your document's assigned RGB space will determine what RGB space the CMYK converts to, so if you are looking for sRGB, then Edit>Assign Profiles...>Assign Profile: sRGB
    tell application "Adobe InDesign CS3"
    tell document 1
    repeat with a from 1 to count of every swatch
    try
    set space of color a to RGB
    end try
    end repeat
    display dialog "All swatches have been converted to RGB color"
    end tell
    end tell

  • Convert cmyk to rgb in acrobat 7

    Good morning,
    I have a question about converting color spaces using Acrobat 7 Professional  and Pitstop Pro.
    I have some CMYK PDFs used for magazine printing that I need to convert to a 144 DPI RGB version for a digital edition.
    I know most folks are concerned with RGB to CMYK but I need to do it in reverse...
    If I do a Convert Color in Acrobat CMYK to RGB it looks a lot better than if I do it using an Action List command to Convert to RGB  in Pitstop.
    The Pitstop ones look almost posterized, way darker with significant color shifts
    I would have thought Pitstop would use the Acrobat color engine to do the transformation to RGB but it seeems it knid of does it's own thing.
    I do have sRGB selected in my Color Management Prefs in Acrobat.
    It would be nice to make this RGB second version PDF with Pitstop and Distiller on our server so it runs more automated, less manual intervention...
    thanks for any advice you have,
    Pat

    I think I stumbled across the solution... there are separate Color Management Preference controls for Pitstop.
    I selected sRGB instead of the Enfocus Default RGB.

  • Converting cmyk to rgb

    I have about 200 .psd files with a customized CMYK profile (used for press) that I have covert to Adobe RGB (1998).   Amazon recommends this for Look Inside, because CMYK fails when they OCR the PDFs.
    The only way I know to do this is one .psd at a time. Is there a way to streamline this in Bridge or PS other than using keystroke shortcuts (which I alrady do)?
    Thanks in advamce.
    Toni

    Outstanding. Thank you so much! Ninty files done in a flash, 150 to go. Now if I could just get something simialr to work on my 300+ Illustator files!
    Cheers,
    Toni

  • Why do Adobe Color CC and Indesign CC not convert CMYK to RGB the same?

    I recently used Adobe Color CC to create a color theme that will be used for both print and web.  I created the theme with approved CMYK values with the intent of saving the .ASE file to be imported into other CC apps.  Corresponding RGB, Hex, Lab and HSB values are automatically created.  Of course, we are using CMYK for print and RGB for web
    A coworker had separately created the same exact CMYK theme in InDesign CC, and created RGB values from the same exact CMYK values I had used in Adobe Color.
    The InDesign RGB values are quite different from the Adobe Color values.
    Anyone know why the values are not the same, and moreover, which CMYK to RGB conversion values may be relied upon for accuracy?
    EDIT: I guess the real question should be, What are the color management settings built-in to Adobe Color CC, and can they be duplicated in desktop Adobe CC applications?
    Thanks very much

    I found what change it to normal way, but logicaly it's should not be a reason for autoconvert colors. If I choose CMYK and want add CMYK color it should be CMYK (in name minimum) and not RGB.
    File->Documents Colors->CMYK(should be, but RGB was)
    Right now options open like CMYK, not HSB. But if I want color in RGB it added like CMYK. Options like in CMYK, not HSB, again. Still look like error.

  • How do you Convert CMYK to RGB

    I have a project that I need to convert all of the AI files from CMYK to RGB. This use to be very simple back-in-the-day by just choosing Filter > Convert to RGB. I know about Document Color Mode and Convert to RGB.
    When I select all of the objects and choose RGB under Document Color Mode, I still see CMYK plates when I preflight the PDF. Depending on what the Document Color Mode is set on, I either have Convert to RGB grayed out or always available. The resulting file show up as CMYK in both Quark and ID along with CMYK plates when I preflight the PDF.
    What am I missing here?
    AI CC 2014

    Can you be more specific? Which option are you interested in?

  • Why don't Adobe Color CC and InDesign CC convert CMYK to RGB the same?

    I recently used Adobe Color CC to create a color theme that will be used for both print and web.  I created the theme with approved CMYK values with the intent of saving the .ASE file to be imported into other CC apps.  Corresponding RGB, Hex, Lab and HSB values are automatically created.  Of course, we are using CMYK for print and RGB for web
    A coworker had separately created the same exact CMYK theme in InDesign CC, and created RGB values from the same exact CMYK values I had used in Adobe Color.
    The InDesign RGB values are quite different from the Adobe Color values.
    Anyone know why the values are not the same, and moreover, which CMYK to RGB conversion values may be relied upon for accuracy?
    Thanks very much

    It's working for me (Web, PS, AE, ID, FL; not available in the Color Themes panel in Ai).  Please click the triangle next to the color space to expand and view more data.

  • Why Illustrator CS6 convert CMYK to RGB when I do "Add to switches" in Color menu?

    1. Open Color menu and work with color in CMYK.
    2. Do "Add to switches" (or "Создать новый образец" in Russian)
    3. See that new color was added like RGB not like CMYK.
    4. When I open parameters it show me HSB options.
    5. I switch it to CMYK and push OK
    6. Nothing cange - RGB in name and HSB in options.
    Look like it's error.

    I found what change it to normal way, but logicaly it's should not be a reason for autoconvert colors. If I choose CMYK and want add CMYK color it should be CMYK (in name minimum) and not RGB.
    File->Documents Colors->CMYK(should be, but RGB was)
    Right now options open like CMYK, not HSB. But if I want color in RGB it added like CMYK. Options like in CMYK, not HSB, again. Still look like error.

  • Applescript ObjC  convert CMYK to RGB

    G'day scripters
    I've got a routine that gets the color from a color well. Trouble is, it's sometimes in CMYK instead of RGB, which I need.
    I've tried all sorts of things, but constantly get the error...
    18/11/09 12:21:30 PM Mail Manager Reporter[1386] [<NSCalibratedRGBColor 0x2004d9d80> valueForUndefinedKey:]: this class is not key value coding-compliant for the key colorUsingColorSpaceName_calibratedRGBColorSpace.
    The code is...
    on colorWellSet_(sender)
    try
    set ThetempColor to theMainColorWell's |color|
    log
    set ThetempColor to ThetempColor's colorUsingColorSpaceName_calibratedRGBColorSpace
    --set ThetempColor to theMainColorWell's |color|
    --set ThetempColor to theMainColorWell's colorUsingColorSpaceName_calibratedRGBColorSpace
    --set ThetempColor to |color| of theMainColorWell's colorUsingColorSpaceName_calibratedRGBColorSpace
    --set ThetempColor to ThetempColor's colorUsingColorSpaceName_calibratedRGBColorSpace
    --set ThetempColor to theMainColorWell's colorSpaceCreateWith_colorSpaceGenericRGB
    set temp1 to ThetempColor's redComponent()
    set temp2 to ThetempColor's greenComponent()
    set temp3 to ThetempColor's blueComponent()
    set TheColor to {(temp1 * 65535), (temp2 * 65535), (temp3 * 65535)}
    on error errmsg
    display dialog errmsg
    end try
    end colorWellSet_
    As you can see, I've tried lots of things, but they all return the same error.
    Can someone please explain how to fix it?
    Regards
    Santa

    G'day
    Thanks to you both
    the code I ended up with is
    property NSColor : class "NSColor"
    on colorWellSet_(sender)
    try
    set ThetempColor to theMainColorWell's |color|
    set ThetempColor to ThetempColor's colorUsingColorSpaceName_(current application's NSCalibratedRGBColorSpace)
    set temp1 to ThetempColor's redComponent()
    set temp2 to ThetempColor's greenComponent()
    set temp3 to ThetempColor's blueComponent()
    set TheColor to {(temp1 * 65535), (temp2 * 65535), (temp3 * 65535)}
    on error errmsg
    display dialog errmsg
    end try
    end colorWellSet_

  • How does PDF convert CMYK to RGB?

    Hi
    I want to know the formula that PDF uses to convert DeviceCMYK to DeviceRGB values. It seems that Photoshop and PDF uses the same forula, where the other Programs use the "normal" formula, which can be found on the internet and some online RGB to CMYK calculators.
    Where can I get this formula?

    As recommended in the PDF Standard (ISO 32000), all color conversion is done using ICC-based color conversion.  The "red book" algorithms are clearly marked as deprecated in ISO 32000-1.

  • FM10 Crashes when Convert CMYK colors to RGB selected

    Hi folks,
    I have searched for info on this issue and found a couple of items but I'm still having problems doing what I need to do.
    First off, FM 10 version is 10.0.2.419. PC is Dell E6420 laptop, Win 7 SP1, 8GB RAM, big hard drive. No existing Adobe software before installing TCS 3.0 from local files (copied from DVD).
    At first I could not create a pdf (using File > Save as PDF) at all on this system (my old XP system still works fine with TCS 3.0). Instant crash and error messages (Internal error 10024, 7687848, 7688138, 10076935.). After reading the discussions, I cleared the check box for Convert CMYK colors to RGB, which allowed me to create the pdf. However, my colors are washed out completely. So I need to be able to select this check box without the crash.
    Any suggestions?
    Thanks!

    (1)     Although FrameMaker 10 is a 32-bit application, there was no issue with it running under Windows 7 64-bit. You certainly don't need to run it under any XP mode!!!!
    (2)     There were any number of save as PDF bugs in FrameMaker 10 that were fixed in various updates, but typically they were associated with when one didn't check that convert CMYK to RGB option (that uses the native Windows GDI for PostScript creation).
    (3)     Rather than printing to File and distilling, try printing directly to the Adobe PDF PostScript printer driver instance.
              - Dov

  • How can I convert Pdf from RGB to CMYK, keeping font color 100% K while working in Illustrator?

    How can I convert Pdf from RGB to CMYK, keeping font color 100% K while working in Illustrator?
    When I try to open the document in Illustrator and I convert to CMYK the black font converts to rich black, but to set up for Offset printintg I need the text to be only in Black (100%K).
    The original source of the document is a Microsoft Word file, I have converted the Word file to Pdf in order to setup for OFfset Printing.
    Thanks

    I have tried that way, but the downside is that the fonts are set in gray not in a 100%K, also I have to deal with other fonts that are composites and meant to stay Full Color. I could select text by text and convert to gray but, its a 64 page document and I wouldn't want to make a expensive mistake.

  • 'Convert CMYK Colors to RGB' still runs havoc in 9! (Plus a PDF version problem)

    This post is to warn people about severe issues, and how to avoid them. Issues with the CMYK color setting in FM9.x have been reported here earlier, such as:
    http://forums.adobe.com/message/1237696#1237696
    http://forums.adobe.com/message/1237852#1237852
    http://forums.adobe.com/message/1237165#1237165
    However, I do not think this issue has been warned about anywhere near as much as it should have. And, as usual, Adobe is silent (they should have a big poster on their site warning about this issue! And they have even claimed that patches have "solved" the issues with CMYK).
    Just recently, while experimenting with FM9 again, I had extreme problems, which, at first, seemed totally unrelated to this CMYK setting. But after having struggled extremely hard for many many many hours, I finally found out. Now is the time to inform others:
    First a note about versions: FrameMaker 9.0p237, Acrobat Distiller 9.1, XP SP2
    It looks perfectly okay on screen in FrameMaker, exactly as in FM8. But when saved as pdf, several things are "corrupted". Examples: no kerning after the letter 'T', such as the word 'Text'. Dotted leader for a right aligned tab disappears. Some objects from the master pages, such as a logo, become enclosed in a rectangle (a border of the frame/object), but it only happens on *some* body pages, whereas other body pages using the same master page are ok!!? Equations are formatted differently from the way they should, with the wrong font for number, etcetera.
    Solutions:
    1. When 'Save as PDF...', untick 'Convert CMYK Colors to RGB' in PDF Setup. Same setting is in the file's 'Format > Document > PDF Setup...'
    A drawback with this method is that, as of Acrobat Distiller v9, it does not seem to respect the pdf version specified in the PDF job Options! I get PDF 1.6 with this method, despite my job option specifies version 1.5. (This happens also with FrameMaker 8 if Acrobat is v9.) So you *have* to optimize it in Acrobat in order to get a web friendly PDF (PDF 1.4 or 1.5).
    or
    2. Print to 'Adobe PDF'.
    In this latter case, you can set the same 'PDF Setup' settings under the button 'Setup...', EXCEPT that there is no tick box for 'Convert CMYK Colors to RGB', and it does not matter what setting you have chosen in the file's 'Format > Document > PDF Setup...', it will be RGB conversion in any case. Make sure that after you exit the setting, the tick box for 'Print to File' is NOT ticked! This method respects the pdf version specified in the PDF job Options! I get PDF 1.5, which is what my job option specifies.
    (For some reason, Acrobat/Reader does not render these two PDFs exactly the same, except in extreme magnification! Maybe it has to do with the different PDF versions of the files.)
    In either case, the solution actually solves ALL problems I listed! Despite it seems to have absolutely nothing whatsoever to do with colors! Some day in the distant future, CMYK might actually work! But, for myself, I would prefer a proper color management instead...
    Best Regards,
      /Harald

    Oops!! Not until now I discover that under 'Solutions' I happened to write 'untick' where it should be 'tick'! I.e, colors SHOULD be converted to RGB in order to circumvent the problems! I.e it runs havoc in v9 when CMYK colors are NOT converted to RGB! Don't know how I came to write the opposite, but probably I started out by describing the situation where the problems are seen rather than describing how to avoid them.
    Equally strange is that nobody corrected me, but perhaps the mistake was so obvious? (But whether you see problems or not might depend on what fonts you use. So, under certain special circumstances, CMYK might actually work without these reported problems.)
    I am also a bit surprised that others haven't reported the issue that the PDF version set in PDF job Options isn't respected when using 'Save As PDF' and Acrobat 9? (Or maybe someone has, but I have missed it.)

  • Convert CMYK+SPOT (only selected bands) to RGB

    Hello,
    My context:
    I am dealing with multi-band TIFF files - CMYK + one or more SPOT colors.
    I am able to read the multi-band TIFF file using JAI and read the number of bands correctly.
    Also, I can read the value for any band for any pixel.
    For the SPOT colors I have Pantone CMYK equivalents.
    The bands are 8 bit in size.
    My problem:
    I need to be able to show/hide one or more bands and display the result.
    Is there a (mathematical) formula for converting CMYK+SPOT color bands to the RGB color space?
    A simple example:
    (CMYK scale 0-100)
    All bands: C, M, Y, K, SPOT1 (C=100,M=100,Y=0,K=0), SPOT2(C=100,M=0,Y=100,K=0)
    Bands selected: C, M, SPOT1
    PixelX values: C = 50, M = 10, SPOT1=80
    Can we calculate PixelX's RGB values to display on screen?
    Is there any documentation I can read anywhere on the subject?
    Thanks in advance,
    Georgi

    While I have never tried it, you might find this interesting: [cmyk to rgb|http://bytes.com/topic/java/answers/16180-rgb-cmyk].

  • Converting cmyk compressed images to rgb compressed format

    Hi,
    I need some help in converting of CMYK images to RGB images. I got some sample code from internet but I get some run time exceptions with that and I'm not able to figure out the reason for the same. Pls help me in fixing the same. Any help will be sincerely appreicated.
    The code is given below :
    import java.awt.image.*;
    import java.awt.image.renderable.*;
    import java.awt.color.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.io.*;
    import java.net.*;
    import javax.media.jai.*;
    import com.sun.image.codec.jpeg.*;
    public class CMYKTest1 {
      public static void main(String args[]) throws Exception{
         RenderedOp op = JAI.create("fileload", "Kristopher Brock LOGO.jpg");
         ColorModel rgbcm = op.getColorModel();
         ICC_Profile profile = ICC_Profile.getInstance("CMYK.pf");
    //     ICC_Profile profile = ICC_Profile.getInstance(ColorSpace.TYPE_CMYK);
         ICC_ColorSpace icp = new ICC_ColorSpace(profile);
         ColorModel colorModel =
              RasterFactory.createComponentColorModel(op.getSampleModel().getDataType(),
                                                                icp,
                                                                false,
                                                                false,
                                                                Transparency.OPAQUE);
         ImageLayout il = new ImageLayout();
         il.setSampleModel(colorModel.createCompatibleSampleModel(op.getWidth(),
                                                                                op.getHeight()));
         RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il);
         ParameterBlock pb = new ParameterBlock();
         pb.addSource(op).add(colorModel);
         op = JAI.create("ColorConvert", pb, hints);
         pb = new ParameterBlock();
         pb.addSource(op).add(rgbcm);
         il = new ImageLayout();
         il.setSampleModel(rgbcm.createCompatibleSampleModel(op.getWidth(),
                                                                          op.getHeight()));
         hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il);
         op = JAI.create("ColorConvert", pb, hints);
         JAI.create("filestore", op, "earthrgb.jpg", "JPEG", null);
         BufferedImage img = op.getAsBufferedImage(null, null);
         OutputStream fout = new FileOutputStream("earthrgb1.jpg");
         JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fout);
         JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(img);
         param.setQuality(1, false);
         param.setXDensity(300);
         param.setYDensity(400);
         encoder.encode(img, param);
         fout.close();
    }I get the following error:
    Caused by: java.lang.IllegalArgumentException: Numbers of source Raster bands and source color space components do not match
         at java.awt.image.ColorConvertOp.filter(Unknown Source)
         at com.sun.media.jai.opimage.ColorConvertOpImage.computeRectNonColorSpaceJAI(ColorConvertOpImage.java:373)
         at com.sun.media.jai.opimage.ColorConvertOpImage.computeRect(ColorConvertOpImage.java:290)
         at javax.media.jai.PointOpImage.computeTile(PointOpImage.java:914)
         at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
         at javax.media.jai.OpImage.getTile(OpImage.java:1129)
         at javax.media.jai.PointOpImage.computeTile(PointOpImage.java:911)
         at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
         at javax.media.jai.OpImage.getTile(OpImage.java:1129)
         at com.sun.media.jai.codecimpl.JPEGImageEncoder.encode(JPEGImageEncoder.java:173)
         at com.sun.media.jai.opimage.EncodeRIF.create(EncodeRIF.java:70)
         ... 24 more
    Error: One factory fails for the operation "filestore"
    Occurs in: javax.media.jai.ThreadSafeOperationRegistry
    java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
         at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
         at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473)
         at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:332)
         at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:819)
         at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:867)
         at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:888)
         at javax.media.jai.JAI.createNS(JAI.java:1099)
         at javax.media.jai.JAI.create(JAI.java:973)
         at javax.media.jai.JAI.create(JAI.java:1668)
         at CMYKTest1.main(CMYKTest1.java:79)
    Caused by: javax.media.jai.util.ImagingException: All factories fail for the operation "encode"
         at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1687)
         at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473)
         at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:332)
         at com.sun.media.jai.opimage.FileStoreRIF.create(FileStoreRIF.java:138)
         ... 15 moreThanks & Regards,
    Magesh.

    The following code converts an cmyk jpeg image into an rgb jpeg image.
    The only problem if this code is that it loads the whole image in memory and thus you'll need a lot of RAM when converting large images. For example, it take around 300 MB to convert a 3000*3800px image (this is a 5MB jpeg image when compressed on disk).
    import com.sun.image.codec.jpeg.JPEGImageEncoder;
    import com.sun.image.codec.jpeg.JPEGCodec;
    import com.sun.image.codec.jpeg.JPEGEncodeParam;
    import javax.imageio.ImageIO;
    import javax.imageio.ImageReader;
    import javax.imageio.stream.ImageInputStream;
    import javax.imageio.metadata.IIOMetadata;
    import javax.imageio.metadata.IIOMetadataNode;
    import java.util.*;
    import java.io.*;
    import java.awt.image.*;
    import java.awt.*;
    import java.awt.color.ColorSpace;
    import org.w3c.dom.NodeList;
    public class Test {
        public static void main(String[] args) throws Exception {
            BufferedImage i1 = readImage(new File("cmyk.jpg"));
            BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(new File("rgb.jpg")));
            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
            JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(i1);
            param.setQuality(1, false);
            encoder.setJPEGEncodeParam(param);
            encoder.encode(i1);
        public Test() {
        // extract metadata
        public static BufferedImage readImage(File file) throws IOException {
            // Get an ImageReader.
            ImageInputStream input = ImageIO.createImageInputStream(file);
            Iterator readers = ImageIO.getImageReaders(input);
            if (readers == null || !readers.hasNext()) {
                throw new RuntimeException("No ImageReaders found");
            ImageReader reader = (ImageReader) readers.next();
            reader.setInput(input);
            String format = reader.getFormatName();
            if ("JPEG".equalsIgnoreCase(format) || "JPG".equalsIgnoreCase(format)) {
                IIOMetadata metadata = reader.getImageMetadata(0);
                String metadataFormat = metadata.getNativeMetadataFormatName();
                IIOMetadataNode iioNode = (IIOMetadataNode) metadata.getAsTree(metadataFormat);
                NodeList children = iioNode.getElementsByTagName("app14Adobe");
                if (children.getLength() > 0) {
                    iioNode = (IIOMetadataNode) children.item(0);
                    int transform = Integer.parseInt(iioNode.getAttribute("transform"));
                    Raster raster = reader.readRaster(0, reader.getDefaultReadParam());
                    if (input != null) {
                        input.close();
                    reader.dispose();
                    return createJPEG4(raster, transform);
            throw new RuntimeException("No ImageReaders found");
         * Java's ImageIO can't process 4-component
         * images
         * <p/>
         * and Java2D can't apply AffineTransformOp
         * either,
         * <p/>
         * so convert raster data to
         * RGB.
         * <p/>
         * Technique due to MArk
         * Stephens.
         * <p/>
         * Free for any
         * use.
        private static BufferedImage createJPEG4(Raster raster, int xform) {
            int w = raster.getWidth();
            int h = raster.getHeight();
            byte[] rgb = new byte[w * h * 3];
            // if (Adobe_APP14 and transform==2) then YCCK else CMYK
            if (xform == 2) {    // YCCK -- Adobe
                float[] Y = raster.getSamples(0, 0, w, h, 0, (float[]) null);
                float[] Cb = raster.getSamples(0, 0, w, h, 1, (float[]) null);
                float[] Cr = raster.getSamples(0, 0, w, h, 2, (float[]) null);
                float[] K = raster.getSamples(0, 0, w, h, 3, (float[]) null);
                for (int i = 0, imax = Y.length, base = 0; i < imax; i++, base += 3) {
                    float k = 220 - K, y = 255 - Y[i], cb = 255 - Cb[i], cr = 255 - Cr[i];
    double val = y + 1.402 * (cr - 128) - k;
    val = (val - 128) * .65f + 128;
    rgb[base] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff : (byte) (val + 0.5);
    val = y - 0.34414 * (cb - 128) - 0.71414 * (cr - 128) - k;
    val = (val - 128) * .65f + 128;
    rgb[base + 1] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff : (byte) (val + 0.5);
    val = y + 1.772 * (cb - 128) - k;
    val = (val - 128) * .65f + 128;
    rgb[base + 2] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff : (byte) (val + 0.5);
    else {
    // assert xform==0: xform;
    // CMYK
    int[] C = raster.getSamples(0, 0, w, h, 0, (int[]) null);
    int[] M = raster.getSamples(0, 0, w, h, 1, (int[]) null);
    int[] Y = raster.getSamples(0, 0, w, h, 2, (int[]) null);
    int[] K = raster.getSamples(0, 0, w, h, 3, (int[]) null);
    for (int i = 0, imax = C.length, base = 0; i < imax; i++, base += 3) {
    int c = 255 - C[i];
    int m = 255 - M[i];
    int y = 255 - Y[i];
    int k = 255 - K[i];
    float kk = k / 255f;
    rgb[base] = (byte) (255 - Math.min(255f, c * kk + k));
    rgb[base + 1] = (byte) (255 - Math.min(255f, m * kk + k));
    rgb[base + 2] = (byte) (255 - Math.min(255f, y * kk + k));
    // from other image types we know InterleavedRaster's can be
    // manipulated by AffineTransformOp, so create one of
    // those.
    raster = Raster.createInterleavedRaster(new DataBufferByte(rgb, rgb.length), w, h, w * 3, 3, new int[]{0, 1, 2}, null);
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorModel cm = new ComponentColorModel(cs, false, true, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
    return new BufferedImage(cm, (WritableRaster) raster, true, null);

Maybe you are looking for

  • Key board and track pad not working

    Ok, My situation is similar to some of the other things posted but not quite. I tried to wake my computer up from sleep the other day and it wouldn't "wake up" so I did a hard shut down and restart. When it restarted the key board and track pad did n

  • How do I download an ebook to read in itunes? I have windows 7 and itunes 12

    How do I download a book to read in itunes? I have windows 7 home premium and itunes 12? I think my computer is authorized and my account is up to date.

  • Vendor + Customer Ledger Balance

    Hello Experts, I am end user in Fico We are created some Vendor as a Customer through customer master because we are creating some scrap sales billing to the same vendor means customer. We have seen thier ledger balance as Vendor Bal. in Vendor Ledge

  • The "Recently Used" entry in the file open/save dialog

    The file selection dialog (eg: save/open/etc) on gtk applications has a "Recently Used" option: Over size imaged reduced to link This has generally not shown any options for me (for some reason, firefox suddenly showed a single entry this time). I fi

  • A proposal - moving some things out of mx.rpc into mx.async?

    Hey guys, Just want to get your thoughts rather than jump in and filing a feature request. What do you think about moving a few things that aren't necessarily RPC out of mx.rpc and into a new package (for example mx.async) and removing some of the se