Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Fu: Creating batch path loading and saving plugin.
#2
Yes, it is doable. Steep learning curve if you need to learn both Python and Gimp scripting. Some hints:
  • Use os.walk(topdir) to list the contents of the top directories. This produces sperat lists of directories and files
  • All the API documentation is available via Filters>Python-fu>Console>Browse.... It is dynamically generated, you'll even see your black-to-alpha plugin there.
  • The Python-specific bit of the API (using Python ibjects instead of the PDB calls) is documented here: http://www.gimp.org/docs/python/index.html
  • Load the files with layer=pdb.gimp_file_load_layer(image, filename). Once loaded you have to explicitly add the layer to the image (image.add_layer(layer,pos), pos=0 for the top of the stack, pos=len(image.layers) for the bottom).
  • You can make a special case and load the first file with image=pdb.gimp_file_load(filename,filename) to create the image.
  • Try to get at least the file walk working by using Python outside of Gimp (you can run the python executable that comes with Gimp in a terminal/console, it is much easier to debug that way, but this is only possible for code that doesn't interact with Gimp).
  • To debug under Gimp, several hints there: https://www.gimp-forum.net/Thread-Debugg...in-Windows
  • As long as you don't change the registration data, you can modify the script file and execute the new version without needing to restart Gimp.
Good luck.
Reply


Messages In This Thread
RE: Python Fu: Creating batch path loading and saving plugin. - by Ofnuts - 10-31-2018, 01:29 PM

Forum Jump: