You are here

Access objects in layers

Hi Everybody

Im trying to develop a script-fu script for GIMP but I am having some difficulties. Is there a way to access to the objects contained in each layer?
For example, that the script tells me there are 4 objects (rectangle, ellipse, etc) in layer 1, 5 objects in layer2, and so on for the total of layers.

Thanks in advance

GIMP doesn't particularly understand the concept of graphical objects, for the most part it only handles bitmap graphics. If you want to have separate "objects" such as circles, rectangles, etc then your best bet is to place each object on a separate layer.

Thanks very much, I guess it wont be useful because I would be usign more than one hundred objects per layer, so that would be too many layers.

to start with a transparent background or create a transparent layer that the script works on, and then require the USER to make the shapes, and then have the script select all the objects as selections (alpha to selection).
That is if you want Gimp to recognize many shapes on a single layer. I believe it could be done that way.

What is it you want the script to do, or accomplish?


I've written scripts that do that - separate all the images on a single layer into individual selections and then do something with them

More details might help in proposing a solution.

-Rob A>

Im kind of new with this language but I see what you are saying, I guess that would actually work on a single layer, but in order to do the same for more than one layer, is there some kind of index for each layer that could let the script iterate and do the count through each layer?

have the script count objects on layers with linked attributes.Not sure what the PDB would be though.You can probably find it in the Help>Procedure Browser
gimp-layer-get-linked ... perhaps?

Of course this would require the user to link the correct layers.
Maybe you could use a type of gimp-image-merge-visible-layers ... after?


More information is needed on the nature of your objects if you expect to place them on the same layer.

If the objects are just unfilled shapes then they might be described using paths (or strokes within a single path). In this case they don't necessarily have to correspond to a particular layer (but they can, if needed). This is likely the best approach, but it is very dependent upon the nature of your shapes. (Filled shapes could also be supported, but would require some extra coding.)

If the objects do not overlap then they can probably be stored on a single layer and later "extracted" using a technique similar to the one employed in my Mean Fill whereby fuzzy selection of one-pixel tall strips are made to find the objects. The code as written does not support anti-aliased regions (a pixel is either inside the region or outside of it), so this might not be useful for some shapes.

Finally, could you describe the problem you'd have with hundreds of layers; I've used GIMP images with thousands of layers before with only minimal difficulty (as long as the layers are small enough to not overtax available memory).

Sure may be possible

BUT maybe not strictly needed, on top of the filter list you always have the option to run again the last filter used
So you may click on a different layer in the layer windows and click filters/repeat last

Not quick as a batch but not even too slow

anyway i suppose the script of RobA would require something to determine the objects
as Saulgoode wrote gimp doesn't understand the concept of objects
that may be solved is the object are separated by transparency or by a solid color (as a white BG )...or something alike

Subscribe to Comments for "Access objects in layers"