Can I write a script to cycle through a photoshop timeline, and run an action on each frame?

  • 1
  • Question
  • Updated 3 years ago
I've been trying to create a script that uses an action that cycles through the layers of a GIF and removes the background. I found a script that works almost perfectly:

var doc = document.
var doc = app.activeDocument;
for(var i = 0; i < doc.layers.length; i++){

doc.activeLayer = doc.layers[i];
app.doAction("ColorPicker-Remove", "Default Actions");
doc.activeLayer.visible = false;


The script loops through all the layers of my document and runs a Color Picker action that selects the single color background, deletes it, then clears the selection. When I run the script it removes the background color from each layer, but then sets the activeLayer.visible to false for each of the timeline frames. I've tried variations where I set the activeLayer.visible to true, but that just reverses the problem where all of the layers are shown for each animation frame.

I'd like to modify my script to cycle through the timeline frames as well as the layers:

1. Run action
2. Select next timeline frame
3. Select next layer

Something like that. Is there a way to cycle through the timeline frames in a script?
Photo of Andrew Smith

Andrew Smith

  • 1 Post
  • 0 Reply Likes

Posted 3 years ago

  • 1

Be the first to post a reply!