Transform layer to fit canvas

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

perkin5
Posts: 1
Joined: Fri May 19, 2017 4:11 pm

Transform layer to fit canvas

Post by perkin5 »

I am looking for a free script to do the above. This is the activity in question: I have a multilayered document open and I drag in another image (a texture) which forms a new layer on top of the stack. I accept it but the dimensions don't match the canvas, so I press Ctrl-T to transform it. I drag the top right corner to snap into the top right corner of the canvas and then drag the bottom left corner to snap into the bottom left corner of the canvas - so my texture layer now exactly covers the canvas. Of course the aspect ratio has changed but as it is a texture that doesn't matter.

So what I would like is that, after placing the texture image and with its layer selected, I could run a script to achieve that simple task. I'm guessing it would only be 3 or 4 lines of code.

Has anyone come across such a script? Or failing that could you help me write it - I've never tried to write a Photoshop script.