![]() |
Updating Python Scripts to Gimp 3 - 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: Updating Python Scripts to Gimp 3 (/Thread-Updating-Python-Scripts-to-Gimp-3) |
Updating Python Scripts to Gimp 3 - PetterPaan - 06-28-2025 Hi all - I get only errors on PythonConsole 3.04, so my question focuses on a first step line thats "load xcf by script": GIMP 3.0.4 Python Console Python 3.12.10 (main, Apr 18 2025, 06:12:22) [GCC UCRT Clang 20.1.3 64 bit (AMD64)] ➤> import gi ➤> import os ➤> xcfFile = file.xcf.load("E:/TemporaryD/AIWorld/Design/TShirts/2304.xcf") Traceback (most recent call last): File "<input>", line 1, in <module> NameError: name 'file' is not defined ➤ Almost all tries with different imports result in similar errors - I tried it for hours, so I cannot remember what I tried and what not. If anyone here gets this one line running (different path of course) he/she may ask Tinkerbell for a gift... PetterPaan RE: Updating Python Scripts to Gimp 3 - Ofnuts - 06-28-2025 When you write: Code: xcfFile = file.xcf.load("E:/TemporaryD/AIWorld/Design/TShirts/2304.xcf") Then either
In practice, you have to import at least a gimp module, which is done like this: Code: gi.require_version('Gimp', '3.0') and then you can at some point in your code (but not right away because there are many things that should be done before to make Gimp consider using your code) issue a Code: image=Gimp.file_load( as documented here. However, the mere idea that you are asking this question in these terms hints that you have very little knowledge of Python (and probably of programming as well) so your chances to end up with a working plugin are minimal if you go straight for this. Better take some time and learn the basics of programming and Python outside of Gimp. The hard part is not writing the code, it is debugging it, and Gimp isn't a very friendly environment for this. (*) "To name things wrongly is to add to the misfortune of the world". Albert Camus |