Answered
Need help with a script to Free Transform a selection (PS 2023)
Is it possible to move and rotate a selection using a script?
If so, I need some hints/help to get started.
Is there already a script that does this ?
Is it possible to move and rotate a selection using a script?
If so, I need some hints/help to get started.
Is there already a script that does this ?
@mangurian – the following code provides an interactive transform of a selection:
try {
if (activeDocument.selection.bounds) {
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
descriptor.putEnumerated(s2t("interfaceIconFrameDimmed"), s2t("interpolationType"), s2t("bicubic"));
executeAction(s2t("transform"), descriptor, DialogModes.ALL);
}
} catch (e) {}
This is the raw code recorded by the SL plug-in, commented to show the values used in the original recording:
var idtransform = stringIDToTypeID( "transform" );
var desc221 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );
var ref17 = new ActionReference();
var idchannel = stringIDToTypeID( "channel" );
var idselection = stringIDToTypeID( "selection" );
ref17.putProperty( idchannel, idselection );
desc221.putReference( idnull, ref17 );
var idfreeTransformCenterState = stringIDToTypeID( "freeTransformCenterState" );
var idquadCenterState = stringIDToTypeID( "quadCenterState" );
var idQCSAverage = stringIDToTypeID( "QCSAverage" );
desc221.putEnumerated( idfreeTransformCenterState, idquadCenterState, idQCSAverage );
var idoffset = stringIDToTypeID( "offset" );
var desc222 = new ActionDescriptor();
var idhorizontal = stringIDToTypeID( "horizontal" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc222.putUnitDouble( idhorizontal, idpixelsUnit, -10 ); // -10px horizontal transform
var idvertical = stringIDToTypeID( "vertical" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc222.putUnitDouble( idvertical, idpixelsUnit, -10 ); // -10px vertical transform
var idoffset = stringIDToTypeID( "offset" );
desc221.putObject( idoffset, idoffset, desc222 );
var idwidth = stringIDToTypeID( "width" );
var idpercentUnit = stringIDToTypeID( "percentUnit" );
desc221.putUnitDouble( idwidth, idpercentUnit, 125.000000 ); // 125% width scale
var idheight = stringIDToTypeID( "height" );
var idpercentUnit = stringIDToTypeID( "percentUnit" );
desc221.putUnitDouble( idheight, idpercentUnit, 125.000000 ); // 125% height scale
var idskew = stringIDToTypeID( "skew" );
var desc223 = new ActionDescriptor();
var idhorizontal = stringIDToTypeID( "horizontal" );
var idangleUnit = stringIDToTypeID( "angleUnit" );
desc223.putUnitDouble( idhorizontal, idangleUnit, 10.000000 ); // 10 degree horizontal skew
var idvertical = stringIDToTypeID( "vertical" );
var idangleUnit = stringIDToTypeID( "angleUnit" );
desc223.putUnitDouble( idvertical, idangleUnit, 10.000000 ); // 10 degree vertical skew
var idpaint = stringIDToTypeID( "paint" );
desc221.putObject( idskew, idpaint, desc223 );
var idangle = stringIDToTypeID( "angle" );
var idangleUnit = stringIDToTypeID( "angleUnit" );
desc221.putUnitDouble( idangle, idangleUnit, 45.000000 ); // 45 degree Rotation angle
var idlinked = stringIDToTypeID( "linked" );
desc221.putBoolean( idlinked, true );
var idinterfaceIconFrameDimmed = stringIDToTypeID( "interfaceIconFrameDimmed" );
var idinterpolationType = stringIDToTypeID( "interpolationType" );
var idbicubic = stringIDToTypeID( "bicubic" );
desc221.putEnumerated( idinterfaceIconFrameDimmed, idinterpolationType, idbicubic );
executeAction( idtransform, desc221, DialogModes.NO );
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.