You are here

Plugin API to get layer name

I am trying to write a plugin that will work with animated multi-layer images.
In order to work with them it needs to be able to get and set layer names by layer id (because frame timing is based on layer name).

But I have gone over the API documentation many times and cannot find a way to do this. I managed to make it work with the undocumented gimp_item_get_name() but it only works if it is the first and only image open. It gets screwed up when there is more then one image open presumably because gimp_item_get_name() works on a global level.

Is gimp really missing this important API function, or am I missing something?

You are doing something wrong in your call of the procedure. Please provide more details about what you are doing.

Thanks for the response.

What I am trying to do is write a plugin to change the framerate of a animation.

You know how gimp would store an animation at 20FPS for example

In layers:
Frame 1 (50mS)
Frame 2 (50mS)
Frame 3 (50mS)
Frame 4 (50mS)
Frame 5 (50mS)

So if I wanted to change the framerate to 40 FPS, I would duplicate each layer and change the layers name to something like

Frame 1A (25mS)
Frame 1B (25mS)
Frame 2A (25mS)
Frame 2B (25mS)
Frame 3A (25mS)
Frame 3B (25mS)
Frame 4A (25mS)
Frame 4B (25mS)
Frame 5A (25mS)
Frame 5B (25mS)

But I cannot figure out a way to recurse through the layers and rename them if necessary.

I cannot even compute the current framerate because I cannot reliably get the layer's name.

Essentially I need to get layerid from imageid and layer position in that image

"Essentially I need to get layerid from imageid and layer position in that image"

You can get a list of all the layers in your animation with 'gimp-image-get-layers'. The layers in the list are in top to bottom order.

The following script might serve as an example of how animation settings can be modified by editing layer names.

http://chiselapp.com/user/saulgoode/repository/script-fu/wiki?name=sg-an...

Well I was actually developing this in C. And there doesn't seem to be a C equivalent.

I guess I could switch to gimp's script-fu language although I would prefer not to because I am not really familiar with it.

Thank you very much. Now I can start developing again

Subscribe to Comments for "Plugin API to get layer name"