Highlighted

Stopping an action when the bottom-most layer is reached

Nov 14, 2019

Copy link to clipboard

Copied

Hello all, 

 

I'm looking to get assistance on creating an action in Ps to automatically remove background from images, but the problem I'm running into is when I stack all those images as layers, and run the action (remove background quick action, select backward layer, and then loop back to remove background, and so on), I have no clue how to make it stop after it's selected the bottom most layer in the stack, it just switches to the topmost one and continues going.

 

In essence I'm making GIF animations from green screen footage, and needed a way to automate it somehow, because removing the BG on 50+ stacked GIF layers is a bit tedious.

 

Any assistance with this would be greatly appreciated.

Most Valuable Participant
Correct answer by JJMack | Most Valuable Participant

In an action you can start at the top or buttom of visible layer  and process visible layers relative the the starting position. However there is no action conditional you can user to know when to stop. You can come close if yout start at the top and the is a  visible background layer but then you can not remove the background in a photoshop background layer and many documents do not have a background layer

image.png

Topics

Actions and scripting, Feature request, How to

Views

136

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Stopping an action when the bottom-most layer is reached

Nov 14, 2019

Copy link to clipboard

Copied

Hello all, 

 

I'm looking to get assistance on creating an action in Ps to automatically remove background from images, but the problem I'm running into is when I stack all those images as layers, and run the action (remove background quick action, select backward layer, and then loop back to remove background, and so on), I have no clue how to make it stop after it's selected the bottom most layer in the stack, it just switches to the topmost one and continues going.

 

In essence I'm making GIF animations from green screen footage, and needed a way to automate it somehow, because removing the BG on 50+ stacked GIF layers is a bit tedious.

 

Any assistance with this would be greatly appreciated.

Most Valuable Participant
Correct answer by JJMack | Most Valuable Participant

In an action you can start at the top or buttom of visible layer  and process visible layers relative the the starting position. However there is no action conditional you can user to know when to stop. You can come close if yout start at the top and the is a  visible background layer but then you can not remove the background in a photoshop background layer and many documents do not have a background layer

image.png

Topics

Actions and scripting, Feature request, How to

Views

137

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Nov 14, 2019

Copy link to clipboard

Copied

I'm a bit confused as to what you're doing. As far as I know, an action can't loop, so are you using a script? Do you just want to delete the bottom layer? You can just select the bottom layer with the shortcut alt/opt-,

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Nov 14, 2019

Copy link to clipboard

Copied

In an action you can start at the top or buttom of visible layer  and process visible layers relative the the starting position. However there is no action conditional you can user to know when to stop. You can come close if yout start at the top and the is a  visible background layer but then you can not remove the background in a photoshop background layer and many documents do not have a background layer

image.png

JJMack

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 14, 2019

Copy link to clipboard

Copied

JJMack, you are a saviour! I wasn't aware that you could set conditional actions, so what I did was stacked all my to-be-GIF layers, created a locked layer at the very bottom of the stack, just a dummy one, and added that conditional action for the loop to trigger a stop action if it detects a locked layer. Worked like a charm! Thank you

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 14, 2019

Copy link to clipboard

Copied

In essence I'm making GIF animations from green screen footage, and needed a way to automate it somehow, because removing the BG on 50+ stacked GIF layers is a bit tedious.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Nov 14, 2019

Copy link to clipboard

Copied

Please post a screenshot of the action will all steps expanded.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 14, 2019

Copy link to clipboard

Copied

Here's what I've got after adding the conditional action JJ Mack mentioned, see above.

Screenshot_5.png

It works well like this now.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Nov 14, 2019

Copy link to clipboard

Copied

A script can easily detect the last layer:

var doc = activeDocument;
if(doc.activeLayer == doc.layers[doc.layers.length-1]){alert('this is the last layer')}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Nov 14, 2019

Copy link to clipboard

Copied

/* 
Lena wrote:
In essence I'm making GIF animations from green screen footage, and needed a way to automate it somehow, because removing the BG on 50+ stacked GIF layers is a bit tedious.
*/

 

FYI, there are numerous scripts that will iterate/loop an action over all layers in a file.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 14, 2019

Copy link to clipboard

Copied

I was good on how to create a loop, may not have worded it well, but I was trying to add a way to stop it. Sorry 'bout the confusion, I'm a bit new to all this.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Nov 14, 2019

Copy link to clipboard

Copied

Actions can have problems doing this as you found, a script doesn't, it knows when to stop without having to be explicictly told to do so.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...