Last active
January 6, 2016 22:05
-
-
Save TylerJPresley/a8ebc9d903aa56d9463d to your computer and use it in GitHub Desktop.
This Photoshop script helps me generate ~100 icons that get used in various places. All the layers in the PSD are smart objects that can be easily resized without getting distorted.
This file contains hidden or 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
#target photoshop | |
// | |
// StrengthenIconExport.jsx | |
// | |
// | |
// Generated Sat Jan 02 2016 14:20:45 GMT-0600 | |
// | |
cTID = function(s) { return app.charIDToTypeID(s); }; | |
sTID = function(s) { return app.stringIDToTypeID(s); }; | |
// | |
// StrengthenIconExport | |
// | |
var iconSizes = [1024,512,256,192,180,167,160,152,144,120,114,96,87,80,76,72,60,58,57,48,40,36,32,29]; | |
var outputDir = "/Users/TylerJPresley/Desktop/icons/"; | |
for (var i = 0, j = iconSizes.length; i < j; i++) { | |
// Show | |
function step1(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "trd - full"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Shw '), desc1, dialogMode); | |
}; | |
// Image Size | |
function step2(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
desc1.putUnitDouble(cTID('Wdth'), cTID('#Pxl'), iconSizes[i]); | |
desc1.putBoolean(sTID("scaleStyles"), true); | |
desc1.putBoolean(cTID('CnsP'), true); | |
desc1.putEnumerated(cTID('Intr'), cTID('Intp'), sTID("automaticInterpolation")); | |
executeAction(sTID('imageSize'), desc1, dialogMode); | |
}; | |
// Save | |
function step3(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var desc2 = new ActionDescriptor(); | |
desc2.putEnumerated(sTID("PNGInterlaceType"), sTID("PNGInterlaceType"), sTID("PNGInterlaceNone")); | |
desc2.putEnumerated(sTID("PNGFilter"), sTID("PNGFilter"), sTID("PNGFilterAdaptive")); | |
desc2.putInteger(cTID('Cmpr'), 9); | |
desc1.putObject(cTID('As '), sTID("PNGFormat"), desc2); | |
desc1.putPath(cTID('In '), new File(outputDir + "icon-" + iconSizes[i] + "-trd-full")); | |
desc1.putInteger(cTID('DocI'), 1248); | |
desc1.putBoolean(cTID('Cpy '), true); | |
desc1.putBoolean(cTID('LwCs'), true); | |
executeAction(cTID('save'), desc1, dialogMode); | |
}; | |
// Hide | |
function step4(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "trd - full"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Hd '), desc1, dialogMode); | |
}; | |
// Show | |
function step5(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "trw - full"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Shw '), desc1, dialogMode); | |
}; | |
// Save | |
function step6(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var desc2 = new ActionDescriptor(); | |
desc2.putEnumerated(sTID("PNGInterlaceType"), sTID("PNGInterlaceType"), sTID("PNGInterlaceNone")); | |
desc2.putEnumerated(sTID("PNGFilter"), sTID("PNGFilter"), sTID("PNGFilterAdaptive")); | |
desc2.putInteger(cTID('Cmpr'), 9); | |
desc1.putObject(cTID('As '), sTID("PNGFormat"), desc2); | |
desc1.putPath(cTID('In '), new File(outputDir + "icon-" + iconSizes[i] + "-trw-full")); | |
desc1.putInteger(cTID('DocI'), 1248); | |
desc1.putBoolean(cTID('Cpy '), true); | |
desc1.putBoolean(cTID('LwCs'), true); | |
executeAction(cTID('save'), desc1, dialogMode); | |
}; | |
// Hide | |
function step7(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "trw - full"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Hd '), desc1, dialogMode); | |
}; | |
// Show | |
function step8(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "trw"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Shw '), desc1, dialogMode); | |
}; | |
// Save | |
function step9(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var desc2 = new ActionDescriptor(); | |
desc2.putEnumerated(sTID("PNGInterlaceType"), sTID("PNGInterlaceType"), sTID("PNGInterlaceNone")); | |
desc2.putEnumerated(sTID("PNGFilter"), sTID("PNGFilter"), sTID("PNGFilterAdaptive")); | |
desc2.putInteger(cTID('Cmpr'), 9); | |
desc1.putObject(cTID('As '), sTID("PNGFormat"), desc2); | |
desc1.putPath(cTID('In '), new File(outputDir + "icon-" + iconSizes[i] + "-trw")); | |
desc1.putInteger(cTID('DocI'), 1248); | |
desc1.putBoolean(cTID('Cpy '), true); | |
desc1.putBoolean(cTID('LwCs'), true); | |
executeAction(cTID('save'), desc1, dialogMode); | |
}; | |
// Hide | |
function step10(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "trw"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Hd '), desc1, dialogMode); | |
}; | |
// Show | |
function step11(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "trd"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Shw '), desc1, dialogMode); | |
}; | |
// Save | |
function step12(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var desc2 = new ActionDescriptor(); | |
desc2.putEnumerated(sTID("PNGInterlaceType"), sTID("PNGInterlaceType"), sTID("PNGInterlaceNone")); | |
desc2.putEnumerated(sTID("PNGFilter"), sTID("PNGFilter"), sTID("PNGFilterAdaptive")); | |
desc2.putInteger(cTID('Cmpr'), 9); | |
desc1.putObject(cTID('As '), sTID("PNGFormat"), desc2); | |
desc1.putPath(cTID('In '), new File(outputDir + "icon-" + iconSizes[i] + "-trd")); | |
desc1.putInteger(cTID('DocI'), 1248); | |
desc1.putBoolean(cTID('Cpy '), true); | |
desc1.putBoolean(cTID('LwCs'), true); | |
executeAction(cTID('save'), desc1, dialogMode); | |
}; | |
// Show | |
function step13(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "BG - rd"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Shw '), desc1, dialogMode); | |
}; | |
// Save | |
function step14(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var desc2 = new ActionDescriptor(); | |
desc2.putEnumerated(sTID("PNGInterlaceType"), sTID("PNGInterlaceType"), sTID("PNGInterlaceNone")); | |
desc2.putEnumerated(sTID("PNGFilter"), sTID("PNGFilter"), sTID("PNGFilterAdaptive")); | |
desc2.putInteger(cTID('Cmpr'), 9); | |
desc1.putObject(cTID('As '), sTID("PNGFormat"), desc2); | |
desc1.putPath(cTID('In '), new File(outputDir + "icon-" + iconSizes[i] + "-rd")); | |
desc1.putInteger(cTID('DocI'), 1248); | |
desc1.putBoolean(cTID('Cpy '), true); | |
desc1.putBoolean(cTID('LwCs'), true); | |
executeAction(cTID('save'), desc1, dialogMode); | |
}; | |
// Hide | |
function step15(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "BG - rd"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Hd '), desc1, dialogMode); | |
}; | |
// Show | |
function step16(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "BG - rdsq"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Shw '), desc1, dialogMode); | |
}; | |
// Save | |
function step17(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var desc2 = new ActionDescriptor(); | |
desc2.putEnumerated(sTID("PNGInterlaceType"), sTID("PNGInterlaceType"), sTID("PNGInterlaceNone")); | |
desc2.putEnumerated(sTID("PNGFilter"), sTID("PNGFilter"), sTID("PNGFilterAdaptive")); | |
desc2.putInteger(cTID('Cmpr'), 9); | |
desc1.putObject(cTID('As '), sTID("PNGFormat"), desc2); | |
desc1.putPath(cTID('In '), new File(outputDir + "icon-" + iconSizes[i] + "-rdsq")); | |
desc1.putInteger(cTID('DocI'), 1248); | |
desc1.putBoolean(cTID('Cpy '), true); | |
desc1.putBoolean(cTID('LwCs'), true); | |
executeAction(cTID('save'), desc1, dialogMode); | |
}; | |
// Hide | |
function step18(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "BG - rdsq"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Hd '), desc1, dialogMode); | |
}; | |
// Show | |
function step19(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "BG - sq"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Shw '), desc1, dialogMode); | |
}; | |
// Save | |
function step20(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var desc2 = new ActionDescriptor(); | |
desc2.putEnumerated(sTID("PNGInterlaceType"), sTID("PNGInterlaceType"), sTID("PNGInterlaceNone")); | |
desc2.putEnumerated(sTID("PNGFilter"), sTID("PNGFilter"), sTID("PNGFilterAdaptive")); | |
desc2.putInteger(cTID('Cmpr'), 9); | |
desc1.putObject(cTID('As '), sTID("PNGFormat"), desc2); | |
desc1.putPath(cTID('In '), new File(outputDir + "icon-" + iconSizes[i] + "-sq")); | |
desc1.putInteger(cTID('DocI'), 1248); | |
desc1.putBoolean(cTID('Cpy '), true); | |
desc1.putBoolean(cTID('LwCs'), true); | |
executeAction(cTID('save'), desc1, dialogMode); | |
}; | |
// Hide | |
function step21(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "BG - sq"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Hd '), desc1, dialogMode); | |
}; | |
// Hide | |
function step22(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "trd"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Hd '), desc1, dialogMode); | |
}; | |
step1(); // Show | |
step2(); // Image Size | |
step3(); // Save | |
step4(); // Hide | |
step5(); // Show | |
step6(); // Save | |
step7(); // Hide | |
step8(); // Show | |
step9(); // Save | |
step10(); // Hide | |
step11(); // Show | |
step12(); // Save | |
step13(); // Show | |
step14(); // Save | |
step15(); // Hide | |
step16(); // Show | |
step17(); // Save | |
step18(); // Hide | |
step19(); // Show | |
step20(); // Save | |
step21(); // Hide | |
step22(); // Hide | |
} | |
function favicon () { | |
// Show | |
function step1(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "trd - full"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Shw '), desc1, dialogMode); | |
}; | |
// Image Size | |
function step2(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
desc1.putUnitDouble(cTID('Wdth'), cTID('#Pxl'), 16); | |
desc1.putBoolean(sTID("scaleStyles"), true); | |
desc1.putBoolean(cTID('CnsP'), true); | |
desc1.putEnumerated(cTID('Intr'), cTID('Intp'), sTID("automaticInterpolation")); | |
executeAction(sTID('imageSize'), desc1, dialogMode); | |
}; | |
// Save | |
function step3(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var desc2 = new ActionDescriptor(); | |
desc2.putEnumerated(sTID("PNGInterlaceType"), sTID("PNGInterlaceType"), sTID("PNGInterlaceNone")); | |
desc2.putEnumerated(sTID("PNGFilter"), sTID("PNGFilter"), sTID("PNGFilterAdaptive")); | |
desc2.putInteger(cTID('Cmpr'), 9); | |
desc1.putObject(cTID('As '), sTID("PNGFormat"), desc2); | |
desc1.putPath(cTID('In '), new File(outputDir + "favicon")); | |
desc1.putInteger(cTID('DocI'), 1248); | |
desc1.putBoolean(cTID('Cpy '), true); | |
desc1.putBoolean(cTID('LwCs'), true); | |
executeAction(cTID('save'), desc1, dialogMode); | |
}; | |
// Hide | |
function step4(enabled, withDialog) { | |
if (enabled != undefined && !enabled) | |
return; | |
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); | |
var desc1 = new ActionDescriptor(); | |
var list1 = new ActionList(); | |
var ref1 = new ActionReference(); | |
ref1.putName(cTID('Lyr '), "trd - full"); | |
list1.putReference(ref1); | |
desc1.putList(cTID('null'), list1); | |
executeAction(cTID('Hd '), desc1, dialogMode); | |
}; | |
step1(); // Show | |
step2(); // Image Size | |
step3(); // Save | |
step4(); // Hide | |
} | |
favicon(); | |
// EOF | |
"StrengthenIconExport.jsx" | |
// EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment