Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Photoshop scripting: Move an image to position x,y

I have an active ArtLayer referenced by the variable NewLayer that I want to move to the absolute position x,y in the canvas.

I have been googling for a couple of hours now without any results. Can some one please give an example?

// Thanks.

like image 765
Max Kielland Avatar asked Aug 21 '12 22:08

Max Kielland


People also ask

How do I change the position of a picture in Photoshop?

Hold shift key at same time in order to rotate in exact 15 degree increments. Move the photo by dragging the mouse over the photo until you see the solid arrow in the center of the photo. Click and drag photo to desired position.

How do you bring an object forward in Photoshop?

Choose Layer > Arrange, and then choose Bring To Front, Bring Forward, Send Backward, or Send To Back.

How do I move an image down in Photoshop?

Tip: The shortcut key for the Move Tool is 'V'. If you have the Photoshop window selected press V on the keyboard and this will select the Move Tool. Using the Marquee tool select an area of your image that you want to move. Then click, hold and drag your mouse.


1 Answers

After some more API reading and searching I came to the conclusion that it is only possible to move a layer with delta move.

I wrote this little function to position a layer at an absolute position. Hope this is helpful to the next reader with the same question...

//******************************************
// MOVE LAYER TO
// Author: Max Kielland
//
// Moves layer fLayer to the absolute
// position fX,fY. The unit of fX and fY are
// the same as the ruler setting. 

function MoveLayerTo(fLayer,fX,fY) {

  var Position = fLayer.bounds;
  Position[0] = fX - Position[0];
  Position[1] = fY - Position[1];

  fLayer.translate(-Position[0],-Position[1]);
}
like image 137
Max Kielland Avatar answered Nov 15 '22 11:11

Max Kielland