Pliant AllianceSoftware development notes & tools

GIMP for repeat image processing without the drag

GIMP is usually discussed as a careful, manual image editor, but its scripting side is well suited to jobs that begin with a folder of files and end with a folder of predictable outputs. Resizing a shoot, preparing proofs, applying a watermark or producing web-ready JPEGs becomes repetitive precisely where a human editor becomes slowest. A well-built batch turns those repeated operations into a repeatable production step.

For the 2005–2006 GIMP releases preserved in this archive, Script-Fu was the dependable built-in route. Python-Fu became a practical option in later GIMP 2.x releases, and current installations may offer a graphical batch interface for common tasks. The useful idea has not changed: define the transformation, run it without watching every click, and keep the originals beyond reach. The details matter because a batch that saves one image beautifully can still ruin an afternoon if it overwrites the wrong file.

Batch work is a different kind of editing

Start by separating exploration from production. Interactive GIMP is ideal for deciding how an image should look; batch mode is ideal for applying an already tested decision to many files. The best workflow uses the first on a few examples, records the chosen settings, then hands those settings to a script. This is especially helpful for a small Sydney photography studio or a Melbourne design office, where the same brief may need a web thumbnail, an A4 proof and a print-resolution master.

For an archive-minded workflow, compare three common routes:

Route Best suited to Strength Limitation
Script-Fu GIMP 2.x scripting consoles and .scm files Included with GIMP and able to call core image procedures Awkward for file handling; lists and paths need care
Python-Fu GIMP 2.8 and later where the extension is installed Clear loops, counters, logging and ordinary file handling Interpreter availability differs between installations
Command-line GIMP Unattended runs and scheduled jobs Starts without the graphical interface and can quit cleanly Command quoting and exit codes require testing

For GIMP 2.x users, Script-Fu is the safest baseline because it is present without adding a separate language stack. Python-Fu is easier for loops, logs and file handling, but availability depends on the package. The command-line route wraps either scripting environment for unattended work. Choose one route and keep the transformation itself independent of the person running it.

Plan the job before opening GIMP

Before writing any code, write down the job. Which formats enter the folder? What sizes, colour modes and filenames must come out? Does the process overwrite existing files, skip them or stop at the first error? These answers belong in a short manifest that can sit beside the script, because a later operator should be able to see what the job was meant to do.

Keep source images read-only and write to a separate output directory. A timestamped folder is often better than a generic “exported” folder: it preserves earlier runs and makes an accidental bad batch harmless. Include a dry-run mode that reports what would happen without opening files for export. For a studio working across Windows and Ubuntu, use unambiguous paths and keep a small test set that includes spaces in names, a portrait image, a transparent PNG and a very large file.

Names and units deserve equal attention. Decide whether “800 pixels” means a width or a bounding box before scaling, and record the colour space of each export. Keep the manifest in plain text, with absolute paths generated for the current machine rather than typed by hand. A Melbourne agency might label work by client and campaign, but the script should not depend on a particular client’s folder names; it should read the list of jobs given to it.

Build a reusable transformation script

A transformation should be built from a few ordinary GIMP operations: load, scale or crop, flatten if the target format requires it, save and delete. In Script-Fu these arrive as procedure calls such as gimp-file-load, gimp-image-scale, gimp-file-save and gimp-image-delete. The calls resemble those in the Filters and Script-Fu consoles, which makes them learnable without a separate framework. Script-Fu is terse, however, and its handling of lists can obscure a simple loop.

Python-Fu makes loops, counters and error messages more familiar. In the GIMP 2.x Python-Fu environment, a small job might look like this:

from gimpfu import pdb

jobs = [("campaign/photo.jpg", "campaign/photo-thumb.jpg")]

for source, destination in jobs:
    image = pdb.gimp_file_load(source, source)
    width = image.width
    height = image.height
    new_width = 800
    new_height = int(max(1, round(height * new_width / width)))
    pdb.gimp_image_scale(image, new_width, new_height)
    pdb.gimp_image_flatten(image)
    pdb.gimp_file_save(
        image, image.active_layer, destination, destination
    )
    pdb.gimp_image_delete(image)

The example calculates the new height from the original ratio, flattens the image before JPEG output and removes each image from memory after saving. Its tiny in-memory list stands in for a production manifest; the procedure remains the same.

Load the file list first, log the source and destination for every item, and skip existing outputs only when that is the stated policy. The important distinction is between selecting work and performing the work. A script that combines those concerns becomes difficult to test, restart or adapt for a second output format.

Run the batch without watching it happen

GIMP can run without its normal interface, which is often the fastest way to process a large set. In GIMP 2.x, a Script-Fu file can be loaded through the -b option, followed by an explicit quit. The command is short enough to inspect and easy to place in a shell script:

gimp -i -b '(load "/home/ubuntu/jobs/thumbs.scm")' -b '(gimp-quit 0)'

The explicit exit matters. Without it, an apparently successful run can leave a background GIMP process holding files open. On GIMP 2.10, Python-Fu jobs can be invoked through gimp-console with the python-fu-eval batch interpreter. The exact script-loading call depends on the installed Python environment, so test that invocation separately before placing it in a scheduled task.

A batch run is an automation pipeline, not merely a long series of clicks. When it depends on external files or services, the disciplined approach described in automation notes becomes relevant: define the inputs, isolate failures and record outcomes. Capture standard output and errors to a log, include the input and output paths in each entry, and return a non-zero exit status when a required file fails. Otherwise a scheduler may report success merely because GIMP closed.

Before committing to overnight processing, run the same command against three or four files in a temporary folder. Check that the output opens, that expected metadata remains and that the originals are untouched. A quick trial exposes permission errors and naming collisions while they are still cheap to fix.

Check results before and after scaling

Batch quality problems usually come from assumptions rather than dramatic failures. GIMP may scale an image to exactly 800 by 600 and distort it, or place a transparent layer over a flattened JPEG and produce an unexpected black area. Colour management introduces another variable: the appearance on screen can differ from the appearance in a print proof. Set the target colour profile deliberately and inspect representative outputs in the applications used by the client.

Metadata can be just as important as pixels. Decide whether to retain EXIF fields, camera information and creation dates, and whether exports should include a copyright notice in the image metadata. For a Sydney photographer preparing proofs for clients, a contact sheet may be more useful than a hundred separate thumbnails; for a Melbourne print bureau, the same sheet can show crops and colour consistency before a run is approved. Contact sheets are themselves good batch products, made by arranging thumbnails on a fixed canvas.

A practical review set should include the smallest, largest, portrait and landscape inputs, plus any file with transparency. Open the exports, compare them at 100 per cent and check the intended pixel dimensions rather than relying on the file preview. If the job creates price lists or catalogue images for the Australian market, use realistic Australian dollar amounts and sample wording in the visual proof. The goal is to catch a production error before multiplying it across the set.

Make the workflow repeatable and maintainable

A good batch leaves evidence of what it did. Record the script version, the input list, the settings file, the start and finish times, and the names of failed items. Keep a checksum or a file-size comparison when the outputs must match a specification. This makes a run auditable months later, when the person who started it has moved on and the folder contains several similar-looking versions.

Schedules need uncertainty rather than false precision. An archived companion on slot timing analysis considers variable outcomes in a scheduled system; the image-production parallel is that a job’s duration changes with file sizes, disk speed and competing tasks. Put the batch on a workstation that can remain available, but do not promise an exact completion time from an average run. In a team spread between Perth and the eastern states, transferring a huge set over a long-distance link can take longer than processing it locally.

Cross-platform support is one of GIMP’s practical advantages in the Australian market. The same Script-Fu logic can run on an Ubuntu workstation and a Windows design PC, provided that paths and plugins are handled consistently. Local resellers and open-source distributions can suit different needs, but a script that depends on one person’s desktop configuration is not a shared asset. Put the script, manifest and checks in version control, then document the few installation assumptions that remain.

The durable result is not a single spectacular export but a production system that can be rerun safely. Change one recorded setting, regenerate the affected outputs and compare them with the previous run. Over time, the script becomes a clear description of the studio’s house style: which dimensions, colour profiles, file formats and naming rules apply. That record is more valuable than any single processed folder, especially when an Australian team needs to reproduce the same result months later.