It is currently Thu Aug 06, 2026 9:15 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Fast pixel operations -how?
PostPosted: Tue Sep 16, 2025 10:46 am  (#1) 
Offline
GimpChat Member

Joined: Jun 28, 2025
Posts: 6
Hi!
In a python plugin I am writing for Gimp 3.0, I have created a byte array I call dest_pix that contains all the pixels of a modified image. How can I now insert this information back into an image with maximum efficiency? In Gimp 2.10 this was possible in a single python statement using dest_pix.tostring(), but not any more. Converting the byte array piecewise into a color and then using set.pixel() is impractically slow. Can anyone show me a piece of code that does this quickly? Many thanks!
Stargazy


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Fast pixel operations -how?
PostPosted: Tue Sep 16, 2025 11:20 pm  (#2) 
Offline
Administrator
User avatar

Joined: Aug 10, 2012
Posts: 14144
Location: Native to NYC living in Arizona, Gimp 2.8 - 3.0, Win 11 PC.
Perhaps using GEGL to push a raw pixel buffer (like your dest_pix) back into an image,
instead of doing it piecewise with set_pixel()?

There is someone here who knows lots about GEGL,
that would be
contrast_.
Image

_________________
Image
"A wise man learns more from a foolish question than a fool can learn from a wise answer"
Image


Top
 Post subject: Re: Fast pixel operations -how?
PostPosted: Wed Sep 17, 2025 7:56 am  (#3) 
Offline
Global Moderator
User avatar

Joined: Apr 01, 2012
Posts: 8448
Location: On the other side of your screen
Also, you may have noticed things have changed quite a bit in vs 3? Some people have been able to produce code but I think it is different as the inner workings of gimp have beed changed etc. Wallace picked a good helper in contrast. Also CmykStudent may be able to tell you what you can and cannot do.

_________________
Image
Free Fun Photo Editing & resources
Poems from the Lord
Gimp Newby
Gimp version 3.2.4 and GMIC-Qt 4.0.2 OS :- Windows 10 Home 64


Top
 Post subject: Re: Fast pixel operations -how?
PostPosted: Wed Sep 17, 2025 1:56 pm  (#4) 
Offline
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 2013
I see I was called to this thread. Ok, stargazy: What is the image modification you are trying to accomplish? I can help you with by rewriting it in GEGL instead of Python.

Understand I do not work with Python instead I write GEGL syntax that can easily mimick GIMP layers and layer groups and filters. GEGL will easily allow you to recall the modified pixels in each step.

To proceed in me helping you please tell me the image modifying task you want.


Top
 Post subject: Re: Fast pixel operations -how?
PostPosted: Fri Sep 19, 2025 1:23 pm  (#5) 
Offline
GimpChat Member

Joined: Jun 28, 2025
Posts: 6
Thank you all for your responses - especially contrast_ who offered direct help. I accept that programing in GEGL will do what I am asking for, but in being brief in my message meant I didn't say that I am specifically working in python to provide examples of python plug-ins for other users. It has been hard going from GIMP 2.10 to 3.0, but have workarounds for most things I wanted to do and the performance has been acceptable. But this specific issue has thwarted me. I shall continue net surfing to see if something emerges. Thanks again.


Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group