Skip to main content
Known Participant
September 11, 2023
Answered

Illustrator script that will convert all SPOT colors to Process (CMYK)

  • September 11, 2023
  • 2 replies
  • 2540 views

I have a bunch of multi colored logos that i need to convert. they will come to me as spot colors

 

does anybody have a script that will convert all spot colors in an illustrator doc to process...

and after that i willl need to convert all process colors to RGB. 

 

scott

 

This topic has been closed for replies.
Correct answer Sergey Osokin

Based on the topic https://community.adobe.com/t5/illustrator-discussions/how-to-change-spot-color-to-process-cmyk-by-disabling-global-option/m-p/3345667 with improvements. You can set the name suffix in the variable. We cannot change the Color Type directly, but we can create a new Process color with values from Spot, and then delete Spot.

//@target illustrator
main();

function main() {
  var suffix = '_CMYK';
  var isRmvSpot = true; // true of false

  var doc = app.activeDocument;
  var len = doc.spots.length;
  var isRgb = /rgb/i.test(doc.documentColorSpace);

  for (var i = 0; i <= len - 1; i++) {
    if (doc.spots[i].colorType === ColorModel.REGISTRATION) continue;
    var spotName = doc.spots[i].name;
    var spotValue = doc.spots[i].getInternalColor();
    var sw = doc.swatches.add();
    sw.name = spotName + suffix;
    var newColor = setColor(spotValue, isRgb);
    sw.color = newColor;
  }

  if (isRmvSpot && len > 0) doc.spots.removeAll();
}

function setColor(arr, isRgb) {
  var color = isRgb ? new RGBColor() : new CMYKColor();
  if (isRgb) {
    color.red = arr[0];
    color.green = arr[1];
    color.blue = arr[2];
  } else {
    color.cyan = arr[0];
    color.magenta = arr[1];
    color.yellow = arr[2];
    color.black = arr[3];
  }
  return color;
}

 

2 replies

Sergey Osokin
Inspiring
September 12, 2023

Do you mean process colors with the Global checkbox checked or unchecked? Should the original spot colors remain in the Swatches panel or be deleted? Are the source documents in CMYK mode?

@Js1212Author
Known Participant
September 12, 2023

in the swatch panel i need the color type to change from Spot Color  to Process color. It will have the global color unchecked and that is how it shoud remain.

the name of the color in the swatches panel should change (if possible but not mandatory) to reflect that it is a process color by appending the existing color name with something like "_PROCESS" or "_CMYK"

Sergey Osokin
Sergey OsokinCorrect answer
Inspiring
September 12, 2023

Based on the topic https://community.adobe.com/t5/illustrator-discussions/how-to-change-spot-color-to-process-cmyk-by-disabling-global-option/m-p/3345667 with improvements. You can set the name suffix in the variable. We cannot change the Color Type directly, but we can create a new Process color with values from Spot, and then delete Spot.

//@target illustrator
main();

function main() {
  var suffix = '_CMYK';
  var isRmvSpot = true; // true of false

  var doc = app.activeDocument;
  var len = doc.spots.length;
  var isRgb = /rgb/i.test(doc.documentColorSpace);

  for (var i = 0; i <= len - 1; i++) {
    if (doc.spots[i].colorType === ColorModel.REGISTRATION) continue;
    var spotName = doc.spots[i].name;
    var spotValue = doc.spots[i].getInternalColor();
    var sw = doc.swatches.add();
    sw.name = spotName + suffix;
    var newColor = setColor(spotValue, isRgb);
    sw.color = newColor;
  }

  if (isRmvSpot && len > 0) doc.spots.removeAll();
}

function setColor(arr, isRgb) {
  var color = isRgb ? new RGBColor() : new CMYKColor();
  if (isRgb) {
    color.red = arr[0];
    color.green = arr[1];
    color.blue = arr[2];
  } else {
    color.cyan = arr[0];
    color.magenta = arr[1];
    color.yellow = arr[2];
    color.black = arr[3];
  }
  return color;
}

 

@Js1212Author
Known Participant
September 11, 2023

Also, i want to keep the color names but maybe tag the color _PROCESS  (231_PROCESS)