• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to Get RGB Values from a CMYK Color in the DOM (CS5)

Explorer ,
Nov 15, 2012 Nov 15, 2012

Copy link to clipboard

Copied

(CS5, Actionscript)

Hi all,

I have an InDesign document containing TextFrames whose border colors are specified as a CMYK array.

I would like to be able to get its color specification as its closest RGB equivalent.

Does the InDesign DOM contain a method for doing this for me automatically?  If not, what workarounds are there?

TIA,

mlavie

TOPICS
Scripting

Views

2.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 15, 2012 Nov 15, 2012

Change the color space from ColorSpace.CMYK to ColorSpace.RGB, and ID will do the conversion for you.

Of course this changes the applied colour, so don't forget to reset it back to CMYK when you're done reading.

Votes

Translate

Translate
Community Expert ,
Nov 15, 2012 Nov 15, 2012

Copy link to clipboard

Copied

Change the color space from ColorSpace.CMYK to ColorSpace.RGB, and ID will do the conversion for you.

Of course this changes the applied colour, so don't forget to reset it back to CMYK when you're done reading.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 15, 2012 Nov 15, 2012

Copy link to clipboard

Copied

Ah. This seems to need an addendum.

"ColorSpace" is only available for swatches, it doesn't work directly with 'strokeColor'. So you have to change & examine the applied swatch instead.

Caveat #2 is that if you change CMYK to RGB, read your values, and then change back to CMYK, yo might get different CMYK values! Conversion between CMYK and RGB is not reversible, as color science is not really an accurate science.

So you'll have to work on a copy of your swatch, or use Undo after the change, or close your document without saving.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Nov 15, 2012 Nov 15, 2012

Copy link to clipboard

Copied

sort of on the same subject.. i have to make a function sort of like this:

covertColor =function(/*int*/Red,/*int*/Green,/*int*/Blue)

               {

               //make conversions somehow

          return {cmyk:[C,M,Y,K],

                     gray:PrecentGray}

}

Haven't had time yet to get on it, as i'm still working on other, more urgent parts of the script, but if anyone has something like this already done, and doesn't mind sharing it, i would be grateful.

Thank you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 15, 2012 Nov 15, 2012

Copy link to clipboard

Copied

Here's how to convert RGB to CMYK:

function rgb2CMYK (r,g,b){

    var color = app.documents[0].colors.add({space:ColorSpace.RGB,colorValue:[r,g,b]});

    color.space = ColorSpace.CMYK;

    var retVal = color.colorValue;

    color.remove();

    return retVal;

}

The same idea for the reverse.

For info on converting to grayscale, check out this:

http://in-tools.com/article/scripts-blog/convert-colors-to-grayscal-in-indesign/

HTH,

Harbs

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Nov 15, 2012 Nov 15, 2012

Copy link to clipboard

Copied

Thank you harbs. very informative and very very helpful.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 19, 2012 Nov 19, 2012

Copy link to clipboard

Copied

LATEST

Thanks to Jongware and Harbs. !

I can't believe the solution was so simple - I guess I was expecting some big, bloated .convertColorSpace() method somewhere with a zillion poorly documented parameters...

mlavie

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines