You can upgrade and automate GIMP with Python. Here's how

If you're looking for an alternative to Photoshop, GIMP is probably one of the best out there. It's free, fast, and open source. One of its most powerful features is its scripting and Python support, which gives you complete control over the application to automate processes you'd normally do manually. We'll show you how to create your own Python-based plugins for GIMP, with a sample program that can batch resize images and add a simple watermark to them.



GIMP has everything you need

You do not need to install Python manually

Show plugin folder in GIMP

If you only want to use Python with GIMP, you don't have to worry about installing Python separately. The right version with everything you need is pre-installed, so you can start creating your scripts right away without having to worry about setting it up. All you have to do is pay attention to the Plug-Ins folder, which you can find under Settings, SettingsAnd Folder. You can create a folder for GIMP to check or just use one of the existing ones.


Once you've figured out where your plugin folder is, you're ready to begin. Load up your favorite IDE (I use VS Code) and you're good to go. You'll need to import the gimpfu module into your Python script, but remember that you can't test your scripts outside of GIMP. You'll need to ignore the most Syntax errors because they complain about functions you call that don't exist outside of GIMP. But watch out for basic problems like type errors, spaces, and more.

If you are not familiar with scripting in GIMP or using Python, there are numerous plug-ins available that will make GIMP even better than Photoshop.


How to create your Python plugin in GIMP

We created a simple batch photo editor

Batch watermarking and resizing in GIMP, written with Python

To demonstrate how to create our own plugin in Python for GIMP, we created a simple batch photo editor that takes all the photos in a folder, scales them to a certain width, and adds a text watermark in the bottom right. It's a very simple program and there are countless alternatives, but the key point is that thanks to this program you can edit images automatically using Python.


Python code in GIMP showing loading an image, resizing it and adding a watermark

What you know from regular Python applies here, but you will also need to learn certain functions that GIMP uses in gimpfu to manipulate images. A significant number of functions in GIMP use the PDB or procedural database to interact with images. Functions like pdb.gimp_file_load And pdb.gimp_image_add_layer are features you need to interact with your files, and you need to learn how to use them.

Register function in GIMP Python


However, you also need to register your plugin with GIMP. When registering, you essentially need to pass it all the parameters that tell it what it's called, who created it, where you can access it, and define all the parameters that need to be filled in by a UI element. This will create the popup where we can select the input and output folders, set the width, and set the watermark text. There's even an opacity slider.

You can also create your own programs

Once you get the hang of it, it's easy


In the images above, below the XDA watermark, you can see the text we added automatically using the script. All of these images were also resized to 1920px wide, which is 1080p for a 16:9 aspect ratio. This is great for consistency, but still resizable enough so you can change the resize width, the type of watermark, and more. With a bit of work, you could even use the added watermark as an image that is added as a layer and flattened, and that image you could select by adding another UI element.


While there are countless plugins and programs that will do just that for you, this is just a demonstration of how you can create your own plugins for GIMP and make them do exactly what you want and need. You could take this idea and create your own plugin for GIMP that does something no other program out there can, or you could just look at it as a learning experience.

Leave a Comment