Last active
February 22, 2016 13:55
-
-
Save paschmann/79cf978ee76577b0cf52 to your computer and use it in GitHub Desktop.
Script for Photoshop CC 2015 (and probably many more versions) and creates iOS 9 icons, including the iPad Pro
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
// Create iOS 9 Icons.jsx | |
// 2015 Paul Aschmann | |
// v1.0 | |
// [name]-29.png | |
// [name][email protected] | |
// [name][email protected] | |
// [name]-40.png | |
// [name][email protected] | |
// [name][email protected] | |
// [name][email protected] | |
// [name][email protected] | |
// [name]-76.png | |
// [name][email protected] | |
// [name]-167.png | |
// [name]-512.png (512px x 512px) | |
// [name][email protected] (1024px x 1024px) | |
// 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 9 Icons | |
resize(29,1); | |
resize(29,2); | |
resize(29,3); | |
resize(40,1); | |
resize(40,2); | |
resize(40,3); | |
resize(60,2); | |
resize(60,3); | |
resize(76,1); | |
resize(76,2); | |
resize(167,1); | |
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