Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

Can a python script use gimpfu, run from terminal, and create new img?

Thu Feb 03, 2022 11:29 pm

I want to make a python script that will use gimp for some of the processing steps and export as jpeg/png.
In my limited google searching, they say python scripts need to be run inside gimp and cannot be used from the terminal.
..But, I'm having a hard time believing that.

I was planning to create a python file that will look through some folders of images, read some metadata of preferences from a csv, with gimp modify the image sizes, put images side by side (in a grid) according to some preferences, output as a single png in another relative path location

Can I use gimpfu from within a larger python file from the terminal to do this? and if so, are there tutorials/documents for this?

Thanks

Current version of gimp 2.10.14, python 3.7.4

Re: Can a python script use gimpfu, run from terminal, and create new

Fri Feb 04, 2022 3:10 am

The script bit need to be run from Gimp. Gimp isn't designed to be an image processing library, but to be a GUI image editor. So your Python script would have to explicitly start Gimp, and give it the script to run, and possibly a source directory, see here(just repalce .BAT/sheel by Python).

Another solution is to write a Gimp script/plugin, and start it from inside Gimp.

But IMHO if you are in Python, there are plenty of image libraries that can do this, such as Pillow. You can also use ImageMagick, either by calling as a command or using its python bindings. Using Gimp for this is really one of the most complicated ways I can imagine.

Re: Can a python script use gimpfu, run from terminal, and create new

Sat Feb 05, 2022 2:00 pm

I see, thanks for the pillow suggestion im reading about it more now.
Post a reply