Mobile app version of vmapp.org
Login or Join
Twilah924

: Automatically scaled opacity for multi-layered images I have several set of images with a fixed background and an object moving in the foreground. I'd like to get an idea of the motion of the

@Twilah924

Posted in: #Gimp #Opacity

I have several set of images with a fixed background and an object moving in the foreground. I'd like to get an idea of the motion of the object by superimposing images with scaled opacity.

If I load a single bunch of N images into GIMP as N distinct layers, is there a way to automatically set the opacity of all the layers to get a scale effect from the first with P1% (e.g. 0% opacity) to the last with P2% (e.g. 100% opacity)?

Thanks in advance

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Twilah924

1 Comments

Sorted by latest first Latest Oldest Best

 

@BetL875

It is feasible from the Python Console window.
Opacity is a layer property, so it is possible to set it with a simple attribution.

Go to filters->Python Fu->Console - there you can type Python expressions. The first one you want is to get a reference to your image - for example:
img = gimp.image_list()[0] (press enterafterwards) will get you a reference to the latest (rightmost tab) open image in GIMP. (increase the numbers from 0 inside the brackets to get to the other images)

The layers are available as a Python list when you type img.layers, and the opacity varies from 0.0 to 100.0 - so, the first thing to do is to calculate how much you want to increase the opacity from one layer to the next - that number is:
opacity_step = 100.0 / (len(img.layers) - 1)
(just type the variable names, like img and opacity_step by themselves and press enter to check their values).
Now, just pick a starting opacity - ex. current_opacity = 0.0 and then iterate over all layers with a for command, setting the opacity. So, putting everything together, you should type:

img = gimp.image_list()[0]
opacity_step = 100.0 / (len(img.layers) - 1)
current_opacity = 0.0
for layer in reversed(img.layers):
layer.opacity = current_opacity
current_opacity += opacity_step

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme