2 Replies Latest reply on Jun 30, 2012 7:18 AM by plumsfriend

    Scripting Relative Canvas Size

    plumsfriend Level 1

      I'm just getting the hang of Photoshop scripting, and have looked everywhere, but I can't find any way of changing a canvas size relative to the current canvas using scripting.


      My current script is below..it sets a selection to the active layer and crops/ flattens the image. Now I want to add a ten pixel border relative to the size of the canvas. Does anyone have any idea how this would be accomplished? I really don't want to have to create an action just to run the canvas resize. Any help would be greatly appreciated!!


      layerPixels2Selection = function(){


         return;// background doesn't have a transparency mask


      var desc = new ActionDescriptor();

      var ref = new ActionReference();

      ref.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) );

      desc.putReference( charIDToTypeID( "null" ), ref );

      var ref1 = new ActionReference();

      ref1.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "Trsp" ) );

      desc.putReference( charIDToTypeID( "T   " ), ref1 );

      executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );