![]() |
|
How to iterate pixels with python API? - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: How to iterate pixels with python API? (/Thread-How-to-iterate-pixels-with-python-API) |
How to iterate pixels with python API? - Scallact - 06-29-2026 Hi, [GIMP 3.2 python API] I'm trying to iterate over all the coordinates of an image, and create some calculated pixel values on a new layer. I'm currently using the Gimp.Drawable.set_pixel() method, but its very slow (and supposed to be). I'm struggling to find the right way to do this. I think there was a concept called "regions" in GIMP 2.xx. I understand I have to use a Gegl.Buffer. But from there I'm stuck I can't find any definition, or just circular definitions, of what a Gegl buffer is, or any other concept. That's what makes things really difficult. Does a "buffer" represent the whole drawable? And if it is, how do I extract just a tile and iterate over the pixels? What is a "shadow buffer"? What is a "handler"? What is "the abyss"? Thanks! RE: How to iterate pixels with python API? - Scallact - 07-02-2026 I was finally able to crack this problem. Here is some sample code: Code: #!/usr/bin/env python3RE: How to iterate pixels with python API? - Scallact - 07-09-2026 Just a little Post-Scriptum about the Babl pixel format in the .set_rectangle method. Here are the formats that I could gather from the internet, notably from here:
The formats:
The formats I presume should logically exist (correct me if wrong):
RE: How to iterate pixels with python API? - CmykStudent_ - 07-09-2026 Scallact: For reference, all babl formats can be found here: https://gegl.org/babl/Reference.html RE: How to iterate pixels with python API? - Scallact - 07-09-2026 (07-09-2026, 07:44 PM)CmykStudent_ Wrote: Scallact: For reference, all babl formats can be found here: https://gegl.org/babl/Reference.html Oh wow, there a lot!!! That's crazy! Thanks a lot, I should have found that myself! But Gogl doesn't seem to like Gegl! ;-) (Just joking) |