Copy link to clipboard
Copied
Hello,
The question is simple but the solution for me isn't so simple.
An eps-file in Illustrator must be saved as an ai-file with the same name, but the extension must be ai instead of the original eps-file.
Is it also possible to change the color profile from RGB/CMYK/... to grayscale?
The problem is that Illustrator saves the file as undefined.ai instead of the <<original file name>>.ai
#target illustrator
// PART 1 -> OK, this part works
var doc = app.activeDocument;
doc.artboards[0].artboardRect = doc.visibleBounds; //cropt de artboard naar enkel de figuurgrootte
// PART 2 -> don't work
var docName=doc.fullname;
destFolder = doc.path;
var destFile = new File(destFolder + "/" + docName + ".ai"); // make a new file in the dest folder
var options = new IllustratorSaveOptions(); // new save as options
options.compatibility = Compatibility.ILLUSTRATOR15; // save as AI CS5
options.pdfCompatible = true;
options.useCompression = false
doc.saveAs(destFile, options); // save the file in the same foldere as the eps
// PART 3 -> OK, this part works
doc.close(SaveOptions.SAVECHANGES); // close the file with saving
// PART 4 -> change color profile?
I hope that someone can help.
Thanks
Maybe someone can find a solution if there are only path/text objects in you document.(eg: K = 0.3*R + 0.59*G + 0.11*B etc.)
Else, I don't think is possible with Javascript, for example, if you have rasterItem embed, there is no way to change it to grayscale with JS(except re-rasterize).
In Windows, a possibly solution is record a "change to grayscale" action, and call the action from within a VBA script. But I'm not familiar with VBA, sorry.
By the way, isn't all steps can be done with an action?
Copy link to clipboard
Copied
Try this:
#target illustrator // PART 1 -> OK, this part works var doc = app.activeDocument; doc.artboards[0].artboardRect = doc.visibleBounds; //cropt de artboard naar enkel de figuurgrootte // PART 2 -> var destFile = new File(decodeURI(doc.fullName).replace(/(?: \[Converted\])?\.eps$/, '.ai')); // also remove "[Converted]" from filename var options = new IllustratorSaveOptions({}); // new save as options options.compatibility = Compatibility.ILLUSTRATOR15; // save as AI CS5 options.pdfCompatible = false; //I don't like it options.useCompression = true; //I like it doc.saveAs(destFile, options); // save the file in the same foldere as the eps // PART 3 -> OK, this part works doc.close(SaveOptions.SAVECHANGES); // close the file with saving
PART 4 -> change color profile
Do you mean change colorMode? But there is no grayscale colorMode.
Copy link to clipboard
Copied
Fabulous!!
many thanks!
Part 4, see attached screenshot.
First I think, everything must be selected (unlock all layers? > select all > change everything to grayscale)
But, I'm a very Newbie. 😞
Now, everything is or RGB or CMYK, and I hope there is a possibility to change everything to Grayscale.
Of course, I know that unlock all layers, select all, change color to grayscale must be done before saving and before closing the file.
Now, I will begin with analyzing what you have changed on my original poor javascript code...
Many thanks for helpful suggestions.
Copy link to clipboard
Copied
Maybe someone can find a solution if there are only path/text objects in you document.(eg: K = 0.3*R + 0.59*G + 0.11*B etc.)
Else, I don't think is possible with Javascript, for example, if you have rasterItem embed, there is no way to change it to grayscale with JS(except re-rasterize).
In Windows, a possibly solution is record a "change to grayscale" action, and call the action from within a VBA script. But I'm not familiar with VBA, sorry.
By the way, isn't all steps can be done with an action?