Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GIF frames deleting script.
#3
Pretty close. Something like this:

1. Depends if you work top down of bottom up
Code:
layers=image.layers[:] # Make a copy of the list
layers.reverse() # if working bottom up

2. Select layers
Code:
keep=3
delete=2
stride=keep+delete
deleted_layers=[layer for i in range(keep,len(layers),stride) for layer in layers[i:i+delete]]

At that point you can inspect the contents of delete_layers to make sure they are the ones

3. Delete them
Code:
for l in deleted_layers:
   image.remove_layer(l)

Coded in slo-mo (so to speak) for better readability, a tattooed Python coder would have done a one-liner Cool
Reply


Messages In This Thread
GIF frames deleting script. - by rey - 04-02-2023, 12:29 PM
RE: GIF frames deleting script. - by rey - 04-03-2023, 10:05 AM
RE: GIF frames deleting script. - by Ofnuts - 04-03-2023, 02:41 PM
RE: GIF frames deleting script. - by rey - 04-03-2023, 05:18 PM
RE: GIF frames deleting script. - by Ofnuts - 04-03-2023, 09:23 PM
RE: GIF frames deleting script. - by teapot - 04-04-2023, 03:30 AM
RE: GIF frames deleting script. - by Ofnuts - 04-04-2023, 07:26 AM
RE: GIF frames deleting script. - by teapot - 04-05-2023, 02:21 AM

Forum Jump: