#target photoshop // // SNIPPING!.jsx // // // Generated Fri Oct 05 2012 18:26:07 GMT+0900 // cTID = function(s) { return app.charIDToTypeID(s); }; sTID = function(s) { return app.stringIDToTypeID(s); }; // //==================== SNIPPING ============== // function SNIPPING() { // Duplicate function step1(enabled, withDialog) { if (enabled != undefined && !enabled) return; var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); var desc1 = new ActionDescriptor(); var ref1 = new ActionReference(); ref1.putEnumerated(cTID('Dcmn'), cTID('Ordn'), cTID('Frst')); desc1.putReference(cTID('null'), ref1); executeAction(cTID('Dplc'), desc1, dialogMode); }; // Show function step2(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.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt')); list1.putReference(ref1); desc1.putList(cTID('null'), list1); desc1.putBoolean(cTID('TglO'), true); executeAction(cTID('Shw '), desc1, dialogMode); }; // Trim function step3(enabled, withDialog) { if (enabled != undefined && !enabled) return; var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); var desc1 = new ActionDescriptor(); desc1.putEnumerated(sTID("trimBasedOn"), sTID("trimBasedOn"), cTID('Trns')); desc1.putBoolean(cTID('Top '), true); desc1.putBoolean(cTID('Btom'), true); desc1.putBoolean(cTID('Left'), true); desc1.putBoolean(cTID('Rght'), true); executeAction(sTID('trim'), desc1, dialogMode); }; function step4(enabled, withDialog) { while (activeDocument.height % 4 != 0) { activeDocument.resizeCanvas (activeDocument.width,activeDocument.height+1); } while (activeDocument.width % 4 != 0) { activeDocument.resizeCanvas (activeDocument.width+1,activeDocument.height); } }; // Duplicate function step5(enabled, withDialog) { if (enabled != undefined && !enabled) return; var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); var desc1 = new ActionDescriptor(); var ref1 = new ActionReference(); ref1.putEnumerated(cTID('Dcmn'), cTID('Ordn'), cTID('Frst')); desc1.putReference(cTID('null'), ref1); executeAction(cTID('Dplc'), desc1, dialogMode); }; // Image Size function step6(enabled, withDialog) { if (enabled != undefined && !enabled) return; var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); var desc1 = new ActionDescriptor(); desc1.putUnitDouble(cTID('Wdth'), cTID('#Prc'), 75); desc1.putBoolean(sTID("scaleStyles"), true); desc1.putBoolean(cTID('CnsP'), true); desc1.putEnumerated(cTID('Intr'), cTID('Intp'), sTID("bicubicAutomatic")); executeAction(sTID('imageSize'), desc1, dialogMode); }; step1(); // Duplicate step2(); // Show step3(); // Trim step4(); // Optimize step5(); // Duplicate step6(); // Image Size }; //========================================= // SNIPPING.main //========================================= // SNIPPING.main = function () { SNIPPING(); }; SNIPPING.main(); // EOF "SNIPPING!.jsx" // EOF