-
-
Save jjulian/5dd2963c3b3a520ab311 to your computer and use it in GitHub Desktop.
Photoshop script to output iOS icons, now with iOS 8 sizes
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
// Output iOS Icons.jsx | |
// 2014 Todd Linkner | |
// License: none (public domain) | |
// v1.2 | |
// | |
// This script is for Photoshop CS6. It outputs iOS icons | |
// from a source 1024px x 1024px PSD | |
// | |
// bring Photoshop into focus | |
#target Photoshop | |
main(); | |
function main() { | |
alert("This script outputs iPhone, iPad, and iTunes icons, " | |
+ "from a 1024px x 1024px PSD source file.\r\r"); | |
// Ask user for input folder | |
var inputFile = File.openDialog("Select a 1024px x 1024px PSD file","PSD File:*.psd"); | |
if (inputFile == null) throw "No file selected. Exting script."; | |
// Open file | |
open(inputFile); | |
// Set ruler untis to pixels | |
app.preferences.typeUnits = TypeUnits.PIXELS | |
// iOS 5-8 and Apple Watch Icons | |
resize(24,2); | |
resize(27.5,2); | |
resize(29,1); | |
resize(29,2); | |
resize(29,3); | |
resize(40,1); | |
resize(40,2); | |
resize(40,3); | |
resize(44,2); | |
resize(50,1); | |
resize(50,2); | |
resize(57,1); | |
resize(57,2); | |
resize(60,2); | |
resize(60,3); | |
resize(72,1); | |
resize(72,2); | |
resize(76,1); | |
resize(76,2); | |
resize(86,2); | |
resize(98,2); | |
resize(512,1); | |
resize(512,2); | |
// Clean up | |
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); | |
alert("Done!"); | |
} | |
function resize(size,scaleFactor) { | |
// Setup file name | |
var pname = app.activeDocument.path + "/"; | |
var fname = app.activeDocument.name; | |
var append = ""; | |
var fsize = size * scaleFactor; | |
if (scaleFactor > 1) { | |
append = "@" + scaleFactor + "x"; | |
} | |
n = fname.lastIndexOf("."); | |
if (n > 0) { | |
var basename = fname.substring(0,n); | |
fname = basename+"-"+size+append+".png"; | |
} | |
// Set export options | |
var opts, file; | |
opts = new ExportOptionsSaveForWeb(); | |
opts.format = SaveDocumentType.PNG; | |
opts.PNG8 = false; | |
opts.transparency = true; | |
opts.interlaced = 0; | |
opts.includeProfile = false; | |
opts.optimized = true; | |
// Duplicate, resize and export | |
var tempfile = app.activeDocument.duplicate(); | |
tempfile.resizeImage(fsize+"px",fsize+"px"); | |
file = new File(pname+fname); | |
tempfile.exportDocument(file, ExportType.SAVEFORWEB, opts); | |
tempfile.close(SaveOptions.DONOTSAVECHANGES); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment