Python-fu basics: importing and exporting files - 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: Python-fu basics: importing and exporting files (/Thread-Python-fu-basics-importing-and-exporting-files) |
Python-fu basics: importing and exporting files - Xeroxide - 10-24-2022 Hi, I am sorry if this is a duplicate question. I did my best to check for topics that answered my question, but I'm still a little lost. What I am trying to do: load an image from folder_1, do some transformation to it (this part I understand well enough), save the image to folder_2 (I can do this using some code I found) Where I am getting stuck: my syntax for loading the file seems to be wrong. It's not showing up in the file menu, which I assume means that I'm missing some essential lines. I found some code that works to save the file, so I will omit that from my code sample. This is basically what I have. #!/usr/bin/python from gimpfu import * def load_file(): path = "C:\Users\User\Pictures\GIMP\folder_1\01.png" filename = path raw_filename = path image = pdb.file_png_load(filename, raw_filename) register( proc_name = ("python-fu-load"), blurb = ("load file"), help = ("imports png from 'new folder' with the name 01"), author = ("REC"), copyright = ("REC"), date = ("2022"), label = ("load file"), imagetypes = ("*"), parameters = [ (PF_IMAGE, "image", "takes current image", None), (PF_DRAWABLE, "drawable", "input layer", None) ], results = [], function = (load_file), menu = ("<image>/Layer") ) main() I know that I'm missing something very basic, but I haven't been able to find an example that simply loads a file to work on using python-fu. I would love to get my hands on some basic utility plugins or examples written for python-fu, if I have something to reference I can probably figure out what I need. Thank you for reading this. RE: Python-fu basics: importing and exporting files - Ofnuts - 10-24-2022 You are using keywords paramaters where you shouldn't: Code: Traceback (most recent call last): Also:
For some examples see here (especially those with export in the name) (*) Of course you need to import os RE: Python-fu basics: importing and exporting files - Xeroxide - 10-24-2022 Thank you for your reply. After cleaning up the mess in the register part of the code, I was able to get it to show up in the menu. So something there was causing the main problem. Looking at your working code is helping a lot, thank you for sharing that. I will try to adopt the correct filepath handling going forward. The debug post has been very helpful too, thanks for that as well. I will study your library of plug-ins for awhile and try to rethink my approach. |