forked from wooster/iPhone-Photoshop-JSX-Icon-Exporter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiOS - Create All iPhone Icons.jsx
104 lines (73 loc) · 4.75 KB
/
iOS - Create All iPhone Icons.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/***********************************************************************
iPhone App Icon Export for iPhone 4/3 Touch and iPad.
Creates all 6 icons sizes that are required for these devices from homescreen, retina display, spotlight search
1. To use this script, double click the script file, photoshop will launch and ask you for a 512x512 icon file of any image format (jpeg, psd, gif, png etc.)
2. Select the file and photos shop will create 6 icon files and save these with the correct names in the save folder as the 512 image.
3. Add these images into your iPhone project and update you app plist.
Read Apples Q&Q 1686 on how to add this icons to your info plist
http://developer.apple.com/iphone/library/qa/qa2010/qa1686.html
Hope you like this script, hit John Ballinger up on Twitter @sponno on from his website www.bluespark.co.nz
Please keep this Attribution here if you are going to redistrubte this code. Thanks
Creative Commons Attribution 3.0 New Zealand License
http://creativecommons.org/licenses/by/3.0/nz/
************************************************************************/
//set unit preferences
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
/////////////////////////////////////////////////////////////////////////////////////////////
//create a new slideshow package
function doResizeAndOutput()
{
// Select Icon file
var file = File.openDialog("Select your iPhone icon file, this should be 512 by 512 for best results, your new icon files will be saved here as well.", /\.(jpe|jpg|jpeg|gif|png|tif|tiff|bmp|psd)/i);
if(file == null) return; // cancelled.
app.open(file);
var path = file.absoluteURI.substr(0,file.absoluteURI.lastIndexOf("/")+1);
// Check document resolution
if(activeDocument.resolution!=72){
activeDocument.resizeImage(null,activeDocument.height,72,ResampleMethod.BICUBIC);
}
// Png Save Options
var pngOptions = new PNGSaveOptions();
pngOptions.interlaced = false;
// Resize icons from largest to smallest - to preserve quality on resizing.
/*
[email protected] - 114x114 pixels application icon for high resolution iPhone 4
Icon-72.png - 72x72 pixels application icon for iPad
[email protected] - 58x58 pixels settings icon for high resolution iPhone
Icon.png - 57x57 pixels application icon for standard resolution iPhone
Icon-Small-50.png - 50x50 pixels settings icon for iPad
Icon-Small.png - 29x29 pixels settings icon for standard resolution iPhone
*/
// 114
activeDocument.resizeImage(null,114,114,ResampleMethod.BICUBIC);
activeDocument.saveAs(File(path + "/[email protected]"), pngOptions, true);
// Undo Resize so we are working with crisp resizing.
app.activeDocument.activeHistoryState = app.activeDocument.historyStates[app.activeDocument.historyStates.length - 2];
activeDocument.resizeImage(null,72,72,ResampleMethod.BICUBIC);
activeDocument.saveAs(File(path + "/Icon-72.png"), pngOptions, true);
// Undo Resize so we are working with crisp resizing.
app.activeDocument.activeHistoryState = app.activeDocument.historyStates[app.activeDocument.historyStates.length - 2];
// Updated for Xcode 4, this has changed from the spec, but is required for validation
activeDocument.resizeImage(null,57,57,ResampleMethod.BICUBIC);
activeDocument.saveAs(File(path + "/[email protected]"), pngOptions, true);
// Undo Resize so we are working with crisp resizing.
app.activeDocument.activeHistoryState = app.activeDocument.historyStates[app.activeDocument.historyStates.length - 2];
activeDocument.resizeImage(null,57,57,ResampleMethod.BICUBIC);
activeDocument.saveAs(File(path + "/Icon.png"), pngOptions, true);
// Undo Resize so we are working with crisp resizing.
app.activeDocument.activeHistoryState = app.activeDocument.historyStates[app.activeDocument.historyStates.length - 2];
activeDocument.resizeImage(null,50,50,ResampleMethod.BICUBIC);
activeDocument.saveAs(File(path + "/Icon-Small-50.png"), pngOptions, true);
// Undo Resize so we are working with crisp resizing.
app.activeDocument.activeHistoryState = app.activeDocument.historyStates[app.activeDocument.historyStates.length - 2];
activeDocument.resizeImage(null,29,29,ResampleMethod.BICUBIC);
activeDocument.saveAs(File(path + "/Icon-Small.png"), pngOptions, true);
// Close file
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
alert("Done\nAll the new icons have been saved beside your original icons.")
}
//create the slideshow source files
doResizeAndOutput();