Forked from jeremieweldin/SaveIconsForiOSIcons.jsx
Last active
August 29, 2015 14:25
-
-
Save badlands/994bc1a005cd0eff7dd9 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 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(29*2,"Icon-Small@2x"); | |
exportFileToPNG24(29*3,"Icon-Small@3x"); | |
exportFileToPNG24(40,"Icon-Small-40"); | |
exportFileToPNG24(40*2,"Icon-Small-40@2x"); | |
exportFileToPNG24(40*3,"Icon-Small-40@3x"); | |
exportFileToPNG24(50,"Icon-Small-50"); | |
exportFileToPNG24(50*2,"Icon-Small-50@2x"); | |
exportFileToPNG24(50*3,"Icon-Small-50@3x"); | |
exportFileToPNG24(57,"Icon"); | |
exportFileToPNG24(57*2,"Icon@2x"); | |
exportFileToPNG24(60,"Icon-60"); | |
exportFileToPNG24(72,"Icon-72"); | |
exportFileToPNG24(76,"Icon-76"); | |
exportFileToPNG24(76*2,"Icon-76@2x"); | |
exportFileToPNG24(120,"Icon-60@2x"); | |
exportFileToPNG24(144,"Icon-72@2x"); | |
exportFileToPNG24(180,"Icon-60@3x"); | |
exportFileToPNG24(512,"iTunesArtwork"); | |
exportFileToPNG24(512*2,"iTunesArtwork@2x"); | |
} | |
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