Script to crop individual layers

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

Marksta

Script to crop individual layers

Post by Marksta »

So what I do is I import layers via video frames and have animation on so it all gets thrown into the timeline. With this, I can easily export a video to a GIF. My problem is, I can't crop each frame independently. The functionality I'd like is something like this.

1: Prompt user for a static resolution
2: Go to layer one with marquee tool locked to static resolution
3: Upon selecting an area, the script creates a new layer from copy of selected area
4. Deletes the layer the copy was made from and puts the new copy layer in its place on the timeline
5. Loops this functionality onto the next layer until its gone through every layer

I'm not sure the best way to go about this layer independent cropping tool or even if PS scripts can work with the user prompting for the input. Any advice would be appreciated.

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

Script to crop individual layers

Post by Mike Hale »

You can get the user's input with either a prompt window if it's simple input or a custom dialog for more complex input.

After you have the selection size from the user you can make a selection that size and do something like this to let the user move the selection to the part of the layer they want.
Code: Select allvar userDialogMode = app.displayDialogs;
app.displayDialogs = DialogModes.ALL;
try{// incase they cancel
   app.activeDocument.selection.translateBoundary();
}catch(e){}
app.displayDialogs = userDialogMode;

However that will also let them resize, rotate, etc.