Copy link to clipboard
Copied
Hi, recently I was graciously helped on the Photoshop forum with this script. It showed me that with what I know about JavaScript, I could modify and possibly build some of my own scripts. I have always found the Save For Web dialog to be great. However the going into the options each time is not my favorite thing, especially when I am doing it a lot throughout the day. I always export the same way. I looked around for a script to use Save For Web in a more automated way and sure enough it was out there. This script allows me to do exactly what I want to do. I even could figure out ways to modify it for other formats (it does png I changed to jpg). So now for my real question and why I am in the Illustrator forum. Does anybody have a simple script like the Photoshop one that does Saves For Web for exporting of a single Illustrator artboard? I have seen some of the robust ones, and they are great. However, I want a simple one like the Photoshop script I show. I need it to not interact with a dialog. That way I can automate it with Directory Opus (Windows Explorer replacement). If anybody has or can whip one up, I would appreciate it. If anybody wants me to share how I automate the Photoshop script with Directory Opus just shout. Thanks
Copy link to clipboard
Copied
there are a few ways to export in illustrator, some work better than others depending on the needs
// https://forums.adobe.com/thread/2634256
var idoc = app.activeDocument;
var destPath = "~/Desktop/myExportTest.png"; // save to desktop
var resolution = '72';
var bounds = idoc.artboards[0].artboardRect; // export the whole artboard
exportFileToPNG24 (destPath, resolution, bounds);
function exportFileToPNG24 (destPath, resolution, bounds) {
var fileSpec = new File(destPath);
var captureOpts = new ImageCaptureOptions; // declare capture options, needed to trun on anti-alias
captureOpts.matte = false; // to give transparent areas some color. default is white.
captureOpts.antiAliasing = true; // anti-alias the image
captureOpts.transparency = true;
captureOpts.resolution = resolution; // higher resolutions take longer to save!!!!
app.activeDocument.imageCapture (fileSpec, bounds, captureOpts); // capture the selection
}
Copy link to clipboard
Copied
That is exactly what I was looking for. I have modified it to grab the current Artboard by name. This is super helpful. Thanks
Copy link to clipboard
Copied
Well Illustrator really lacks on export methods and options. Illustrator lacks many options Photoshop does have, atleast for scripting it does.
Also would be nice if we finally could get the "save screens" options to be available for scripting. Seems Adobe is sleeping or there scripting projects is in the fridge.
Copy link to clipboard
Copied
Have you looked at the Asset Export workflow? You can export Art Boards or Assets to multiple resolutions from that one export, even renaming if you like. Think about it, maybe it is enough. Collect assets and export in batches
Copy link to clipboard
Copied
Yes, I think it is great in many ways. However, my workflows these days has me avoiding navigation to save directories and dialogs (too many throughout the day). I rely on Artboards because the Asset Export Panel has never provided a way to export with a clipping mask. I don't know why Adobe has not given lots of users their request. The way I will use a script like this is very quick and efficient. Thanks
Copy link to clipboard
Copied
The asset export can also export based on artboards.
Copy link to clipboard
Copied
Yes fully aware that it can. Thanks so much ![]()
Copy link to clipboard
Copied
Hi there,
Thanks for reaching out. Moving this discussion to Illustrator Scripting​ community so that you can get some responses from our scripting experts.
Regards,
Srishti
Copy link to clipboard
Copied
@srishtib8795206
when is save for screens going to be added to scripting?
illustrator scripting feels like a dinosaur!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now