Copy link to clipboard
Copied
How to generate swatch values in indesign with script?
Copy link to clipboard
Copied
do you want to add a color to the swatches panel or do you want to modify a given one?
Look into DOM documentation for InDesign:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Color.html#d1e68975
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Colors.html
Here a code sample for adding a named process color in CMYK with C: 100, M: 0, Y: 50, K: 0:
app.documents[0].colors.add
(
{
name : "myColorName" ,
space : ColorSpace.CMYK ,
model : ColorModel.PROCESS ,
colorValue : [ 100 , 0 , 50 , 0 ]
}
);
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
@Laubender Thank you for the reply. I am looking for a script where you can generate the CMYK, RGB and HEX values for the colours. For example there are multiple colours used and I need the CMYK, RGB and HEX values, so with the help of the script I need the values to be generated, where I can use it in Brand Book showing the colour values.
Instead of typing the whole CMYK, RGB and HEX values, with just 1 click of the script I need those.
There is a script for Adobe Illustrator, where you select all the colours whcih are on art board and then you run the script and automatically below the colours we get the CMYK, RGB and HEX values in text format which can be editable.
Thank you.
Copy link to clipboard
Copied
Here is a quick stab at it. It only checks for RGB and CMYK colors, but it should be easy to add in the rest.
Copy link to clipboard
Copied
For example there are multiple colours used and I need the CMYK, RGB and HEX values, so with the help of the script I need the values to be generated, where I can use it in Brand Book showing the colour values.
Hi @innovative_amazement5DC5 , There are a few things you have to consider when attempting to make color conversions either via scripting or the UI. If the source master color is device dependent—either CMYK or RGB—the document’s assigned color profiles will affect the color appearance and conversion values. For example the CMYK color 20|20|20|20 will have a different appearance depending on the assigned CMYK profile—US Sheetfed Coated will have a considerably darker appearnace than US Web Coated SWOP. Also the conversion to RGB would produce different values depending on the destination RGB profile—the conversion to sRGB would be different than the conversion to AdobeRGB.
You might consider defining the master source colors as Lab—the Pantone+ Solid Ink libraries are defined as Lab. A Lab color’s appearance is not affected by the document’s assigned profiles. This thread has more detail and a script option:
https://community.adobe.com/t5/indesign-discussions/branding-color-guide/td-p/10818696
Copy link to clipboard
Copied
@innovative_amazement5DC5 said "… For example there are multiple colours used and I need the CMYK, RGB and HEX values, so with the help of the script I need the values to be generated, where I can use it in Brand Book showing the colour values."
Hm.
Just to clarify, you need the actual values, name, color space, color model, color values, of a given fill color when you e.g. select one or more rectangles. Written to a text frame below the selected objects.
You do not expect any values from color transformations like RGB to CMYK, HSB to CMYK, Lab to CMYK, spot colors to CMYK, don't you?
Regards,
Uwe Laubender
( Adobe Community Expert )
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more