The purpose of this action is to crop all pixel information that falls outside of the canvas area for “just the active layer”, NOT all the other layers in the document as well.
This is way out of my league to be able to script. I posted the question on the Adobe Forums, but i got little responses.
Oddly, I feel this would be an extremely beneficial script to all those who use Photoshop CS.
This below action of mine works very well except it has one limitation. I had to assign the “active layer” a specific name so the action could target it. It would be nice if the name could have been changed back to the layer name it “originally” was. (scripting may be able to solve this snafu)
Step 1: Layer Properties>change name of active layer to: “ToBeDeleted”
Step 2: Select All
Step 3: Layer New Vial Cut
Step 4: Layer Properties>change the name of this newly created layer to: “Cropped Layer”
Step 5: Highlight the layer called: “ToBeDeleted” and choose Delete Layer from the twisty arrow in the Layers palette.
Step 6: Select the layer called: “Cropped Layer”
This will work on the selected layer. The only caveat is that the image must be extended off of all four sides of the document, because the “paste” drops it into the center of the doc.
Haven’t looked into a “paste in place” option.
tell application "Adobe Photoshop CS"
activate
set theDoc to current document
set theLayerName to name of current layer of theDoc
select all of the theDoc
copy
paste
delete layer theLayerName of theDoc
set the name of current layer of theDoc to theLayerName
end tell
N,
I know this dilemma with the “Paste”, which is definitely a problem since often the image doesn’t engulf the entire canvas area. Also, layer effects are a problem with copying and pasting (I believe?).
Layer New via Cut is the key. But it requires some preliminary and itermediate steps. You actually supplied some very useful tidbits of coding that may help me script my action.
The tricky part is that I will have to be able to code for: Get the name of Active layer “X”. Change the active layer to “Y”. Eventually perform, Layer New Via Cut and Change the new layer to “X” and then delete “Y” layer.
This would work in all instances, and with layers with effects.
Thanks for what you gave me.
With my limited skills I am going to attempt this. Good thing is, I don’t have to work tomorrow
Keep in mind that you can call a PS action from within Applescript. (Not sure if you can do a “Layer via Cut” with AS). You might need to do a combo of actions and AS.
N,
I had no idea you can call a PS action from within AppleScript!!! (Is this for real?)
This would work perfect.
All I need to do is have AS do is the following in this order.
1: Get the name of the active layer.
2: Run the PS action.
3: Assign the active layer the name it received in step 1.
This would be so amazing!
Can you please tell me how I could code for calling PS action from within Applescript?
Actually this wasn’t so difficult. This script seems to be working. How I have no idea? I must have gotten lucky?
Thanks again for letting me know this can be done. I have a feeling I will be using this feature quite often.
jeff
tell application "Adobe Photoshop CS"
activate
set theLayerName to name of current layer of document 1 as string
do action "Crop_One_Layer" from "Crop_One_Layer.atn"
set name of current layer of document 1 to theLayerName
end tell
Matt,
Can you help me out? I really want to include this but I am having difficulty.
How can incorporate your script into the script below? Also, does there need to be an “&” between the “command” and “shift” ?
Btw, if I can abandon the action, I will be so happy.
Thanks,
jeff
tell application "Adobe Photoshop CS"
activate
set theLayerName to name of current layer of document 1 as string
set the name of current layer of document 1 to "DeletedLayer"
-- run the action
do action "Delete_All_The_Inverse" from "Delete_All_The_Inverse.atn"
-- delete the original layer
delete layer "DeletedLayer" of document 1
set name of current layer of document 1 to theLayerName
end tell