Copy link to clipboard
Copied
Greetings,
For visuals and as substitute for the following text please view this video
In a nutshell, I'm looking for a way to programmatically convert a given CMYK to LAB which would also respect the color profile referencing the values. So, if the user is set in XCMYK vs SWOPv2 the same CMYK recipe will produce, correctly, two very different LAB values.
Given this, I can then calculate a Delta e 2000 difference between two swatches and create correctly spaced out colors between a given start and end color. Say, a delta e of 1 between each swatch.
Anyone has somewhere to point me to, for a indesign script based approach to converting colors while respecting the color space they reference? Is there already an API for this in InDesign Javascript?
Thank you kindly!
PS: pm me if you want to send you this script I'm writing 🙂
1 Correct answer
If you change the document’s assigned CMYK profile you will get different color managed Lab values by simply changing the color’s space property.
Something like this, where I’m making a new swatch, setting the document’s profile assignment, duping the swatch, get the dup‘s Lab values for the provided CMYK profile, and removing the dup.
var docprof = app.activeDocument.cmykProfile;
var profA = "U.S. Web Coated (SWOP) v2";
var profB = "U.S. Sheetfed Coated v2";
//Create a CMYK color.
...
Copy link to clipboard
Copied
If you change the document’s assigned CMYK profile you will get different color managed Lab values by simply changing the color’s space property.
Something like this, where I’m making a new swatch, setting the document’s profile assignment, duping the swatch, get the dup‘s Lab values for the provided CMYK profile, and removing the dup.
var docprof = app.activeDocument.cmykProfile;
var profA = "U.S. Web Coated (SWOP) v2";
var profB = "U.S. Sheetfed Coated v2";
//Create a CMYK color.
try{
var mycolor = app.activeDocument.colors.add({name:"Red", model:ColorModel.process, colorValue:[20, 100, 100, 0]});
}
catch (e){
var mycolor = app.activeDocument.colors.item("Red");
};
/**
*Get a swatch’s Lab Value
* @param s the swatch
* @param p the CMYK Profile
**/
function getLAB(s, p){
app.activeDocument.cmykProfile = p;
var d = s.duplicate();
d.space = ColorSpace.LAB;
val = d.colorValue;
d.remove();
return val;
}
var lab1 = getLAB(mycolor, profA);
var lab2 = getLAB(mycolor, profB);
$.writeln("SWOP: " + lab1 + "\nSheetfed: " + lab2)
//returns SWOP: 44.9591979980469,62.1322975158691,40.0155982971191
// Sheetfed: 41.3518981933594,56.3812980651855,43.5097007751465
//reset profile
app.activeDocument.cmykProfile = docprof;
If you know some AppleScript you might look at this branding script I wrote that makes a color managed swatch book from Lab spot colors. The link includes the Applescript with annotations
https://community.adobe.com/t5/indesign/branding-color-guide/td-p/10818696?page=1
Copy link to clipboard
Copied
Rob, thank you for this!
If this works I can do the honeycomb pattern swatch explorer ala Fiery (EFI rip) but in a much more useful way.
This is awesome, you've made my week.
Cheers from Vancouver,
Antoine
Copy link to clipboard
Copied
Happy to help. Watch out for the profile name, the string has to be exact.

