Skip to content

Instantly share code, notes, and snippets.

@jeremieweldin
Created September 13, 2010 18:31
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save jeremieweldin/577775 to your computer and use it in GitHub Desktop.
Save jeremieweldin/577775 to your computer and use it in GitHub Desktop.
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
Copy link

alvarix commented Dec 4, 2012

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

@Captnwalker1
Copy link

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

This worked fine for me in CS5 on Mac

@reubenpressman
Copy link

AWESOME! Thanks so much!

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