Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Illustrator automation script for exporting an icon artboard to all the sizes needed for iOS apps.
var destFolder = null;
destFolder = Folder.selectDialog( 'Select the folder where you want to save the exported files.', app.activeDocument.path );
var baseDestName = app.activeDocument.name;
if (baseDestName.indexOf('.') < 0)
{
//nothing
} else {
var dot = baseDestName.lastIndexOf('.');
baseDestName = baseDestName.substring(0, dot);
}
var activeArtboard = app.activeDocument.artboards[app.activeDocument.artboards.getActiveArtboardIndex()];
if (destFolder != null)
{
exportFileToPNG24(29,"Icon-Small");
exportFileToPNG24(50,"Icon-Small-50");
exportFileToPNG24(57,"Icon");
exportFileToPNG24(58,"Icon-Small@2x");
exportFileToPNG24(72,"Icon-72");
exportFileToPNG24(114,"Icon@2x");
exportFileToPNG24(512,"iTunesArtwork");
}
function exportFileToPNG24(iconSize, name)
{
var scale = iconSize / activeArtboard.artboardRect[2] * 100;
if ( app.documents.length > 0 )
{
var exportOptions = new ExportOptionsPNG24();
var type = ExportType.PNG24;
var fileSpec = new File ("" + destFolder + "/" + name );
exportOptions.verticalScale = scale;
exportOptions.horizontalScale = scale;
exportOptions.antiAliasing = true;
exportOptions.transparency = true;
exportOptions.artBoardClipping = true;
app.activeDocument.exportFile (fileSpec, type, exportOptions);
}
}
@alvarix

This comment has been minimized.

Copy link

@alvarix alvarix commented Dec 4, 2012

Hi,
I tried using this on CS5, and it export all the assets at the same size (100%)

@Captnwalker1

This comment has been minimized.

Copy link

@Captnwalker1 Captnwalker1 commented Jul 25, 2013

Dude effing amazing, really get sick of hitting save for web & devices 10x

This worked fine for me in CS5 on Mac

@reubenpressman

This comment has been minimized.

Copy link

@reubenpressman reubenpressman commented Aug 23, 2014

AWESOME! Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment