What is the original size and what is your target size? Here are two JavaScript versions. One makes a 100x100 transform on a 103x103 layer. The other makes a 100x100 transform on a 102x102 layer. Note the offset is needed on the “odd” bounds change. Also note that mine are using percentages to transform and not pixels. I think the key is “Am I landing on ½ pixel. If so, I need to adjust accordingly.” // 102x102 to 100x100 no offset needed as it is even var idtransform = stringIDToTypeID( "transform" ); var desc532 = new ActionDescriptor(); var idnull = stringIDToTypeID( "null" ); var ref136 = new ActionReference(); var idlayer = stringIDToTypeID( "layer" ); var idordinal = stringIDToTypeID( "ordinal" ); var idtargetEnum = stringIDToTypeID( "targetEnum" ); ref136.putEnumerated( idlayer, idordinal, idtargetEnum ); desc532.putReference( idnull, ref136 ); var idfreeTransformCenterState = stringIDToTypeID( "freeTransformCenterState" ); var idquadCenterState = stringIDToTypeID( "quadCenterState" ); var idQCSAverage = stringIDToTypeID( "QCSAverage" ); desc532.putEnumerated( idfreeTransformCenterState, idquadCenterState, idQCSAverage ); var idoffset = stringIDToTypeID( "offset" ); var desc533 = new ActionDescriptor(); var idhorizontal = stringIDToTypeID( "horizontal" ); var idpixelsUnit = stringIDToTypeID( "pixelsUnit" ); desc533.putUnitDouble( idhorizontal, idpixelsUnit, 0.000000 ); var idvertical = stringIDToTypeID( "vertical" ); var idpixelsUnit = stringIDToTypeID( "pixelsUnit" ); desc533.putUnitDouble( idvertical, idpixelsUnit, 0.000000 ); var idoffset = stringIDToTypeID( "offset" ); desc532.putObject( idoffset, idoffset, desc533 ); var idwidth = stringIDToTypeID( "width" ); var idpercentUnit = stringIDToTypeID( "percentUnit" ); desc532.putUnitDouble( idwidth, idpercentUnit, 98.039216 ); var idheight = stringIDToTypeID( "height" ); var idpercentUnit = stringIDToTypeID( "percentUnit" ); desc532.putUnitDouble( idheight, idpercentUnit, 98.039216 ); var idinterfaceIconFrameDimmed = stringIDToTypeID( "interfaceIconFrameDimmed" ); var idinterpolationType = stringIDToTypeID( "interpolationType" ); var idbicubic = stringIDToTypeID( "bicubic" ); desc532.putEnumerated( idinterfaceIconFrameDimmed, idinterpolationType, idbicubic ); executeAction( idtransform, desc532, DialogModes.NO ); // this will translate a 103x103 to 100x100 var idtransform = stringIDToTypeID( "transform" ); var desc506 = new ActionDescriptor(); var idnull = stringIDToTypeID( "null" ); var ref128 = new ActionReference(); var idlayer = stringIDToTypeID( "layer" ); var idordinal = stringIDToTypeID( "ordinal" ); var idtargetEnum = stringIDToTypeID( "targetEnum" ); ref128.putEnumerated( idlayer, idordinal, idtargetEnum ); desc506.putReference( idnull, ref128 ); var idfreeTransformCenterState = stringIDToTypeID( "freeTransformCenterState" ); var idquadCenterState = stringIDToTypeID( "quadCenterState" ); var idQCSAverage = stringIDToTypeID( "QCSAverage" ); desc506.putEnumerated( idfreeTransformCenterState, idquadCenterState, idQCSAverage ); var idoffset = stringIDToTypeID( "offset" ); var desc507 = new ActionDescriptor(); var idhorizontal = stringIDToTypeID( "horizontal" ); var idpixelsUnit = stringIDToTypeID( "pixelsUnit" ); desc507.putUnitDouble( idhorizontal, idpixelsUnit, 0.500000 ); var idvertical = stringIDToTypeID( "vertical" ); var idpixelsUnit = stringIDToTypeID( "pixelsUnit" ); desc507.putUnitDouble( idvertical, idpixelsUnit, 0.500000 ); var idoffset = stringIDToTypeID( "offset" ); desc506.putObject( idoffset, idoffset, desc507 ); var idwidth = stringIDToTypeID( "width" ); var idpercentUnit = stringIDToTypeID( "percentUnit" ); desc506.putUnitDouble( idwidth, idpercentUnit, 97.087379 ); var idheight = stringIDToTypeID( "height" ); var idpercentUnit = stringIDToTypeID( "percentUnit" ); desc506.putUnitDouble( idheight, idpercentUnit, 97.087379 ); var idinterfaceIconFrameDimmed = stringIDToTypeID( "interfaceIconFrameDimmed" ); var idinterpolationType = stringIDToTypeID( "interpolationType" ); var idbicubic = stringIDToTypeID( "bicubic" ); desc506.putEnumerated( idinterfaceIconFrameDimmed, idinterpolationType, idbicubic ); executeAction( idtransform, desc506, DialogModes.NO );
... View more