Last active
October 18, 2022 20:49
-
-
Save WhereJuly/75ee8fd3af4dc3c6466858b2721f9d39 to your computer and use it in GitHub Desktop.
Photoshop: script for zooming in
This file contains 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
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);};}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 !