Skip to main content
Known Participant
November 15, 2012
Answered

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

  • November 15, 2012
  • 1 reply
  • 3013 views

(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

This topic has been closed for replies.
Correct answer Jongware

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.

1 reply

Jongware
Community Expert
JongwareCommunity ExpertCorrect answer
Community Expert
November 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.

Jongware
Community Expert
Community Expert
November 15, 2012

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.

Vamitul
Legend
November 15, 2012

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