![]() |
Python Scripting Help Needed Gimp 3 - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Gimp 2.99 & Gimp 3.0 (https://www.gimp-forum.net/Forum-Gimp-2-99-Gimp-3-0) +--- Thread: Python Scripting Help Needed Gimp 3 (/Thread-Python-Scripting-Help-Needed-Gimp-3) |
Python Scripting Help Needed Gimp 3 - silenuznowan - 03-29-2025 I have some simple batch scripts for version 2 that I am trying to convert to work with version 3, which I really like working with. Anyway one simple script was this: Code: import os I'm now trying to do the equivalent with Gimp 3 but am unable to even load the file. In Gimp 2 you could load a file with the one line: Code: img = pdb.gimp_file_load(filename, filename) So now this is replaced with: Code: def load_file(filename): Only this results in the following error Quote:TypeError: could not convert 'interior-starship-doors.xcf' to type 'GFile' when setting property 'GimpProcedureConfig-gimp-file-load.file' So it looks like instead of expecting a filename for file the new python api expects an object of type GFile to be passed, and I was wondering how I do this? Thanks in advance. Update: I managed to figure things out using Gio so my new load_file function looks like this: Code: def load_file(filename): While this works, I'm wondering if I'm also supposed to dispose of the Gio.File object, and if so how do I do that? Thanks in advance. Also if there's any interest I can post the whole version of the new script. RE: Python Scripting Help Needed Gimp 3 - Ofnuts - 03-29-2025 The Gio.File is a rather small object (only holds the name, and no state or file dara...) and will disappear when your script ends, so no need to worry. |