Hi, I’m trying to set the zoom level using the UXP API.
However, when setting the zoom level via Alchemist from the UI or Windows hotkeys, it does not fire any events.
The code below is what I am using in CEP, how can I convert to UXP and do the same thing?
function setZoomLevel(_zoomLevel)
{
cTID = function(s) { return app.charIDToTypeID(s); };
var docRes = activeDocument.resolution;
activeDocument.resizeImage( undefined, undefined, 72/(_zoomLevel/100), ResampleMethod.NONE );
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( cTID( "Mn " ), cTID( "MnIt" ), cTID( 'PrnS' ) );
desc.putReference( cTID( "null" ), ref );
executeAction( cTID( "slct" ), desc, DialogModes.NO );
activeDocument.resizeImage( undefined, undefined, docRes, ResampleMethod.NONE );
}
I already have something like this with UXP BatchPlay, but it’s not working as I expected :
const app = require("photoshop");
const ps = app.app;
const constants = app.constants;
async function SetZoomLevel(value){
ps.activeDocument.resizeImage(undefined, undefined, 72/(value/100), constants.ResampleMethod.NONE);
ps.activeDocument.resizeImage(undefined, undefined, ps.activeDocument.resolution, constants.ResampleMethod.NONE);
}