How to use JavaScript to export to PNG/TIFF as multiple assets?
I have a lot of .ai files with logo and I need to export them into PNG files. Is there an antomatic way of doing it? I know you cannot record the export part in Action...
I have a lot of .ai files with logo and I need to export them into PNG files. Is there an antomatic way of doing it? I know you cannot record the export part in Action...
like this?
https://drive.google.com/file/d/1mqULmWWj7SkhSs-eoA1Nc4VuzR4Vc1sW/view?usp=sharing
Hi,
You can use following snippet for your documents. When you run the script it will ask for the folder where source file exists. So select source_files folder in your case and png will be exported at the Desktop.
var _folder = Folder.selectDialog();
if (_folder != null) {
var _files = _folder.getFiles('*.ai');
for (var f = 0; f < _files.length; f++) {
var doc = app.open(_files[f]);
var docAssets = doc.assets;
var assetIDArray = new Array();
var itemToExport = new ExportForScreensItemToExport();
itemToExport.artboards = '';
itemToExport.document = false;
var assetArray = new Array();
var _layer = doc.layers[0];
for (var i = 0; i < _layer.groupItems.length; i++) {
var asset = docAssets.add(doc.groupItems[i]);
assetIDArray.push(asset.assetID);
}
itemToExport.assets = assetIDArray;
var options = new ExportForScreensOptionsPNG24();
app.activeDocument.exportForScreens(File('~/Desktop'), ExportForScreensType.SE_PNG24, options, itemToExport);
}
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.