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

How does Illustrator’s Color Picker compute HSB and CMYK values?

Community Beginner ,
Apr 24, 2021 Apr 24, 2021

Copy link to clipboard

Copied

I have a Illustrator document with default RGB color mode. The Color Picker displays the RGB values of selected object and it also displays HSB (Hue, Saturation, Brightness) and CMYK (Cyan, Magenta, Yellow) values of the selected object. But I do not understand how Illustrator calculates these (HSB and CMYK) values. I found RGB-to... conversion functions on the web which all seem to be based on the same algos (for example: https://gist.github.com/felipesabino/5066336 ) but the CMYK and HSB value obtained with these do not match with the values from Color Picker ? Can anybody please tell me how (algo?) Illustrator calculates the HSB and CMYK values from the RGB values in the Color Picker?

So far I understood that RGB to CMYK conversion depends on the type of printer which is used, but I thought that, as long as there is no printer selected the RGB to CMYK shall follow a default scheme/algo? I’m asking for help because I would like to use the HSB and CMYK values which are displayed in the Color Picker as guidelines for manually mixing colors for hobby painting purposes (on a ‘real’ palette and canvas). I found the CMYK and HSB values displayed in the Color Picker more realistic than the ones computed by the algo from URL above, for example for RGB color R=246 G=109 B=164 the Color Picker displays S=55%, B=96%, C=0%, M=70%, Y=3% K=0% whereas the algo from URL above calculates/converts to C=0%, M=54%, Y=32%, K=4% ?

Actually, I have a little JavaScript which creates a separate, dedicated Illustrator document which I call “color palette” document. The script creates as many squares filled with unique colors (associated with text labels indicating the ID of the color) as colors used in the original document. I would like to add additional text labels per color square to indicate CMYK and HSB values, ideally these calculated internally and displayed by the Color Picker but I don’t know how these are calculated.

Many thanks in advance for your time and advice!

TOPICS
Draw and design , Print and publish , Scripting

Views

1.5K

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 3 Correct answers

LEGEND , Apr 26, 2021 Apr 26, 2021

JavaScript has no colour management, the RGB values are just to be delivered to an output. To match the conversion done by colour managed apps you need to what they do: use a CMM (Colour Management Module), which takes input profile, output profile and rendering intent to make a conversion environment. I have never heard of a JavaScript API to any CMM. On Windows, the ICM2 system component will do this. On Mac, ColorSync will do this (though the documentation is abysmal).

Votes

Translate

Translate
Valorous Hero , Apr 28, 2021 Apr 28, 2021

Use app.convertSampleColor()

Votes

Translate

Translate
LEGEND , Aug 15, 2022 Aug 15, 2022

Happily HSB is actually defined as a simple mathematical transform of RGB. So there is no such thing, for example, as an HSB profile; HSB is always qualified by the RGB space it is transformed from. Just convert to RGB with suitable profile, and then use the standard formula to convert to HSB. 

Votes

Translate

Translate
Adobe
LEGEND ,
Apr 24, 2021 Apr 24, 2021

Copy link to clipboard

Copied

"I found RGB-to... conversion functions on the web which all seem to be based on the same algos (for example: https://gist.github.com/felipesabino/5066336 " Yes, these are ALL WRONG . Every web page, I have ever seen to make this conversion is wrong. These are made by people who can read a formula, but do not understand color management.

 

Conversion depends on the RGB and CMYK profile in use. Sites which offer to convert without choosing a profile are like - well, like a site offering to convert between currencies without asking you the currency! "Hey, 3.00 is worth 7.54! That's great, What currency? I don't know, some currency or other."

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 ,
Apr 24, 2021 Apr 24, 2021

Copy link to clipboard

Copied

I love this comparison.

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 ,
Apr 24, 2021 Apr 24, 2021

Copy link to clipboard

Copied

I looked at your code. Part of RGB to CMYK processing is this:


result.k = Math.min( 1 - r, 1 - g, 1 - b );
result.c = ( 1 - r - result.k ) / ( 1 - result.k );
result.m = ( 1 - g - result.k ) / ( 1 - result.k );
result.y = ( 1 - b - result.k ) / ( 1 - result.k );

 

This is nice simple code. I know, I have used it myself. But from the point of view of colour accuracy it is a joke. (Sadly, a joke repeated all over the internet, and it doesn't get any funnier). It supposes (for example) that RGB cyan and CMYK cyan are equivalent colours. Well, only from the point of view of the person looking for easy code. Anyone who ever printed anything will know this is just false.

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 Beginner ,
Apr 26, 2021 Apr 26, 2021

Copy link to clipboard

Copied

Hi and thank you all for your replies! I have one more question: I wonder if its possible to get CMYK and HSB values of shapes in my javascript ? It’s actually possible/easy to get values for RGB using RGBColor type:

 

var fill_color = new RGBColor();

fill_color = selectedItems[i].fillColor;

color_string = fill_color.red.toString() + "_" + fill_color.green.toString() + "_" + fill_color.blue.toString();

 

but it seems there is no such equivalent  CMYL or HSB color type in JavaScrip Object reference ?

 

Thank you in advance for your help! Kind regards

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 ,
Apr 26, 2021 Apr 26, 2021

Copy link to clipboard

Copied

JavaScript has no colour management, the RGB values are just to be delivered to an output. To match the conversion done by colour managed apps you need to what they do: use a CMM (Colour Management Module), which takes input profile, output profile and rendering intent to make a conversion environment. I have never heard of a JavaScript API to any CMM. On Windows, the ICM2 system component will do this. On Mac, ColorSync will do this (though the documentation is abysmal).

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
Valorous Hero ,
Apr 28, 2021 Apr 28, 2021

Copy link to clipboard

Copied

Use app.convertSampleColor()

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

I'm not seeing HSB as one of the ColorSpace options. Maybe it's undocumented?

 

nicholascombs_0-1660588143107.png

 

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

Happily HSB is actually defined as a simple mathematical transform of RGB. So there is no such thing, for example, as an HSB profile; HSB is always qualified by the RGB space it is transformed from. Just convert to RGB with suitable profile, and then use the standard formula to convert to HSB. 

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

LATEST

Cool, thanks!

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