// 2017, use it at your own risk; #target photoshop if (app.documents.length > 0) { var myDocument = activeDocument; var originalUnits = app.preferences.rulerUnits; app.preferences.rulerUnits = Units.PIXELS; var theWidth = myDocument.width; var theHeight = myDocument.height; if (theWidth <= 1000) {unsharpMask (120, 1, 5)}; if (theWidth > 1000 && theWidth <= 2000) {unsharpMask (120, 2, 5)}; if (theWidth > 2000) {unsharpMask (120, 4, 5)}; app.preferences.rulerUnits = originalUnits; }; ////// unsharp mask ////// function unsharpMask (amount, radius, threshold) { // ======================================================= var idUnsM = charIDToTypeID( "UnsM" ); var desc2 = new ActionDescriptor(); var idAmnt = charIDToTypeID( "Amnt" ); var idPrc = charIDToTypeID( "#Prc" ); desc2.putUnitDouble( idAmnt, idPrc, amount ); var idRds = charIDToTypeID( "Rds " ); var idPxl = charIDToTypeID( "#Pxl" ); desc2.putUnitDouble( idRds, idPxl, radius ); var idThsh = charIDToTypeID( "Thsh" ); desc2.putInteger( idThsh, threshold ); executeAction( idUnsM, desc2, DialogModes.NO); }; |