Action or automating process to set corner reference point to [0,0]
Hello my dudes,
I'm trying to figure out how to automate a step I use frequently in my current workflow.
Right now, my manual process is Transforming a layer, clicking on the corner reference point, clicking to the [X: 1px] box, entering '0', tabbing over to the [Y:2px], hiting '0' again, and then enter.
I've tried creating an action, but it records the absolute movement of the layer for that process. So if I move it -25,-50. The next time I play back the action on a different layer, it will move -25,-50, but it may be a different starting point, so that won't work. I would like it to set to [0,0] independent from its starting point.
Wondering if this requires scripting instead.
Hope this makes sense.
Thanks!
Posted Mar 31, 2021, 7:46 PM UTC · edited
So you're just moving the layer contents to the top left corner? Can you use the alignment options instead? With your layer active and the Move tool active, hit ctrl/cmd-a to select all, then in the options bar, hit the align left edge and align top edge icons, then ctrl/cmd-d to deselect. (Also available in Layers menu > Align Layers to Selection.) Record it as an action.
You can also do it with scripting, and you'd probably have to if e.g. you were going to align the layer's center to 0,0 instead of its edges.
🤦🏼♂️ Sometimes my brain tries to do mental gymnastics to do something simple. Thanks for help. I gotta remember the old K.I.S.S. mantra.
Just found a limitation with this. For smart objects that have a bounding box, the alignment is applied to the pixels within that box, not the edges of the box itself. Ie. if a smart object layer is 100x100, and there is a small 10x10 object in the middle with the rest being transparent, aligning this smart object to the left and top will make the 10x10 object align with the top corner.
I'll probably have to script this out. Thanks anyways.
Here's a workaround (though I just did a basic test so it's possible it won't work in your case).
Record an action:
Edit the SmObj contents (double-click thumbnail, or one of the other methods).
Create a new Solid Color Fill layer. Save, close.
Do the alignment steps.
Edit SmOjb to open it, hit delete, which should delete the color fill layer since it was the active layer when saved, and should re-open as such. Save, close.
Now the layer should be aligned to the SmObj's file dimensions instead of the few non-transparent pixels inside it (because when it was aligned, it was completely filled with pixels).
Yeah, this makes sense for the meantime. At some point, I'd still like o make a simple script. Having PS open, save, and close layers may slow things down, especially if the SO's get hefty.
I thank you for your efforts, good sir.