Run GIMP Script from Command Line and Exit
Running GIMP in batch mode allows you to automate image processing tasks by executing scripts directly from the terminal. By combining headless operation flags with the batch evaluation command and a termination call, GIMP can execute custom Script-Fu or Python-Fu routines and shut down automatically once execution completes, freeing up system resources without requiring manual user interaction.
The Essential Command-Line Arguments
To run a script and immediately terminate the GIMP process, you must
combine the --no-interface flag with two
--batch commands:
gimp -i -b '(your-script-call argument1 argument2)' -b '(gimp-quit 0)'-ior--no-interface: Launches GIMP without loading the graphical user interface. This is required for headless environments, automated shell scripts, or remote server jobs.-bor--batch <command>: Instructs GIMP to execute the provided command string using its internal interpreter (Script-Fu by default).-b '(gimp-quit 0)': Forces the GIMP process to cleanly terminate with an exit code of0once the preceding batch commands have finished processing. If you omit this argument, GIMP will execute your script and remain open in the background indefinitely, waiting for standard input.
Practical Script-Fu Example
To call a native Script-Fu function and exit, execute:
gimp -i -b '(script-fu-invert-colors "image.png")' -b '(gimp-quit 0)'GIMP evaluates multiple -b parameters in sequential
order. The image processing script runs first, and the subsequent
(gimp-quit 0) command executes only after the first command
has finished.
Python-Fu Execution
If your automation uses Python-Fu instead of Scheme/Script-Fu, the same termination argument applies, but the script invocation changes:
gimp -i -b 'import my_script; my_script.run("image.png")' -b '(gimp-quit 0)'You can also call the procedure database directly in Python syntax,
but passing the final (gimp-quit 0) via Script-Fu remains
the cleanest, universal method for process termination across all GIMP
installations.
Platform Consideration for Windows
On Windows systems, use gimp-console.exe instead of
gimp.exe. While gimp.exe opens a detached
background process that hides terminal output,
gimp-console.exe connects standard input and standard
output directly to your command prompt:
gimp-console-2.10.exe -i -b "(your-script)" -b "(gimp-quit 0)"