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

Similar Messages

  • 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?

  • 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.

  • How to convert YUV to RGB

    I need to convert the YUV values to RGB. What is the formulae to convert? YUV values in the ratio 4:2:2. First I read it from a YUV file,then
    convert it to RGB. Then make an image(JPEG) from this values. How can I do this?

    http://www.fourcc.org/fccyvrgb.php
    First result in google...Like I said, no initiative what so ever!
    The OP is a goldmine of post like these, I forsee that he's about to start a major project that he's incapable of and get the forum to complete it for him

  • 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.

  • 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.

  • 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.

  • 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.

  • 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_

  • 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.

  • 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

  • How to convert CMYK files to K only (C=0 M=0 Y=0) for print, PDF and JPGE

    I have a Jpeg image in grayscale and I need to print it in  K only (while CMY=0) instead of CMYK. I have tried with channel mixed presets and even though the info on screen is now C=0, M=0, Y=0 and K= various values, when I send it to print. The printer still prints with all the CMYK colours so instead of a clean monochrome colour I get yellows reds and blues.
    Any advice would be so much appreciated!
    M

    Hi Gustavo,
    Thank you for your email. My non-human printer is a cannon CLC 5151 and the funny thing is that it does print in black sometimes.
    I have a psd document with C=0 M=0 Y=0 K=various which I have created with the channel mixer presets. - I sent it to print and = 4 coloured grey result
    I open an indesign document and place this very same file (plus others with the same presets with which I create my composition) - I send it to print and = black only
    Then, I say great it's printing on black so now I just need to export this composition as a JPEG
    So I export it and when I send to print = 4 coloured grey
    The is when I realise that the C=0 M=0 Y=0 and various K pressets I originally created have been lost again on this JPEG.
    I come back to indesign and export a PDF and I find that my original presets to black only are now divided into CMYK colour again.
    Perhaps the channel mixer presets are only a guide and they are not preserved when I import the document anywhere else, but I wonder How come this psd document prints in 4 colured grey despite what you can see on the info?
    I have tried to paste the image into the black channel of a new document but I can't save it as a JPGE nor I can place onto an indesign either because it doesn't recognize the colour mode.
    I agree with you in that it's nicer to get a greyscale with 4 colour ink but only if the printer is properly calibrated and ours isn't at all. and I need to present both indesign and JPEG prints and they should be looking the same.
    M
    Saludos desde Londres

  • How to convert CMYK to Pantone?

    I have a document with 10+ images that need to be 2-color, black and a Pantone ink. (These are not duotone images; each one is grayscale with certain parts of the image colored in the Pantone ink. Think of a grayscale face with red lips.) I first converted these to grayscale and then selected a Pantone ink color and colored parts of the image using the paint bucket, etc. However, my printer said that they cannot print these from my 2-color InDesign document because the images are CMYK and that Photoshop cannot separate two colors unless you use Duotone. I don't want them duotone as only certain parts of the photos should be colored. The only solution I know would be to insert the gray images without color into my InDesign document and then try to color them with the InDesign tools, which would be really difficult. Please help! There must be another way.

    You can do this a few ways. Your best would be to create a grayscale doc with the black ink, and then in the channels panel flyout menu (to the right of "channels"), create a new spot color. Assign it the Pantone number by clicking on the little square to the right of "color" and then the color libraries button. Paint in that instead. If you need the ink to be overprinted by black then it should be quite simple. Otherwise, you can use the black channel to knockout parts of the spot by ctrl-clicking on the black channel, inversing the selection, and then filling with white.
    If they balk at this file saved as a TIF (with "spot channels" checked when you save) or PSD, you can go to image > mode > multichannel, and try saving it as a DCS2.0. The printer might have better luck with this (but try TIF or PSD first).
    If the printer can't handle a file like this, your next bet is a CMYK file where the black channel holds the black in values, and the C, M or Y channel holds the spot values. Then anything else in the layout file that should be spot needs to be painted C, M or Y.

  • 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

  • I can convert almost things multiple times at the same time including CMYK to RGB (or sRGB), but not RGB to CMYK and not brighten/contrast. How?

    I can convert almost things multiple times at the same time including CMYK to RGB (or sRGB), but not RGB to CMYK and not brighten/contrast. How?

    If you want a relevant answer you may have to elaborate on what you actually mean. Posting screenshots might help, too.
    In any case multiple conversions of an image are not advisable in general.

Maybe you are looking for