What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

How may I move a layer by pixels equal to the width of the layer?


Rs Vivs Laliberte

New Member
Messages
2
Likes
0
Hi
Something I do very often is duplicate a layer, and then move the duplicate right by a number of pixels equal to the size of the layer...I have worked out how to record my actions used for creating the new layer, but can't figure out how to set up the move correctly in a script, since the size varies from project to project. And, infact, from run to run of my little action. (I create a 2nd layer, move it, flatten, and then repeat so the next time the size is approx 2x as long as the first time)
I've seen a few videos on "variables" but didn't see one that I could assign to the width of my selection, but I may well have missed something in my newbieness.
Any advice appreciated. =]
 
This code will duplicate the current layer, select the duplicate and move it to the right by the layers width.

Code:
#target photoshop
if(documents.length){
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var dup =activeDocument.activeLayer.duplicate ();
var LB = activeDocument.activeLayer.bounds;
var layerWidth = LB[2] - LB[0];
activeDocument.activeLayer= dup;
activeDocument.activeLayer.translate(layerWidth,0);
app.preferences.rulerUnits = startRulerUnits;
}
 
Hi, No I am moving it with the mouse. not keys. I am using the record button in the actions panel. It is actually a selection from the previous layer, which I copy, paste and move. I am able to record my selection process, the copy and the paste. But since the move amount varies from run to run, I'm not sure how to automate that. Functionally I want x=width of selection in pixels; move selection right x pixels. I don't know much about scripting beyond the simple recording options I've been presented, but am willing to learn
 
Last edited:

Back
Top