When scripting the Photoshop CS6 Transform, you can set the center to rotate or scale around a point by specifying the AnchorPosition enum, such as AnchorPosition.BOTTOMCENTER for the bottom center, etc. The Transform tool also allows you to manually change the center by dragging around this "reference point" making it "independent" (the action term when you do this).

Is there a programmatic way to control the x, y coordinates to actually position of the "reference point" that transforms are rotated and scaled around using javascript?

  • So what's your question? Can you edit it to make more clear? And what have you tried before asking here?
    – Luciano
    Commented Feb 25, 2016 at 12:07
  • As the question states, I want to be able set the center point of the transform. Could be the center of the picture, the upper right pixel, or any point that I want things to rotate around. But NOT just to the extent of the item that is being transformed.
    – WillC
    Commented Feb 25, 2016 at 18:35

1 Answer 1


This is to get you going. I dug this out form the script listener.

rotateCurrentLayer(-10 , 532, 412)

function rotateCurrentLayer( angle, X, Y){
    var idTrnf = charIDToTypeID( "Trnf" );
    var desc77 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
    var ref8 = new ActionReference();
    var idLyr = charIDToTypeID( "Lyr " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idTrgt = charIDToTypeID( "Trgt" );
    ref8.putEnumerated( idLyr, idOrdn, idTrgt );
    desc77.putReference( idnull, ref8 );
    var idFTcs = charIDToTypeID( "FTcs" );
    var idQCSt = charIDToTypeID( "QCSt" );
    var idQcsi = charIDToTypeID( "Qcsi" );
    desc77.putEnumerated( idFTcs, idQCSt, idQcsi );
    var idPstn = charIDToTypeID( "Pstn" );
    var desc78 = new ActionDescriptor();
    var idRlt = charIDToTypeID( "#Rlt" );
    desc78.putUnitDouble( charIDToTypeID( "Hrzn" ), idRlt, X);
    desc78.putUnitDouble( charIDToTypeID( "Vrtc" ), idRlt, Y);
    var idPnt = charIDToTypeID( "Pnt " );
    desc77.putObject( idPstn, idPnt, desc78 );
    var idAng = charIDToTypeID( "#Ang" );
    desc77.putUnitDouble( charIDToTypeID( "Angl" ),  idAng, angle);
    executeAction( idTrnf, desc77, DialogModes.NO );
  • jooja - Thanks for the reply. As you said this gives me something to start with. Any reference as to what the variable string names correspond to? I'm guessing "Trnf" is transform, but some of the others are a bit obscure.
    – WillC
    Commented Nov 26, 2016 at 21:08
  • 1
    @WillC that is what adobe gives me. They never actually made an API for this stuff. Its just autogenerated code by script listener. All the bits and pieces are just large enumerations autogenerated by their backend. The autogenerated backend is cryptic and unreadable mess that depends on 4 character names. Presumably this reflects their internal structure somehow.
    – joojaa
    Commented Nov 26, 2016 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.