![]() |
|
Writing a simple python plugin - 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: Writing a simple python plugin (/Thread-Writing-a-simple-python-plugin) |
Writing a simple python plugin - LeonardCarlCampbell - 01-22-2026 Why is it so hard to create a plugin. I am trying to write a simple plugin to export the current image to a PNG file and then close the view. I am stuck at the save the image. Plugin attached. RE: Writing a simple python plugin - MrsP-from-C - 01-22-2026 Can't see your plug-in RE: Writing a simple python plugin - rich2005 - 01-22-2026 (01-22-2026, 08:13 AM)MrsP-from-C Wrote: Can't see your plug-in scripts/plugins can now be attached with extension, for a .py maybe your browser is security blocking the attachment. However it is a subject close to my heart, Gimp 3 python is complicated for the average user and any explanations are welcome. To me the attachment looks AI generated. (I have my own script-fu (as a plugin) for exporting webp and it is a quarter the size. ) I will attach the plugin zipped in-case of a security block and in its own folder as required by Gimp 3. Fails on the first line, the shebang is incorrect. Fix that and it does register but there are hard coded paths (specific to user) Attached: [attachment=14208] RE: Writing a simple python plugin - LeonardCarlCampbell - 01-22-2026 Thanks6 for the upload- it should have had the extension. Yes it is ai generated - Google does well most of the time when writing python script but has fallen completely flat on gimp plugins(He likes to think gimp2 is still a thing). Documentation seem very sparse for this. Yes the paths are hardcoded - easier than figure out what gimp can or can't do when it took hours for me to figure out how to get it to even show up. I'm trying to fixup a lot of images and the export process is so long - complicated by something has taken hold of the keyboard shortcut for export. I finally changed it. Then it comes up with a name dialog where I sometimes have to change from jpg to PNG then another dialog comes up with no buttons (weird) and I have to move this dialog slightly and the final parameter dialog comes up. Tedious. RE: Writing a simple python plugin - gasMask - 01-22-2026 Hi, I went through code and made a working version. I believe there's no way to close the image with Python after saving it as a PNG. Code: #!/usr/bin/env python3RE: Writing a simple python plugin - LeonardCarlCampbell - 01-22-2026 Well I got past the save file. but the close image is not working. appending fixed program RE: Writing a simple python plugin - LeonardCarlCampbell - 01-22-2026 Thanks - I will try it out. Close while helpful isn't too bad as you can close all images and tell it not to save any. Still would be nice. Ok tried it out - export takes some time so if you don't wait you might get an incomplete image. Image close would help here a lot, surprised there is no option for this (I found some documentation but I can't find that feature either. Thanks - It has speed-ed up my work considerably. RE: Writing a simple python plugin - rich2005 - 01-23-2026 (01-22-2026, 05:27 PM)LeonardCarlCampbell Wrote: Well I got past the save file. but the close image is not working. appending fixed program Might / might-not help but if you have a gimp-image-clean-all as a last procedure then you can use File -> Image -> Close All to do as it says, close without any dialogues. Goes back to the ancient save/export controversy More up-to-date example is https://github.com/akkana/gimp-plugins/blob/master/gimp3/saver.py |