Skip to content

Instantly share code, notes, and snippets.

@WhereJuly
Last active October 18, 2022 20:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save WhereJuly/75ee8fd3af4dc3c6466858b2721f9d39 to your computer and use it in GitHub Desktop.
Save WhereJuly/75ee8fd3af4dc3c6466858b2721f9d39 to your computer and use it in GitHub Desktop.
Photoshop: script for zooming in
main();
function main(){
// Change the value between the parentheses below
// into your desired percentage:
setZoomLevel(300);
// Leave the code below unchanged
function setZoomLevel(zoom){
if(zoom < 1) zoom =1;
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var getScreenResolution = executeActionGet(ref).getObjectValue(stringIDToTypeID('unitsPrefs')).getUnitDoubleValue(stringIDToTypeID('newDocPresetScreenResolution'))/72;
var docResolution = activeDocument.resolution;
activeDocument.resizeImage(undefined, undefined, getScreenResolution/(zoom/100), ResampleMethod.NONE);
var desc = new ActionDescriptor();
ref = null;
ref = new ActionReference();
ref.putEnumerated(charIDToTypeID("Mn "), charIDToTypeID("MnIt"), charIDToTypeID('PrnS'));
desc.putReference(charIDToTypeID("null"), ref);
executeAction(charIDToTypeID("slct"), desc, DialogModes.NO);
activeDocument.resizeImage(undefined, undefined, docResolution, ResampleMethod.NONE);};};
@tronelian
Copy link

Thank you so much. It's a big help for me.

@Fitspade
Copy link

Hello, is it possible to do the same thing but on a layer ? I need to zoom on a layer when the user click on a button.. Thank you in advance !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment