Forked from jeremieweldin/SaveIconsForiOSIcons.jsx
Last active
August 28, 2023 09:17
-
-
Save jeffcollier/7137358 to your computer and use it in GitHub Desktop.
Adobe Illustrator automation script for exporting an icon artboard to all the sizes needed for iOS apps. [I upgraded this hyper-helpful script from Jeremie Weldin for iOS 7 images sizes. To apply, open your icon file in Illustrator, select File | Scripts | Others..., and browser to the directory containing this file. -Jeff]
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) | |
{ | |
// iOS 7 | |
exportFileToPNG24(60,"icon-60"); // iPhone App Icon Non-Retina | |
exportFileToPNG24(120,"icon-60@2x"); // iPhone App Icon | |
exportFileToPNG24(76,"icon-76"); // iPad App Icon Non-Retina | |
exportFileToPNG24(152,"icon-76@2x"); // iPad App Icon | |
exportFileToPNG24(40,"icon-40"); // Spotlight Non-Retina | |
exportFileToPNG24(80,"icon-80@2x"); // Spotlight | |
exportFileToPNG24(29,"icon-Small"); // Settings Non-Retina | |
exportFileToPNG24(58,"icon-Small@2x"); // Settings | |
// iOS 6.1 and Earlier | |
exportFileToPNG24(57,"icon"); // iPhone Non-Retina App Icon | |
exportFileToPNG24(114,"icon@2x"); // iPhone App Icon | |
exportFileToPNG24(72,"icon-72"); // iPad Non-Retina App Icon | |
exportFileToPNG24(144,"icon-72@2x"); // iPad App Icon | |
// iPhone Spotlight and Settings handled by 29 and 58 | |
exportFileToPNG24(50,"icon-50"); // iPad Spotlight and Settings Non-Retina | |
exportFileToPNG24(100,"icon-50@2x"); // iPad Spotlight and Settings | |
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