Created
September 13, 2010 18:31
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AWESOME! Thanks so much!