Is it possible to scale a pathItem in Photoshop CC?

36 Views Asked by At

I'm trying to scale a pathItem using Javascript in Photoshop CC. I need to scale it with the TOPCENTER constraint. This pathItem is tied to a text layer (for type on a path).

When you scale a text layer that is bound to a path in Photoshop, it scales the path, not the text. So I tried scaling the actual layer - but it didn't behave as expected. This just scales the text itself.

app.activeDocument.activeLayer.resize(100, amount, AnchorPosition.TOPCENTER);

It appears "resize" is not one of the methods of the pathItem object. I know you can scale paths in Illustrator with Javascript, but it doesn't work here.

app.activeDocument.pathItems[1].resize(100, amount, AnchorPosition.TOPCENTER);

This documentation for Photoshop seems to suggest that there is no such method. Am I missing something? Or is there some alternate way, like directly changing the position of the points on the path?

1

There are 1 best solutions below

1
Ghoul Fool On BEST ANSWER

I'll take a guess that you haven't selected the path item first. This should work for you

select_path("Path 1");
resize_it(200,200);

function select_path(thepathname)
{
    // =======================================================
    var idslct = charIDToTypeID( "slct" );
    var desc70 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
    var ref16 = new ActionReference();
    var idPath = charIDToTypeID( "Path" );
    ref16.putName( idPath, thepathname ); // pathname here
    desc70.putReference( idnull, ref16 );
    executeAction( idslct, desc70, DialogModes.NO );
}

function resize_it(scaleX, scaleY)
{
  // =======================================================
  var idTrnf = charIDToTypeID( "Trnf" );
  var desc82 = new ActionDescriptor();
  var idnull = charIDToTypeID( "null" );
  var ref20 = new ActionReference();
  var idPath = charIDToTypeID( "Path" );
  var idOrdn = charIDToTypeID( "Ordn" );
  var idTrgt = charIDToTypeID( "Trgt" );
  ref20.putEnumerated( idPath, idOrdn, idTrgt );
  desc82.putReference( idnull, ref20 );
  var idFTcs = charIDToTypeID( "FTcs" );
  var idQCSt = charIDToTypeID( "QCSt" );
  var idQcszero = charIDToTypeID( "Qcs0" ); //Anchor
  desc82.putEnumerated( idFTcs, idQCSt, idQcszero );
  var idOfst = charIDToTypeID( "Ofst" );
  var desc83 = new ActionDescriptor();
  var idHrzn = charIDToTypeID( "Hrzn" );
  var idPxl = charIDToTypeID( "#Pxl" );
  desc83.putUnitDouble( idHrzn, idPxl, 0.000000 );
  var idVrtc = charIDToTypeID( "Vrtc" );
  var idPxl = charIDToTypeID( "#Pxl" );
  desc83.putUnitDouble( idVrtc, idPxl, 0.000000 );
  var idOfst = charIDToTypeID( "Ofst" );
  desc82.putObject( idOfst, idOfst, desc83 );
  var idWdth = charIDToTypeID( "Wdth" );
  var idPrc = charIDToTypeID( "#Prc" );
  desc82.putUnitDouble( idWdth, idPrc, scaleX ); // Scale X
  var idHght = charIDToTypeID( "Hght" );
  var idPrc = charIDToTypeID( "#Prc" );
  desc82.putUnitDouble( idHght, idPrc, scaleY ); // Scale Y
  var idLnkd = charIDToTypeID( "Lnkd" );
  desc82.putBoolean( idLnkd, true );
  executeAction( idTrnf, desc82, DialogModes.NO );

}