Skip to content

Instantly share code, notes, and snippets.

@akamilkhan
Created October 20, 2019 17:33
Show Gist options
  • Save akamilkhan/523235830128bf2cec3f3fb10a4537ff to your computer and use it in GitHub Desktop.
Save akamilkhan/523235830128bf2cec3f3fb10a4537ff to your computer and use it in GitHub Desktop.
Template to achieve units uniformity in Photoshop Script
function main() {
// declare local variables
var orig_ruler_units = app.preferences.rulerUnits;
var orig_type_units = app.preferences.typeUnits;
var orig_display_dialogs = app.displayDialogs;
app.preferences.rulerUnits = Units.PIXELS; // Set the ruler units to PIXELS
app.preferences.typeUnits = TypeUnits.POINTS; // Set Type units to POINTS
app.displayDialogs = DialogModes.NO; // Set Dialogs off
#-----------------------------------------------
###################YOUR CODE START####################
#-----------------------------------------------
try { code(); }
// display error message if something goes wrong
catch(e) { alert(e + ': on line ' + e.line, 'Script Error', true); }
// catch(e){$.writeln(e)}
#-----------------------------------------------
###################YOUR CODE END####################
#-----------------------------------------------
app.displayDialogs = orig_display_dialogs; // Reset display dialogs
app.preferences.typeUnits = orig_type_units; // Reset ruler units to original settings
app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment