It is currently Sat Jun 20, 2026 4:45 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Gimp Helpers for Gimp-3.0 by Ofnuts.
PostPosted: Thu Nov 28, 2024 12:37 pm  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2639
Location: Poland
Some great examples of how to write Python plugins for Gimp-3.0
https://gitlab.com/gimp1614946/gimphelpers

Image

Even with Gegl operations (Choice demo uses 'gegl:gaussian-blur'):

Image

_________________
Image


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: Gimp Helpers for Gimp-3.0 by Ofnuts.
PostPosted: Fri Nov 29, 2024 10:55 am  (#2) 
Offline
GimpChat Member
User avatar

Joined: Jul 04, 2019
Posts: 280
Location: Lake Havasu City, Arizona, USA
Thanks MareroQ for bringing this resource to light. There's nothing like having an example to help a programmer put code together. :yes

_________________
Charles


Top
 Post subject: Re: Gimp Helpers for Gimp-3.0 by Ofnuts.
PostPosted: Fri Nov 29, 2024 5:12 pm  (#3) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16037
I am really hoping to get into Python scripting Gimp 3.0 plug-ins next year. This is going to help me immensely.
Thanks Ofnuts!

_________________
Image


Top
 Post subject: Re: Gimp Helpers for Gimp-3.0 by Ofnuts.
PostPosted: Mon Dec 02, 2024 6:31 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2639
Location: Poland
Also updated here:
Useful links for downloading plugins/scripts
viewtopic.php?f=9&t=18452

_________________
Image


Top
 Post subject: Re: Gimp Helpers for Gimp-3.0 by Ofnuts.
PostPosted: Mon Dec 02, 2024 4:23 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Nov 04, 2015
Posts: 1449
Quote:
I am really hoping to get into Python scripting Gimp 3.0 plug-ins next year. This is going to help me immensely.
Thanks Ofnuts!

I'm reading Learn Python The Right Way I agree with what the author says about C and Java both really hard to master. I noticed some of the Gimp 3 python plugins are compiled into an exe like C files.


Top
 Post subject: Re: Gimp Helpers for Gimp-3.0 by Ofnuts.
PostPosted: Tue Dec 03, 2024 3:57 am  (#6) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
Tas_mania wrote:
Quote:
I am really hoping to get into Python scripting Gimp 3.0 plug-ins next year. This is going to help me immensely.
Thanks Ofnuts!

I'm reading Learn Python The Right Way I agree with what the author says about C and Java both really hard to master. I noticed some of the Gimp 3 python plugins are compiled into an exe like C files.


C, possibly, full of traps and small details you have to care for.

Java, no. Java can be a bit verbose, but when your Java code compiles, it sort of makes sense. In Java, you can't add Apples and Oranges, unless the receiving variable is a count of Fruit. In Python, your first runs are mostly trying to catch typos in variable names and other completely stupid mistakes. You can improve things in Python by using an IDE and using the "type hints" that have been introduced in Python 3.8 so you can write something like:

def getConfigArgs(config: Gimp.ProcedureConfig, *argNames: str):


then if you try to call that constructor with something other than a ProcedureConfig and a bunch of strings the IDE will show you the error right away, and when doing code completion you can even hope that it will suggest variables that already have the right type.

Of course it starts to look like Java, where you have to know what you are doing and where you are going.

But then I'm writing a lot of Python3 code these days, and this helps immensely. I even enjoy times where the code runs on the first try!

Quote:
I noticed some of the Gimp 3 python plugins are compiled into an exe like C files.


Uh? The only reason to do this would be to hide the code, because this kind of "compilation" is more like packaging the code and a Python runtime in a bi blob. What you can see in Gimp is a __pycache__ directory, where code compiled on the fly in a previous run is kept in the cache to avoid being recompiled on subsequent runs. Since in Gimp3 plug-ins are all in their own directory, it is easy to distribute the plug-in with separate module files and these end-up precompiled in __pycache__.

_________________
Image


Top
 Post subject: Re: Gimp Helpers for Gimp-3.0 by Ofnuts.
PostPosted: Tue Dec 03, 2024 5:29 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2639
Location: Poland
@ofnuts

There are 23 types of variables possible in Gimp-2.10.xx.
Are the missing ones in Gimp 3 the developers' choice or Yours?


Attachments:
demo-gui Gimp-2.10.png
demo-gui Gimp-2.10.png [ 15.71 KiB | Viewed 2828 times ]

_________________
Image
Top
 Post subject: Re: Gimp Helpers for Gimp-3.0 by Ofnuts.
PostPosted: Tue Dec 03, 2024 5:41 pm  (#8) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
Still not in Gimp3. My equivalent to this is the "full-dialog" file that you will find on gitlab?

GimpHelpers implements all that works so far.

There are two kind of missing things, those that were variants of the same type of arg:

- Slider/spinner/float/int, now you just have Double or Int, but you also have +/- buttons
- Option/Radio are Choice
- Toggle is Boolean (but I prefer to use Choice)

And those that don't exist yet:

- IMAGE (should be implemented soon)
- PATH/VECTORS
- FILENAME, DIRNAME and DIRECTORY (AFAIK the difference is that FILE/DIRECTORY must exist (used for read) while FILENAME/DIRNAME can be created (overlooked by the dev, I have an outstanding issue on this that you can upvote.
- TEXT (multi-line text)
- LayerGroup

For my own scripts the main blockers are PATH (obviously..) and DIRNAME (many scripts exporting things). For IMAGE for the time being I use a LAYER selector, and then obtain the image from the layer).

My latest addition to the code is a simplified way to call the PDB items (mostly things that aren't part of the base API, such as plugins. For instance:

callProcedure('plug-in-sel2path', image=image,
                                drawables=[selectableLayers[0]] )

_________________
Image


Top
 Post subject: Re: Gimp Helpers for Gimp-3.0 by Ofnuts.
PostPosted: Wed Dec 04, 2024 4:14 am  (#9) 
Offline
GimpChat Member
User avatar

Joined: Nov 04, 2015
Posts: 1449
Quote:
I noticed some of the Gimp 3 python plugins are compiled into an exe like C files.


Those files are here:
/usr/lib/x86_64-linux-gnu/gimp/3.0/plug-ins/
An example is file-rawtherapee/file-rawtherapee
Everything listed as 'file' is an executable. They must be compiled C code and they are called 'plug-ins'.

Python console is there as 'python-console.py' but script-fu is an exe.


Top
 Post subject: Re: Gimp Helpers for Gimp-3.0 by Ofnuts.
PostPosted: Wed Dec 04, 2024 8:22 pm  (#10) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
RT is in not written in Python, probably written in C or C++.

Plugins can be written in a variety of languages. On Unix, with the magic of the "shebang" (the top line that starts with "#!") you don't need to know where the code comes from: if it's a compiled binary it can be loaded and run right away, but if the loader doesn't recognize the binary format it looks for a shebang and uses it to start the adequate interpreter on the file. So in addition to compiled plugins (mostly C and C++, perhaps Rust & Golang too) you can have interpreted plugins (Python, Lua...). So, on Linux at least Gimp is completely language-agnostic when it comes to plugins.

Scripts are different animals, they have to be submitted to the script-fu executor to be run.

_________________
Image


Top
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group