GIMP

Introduction
GIMP is the GNU Image Manipulation Program. It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. GIMP is best known as a free alternative to professional graphic editing programs such as Adobe Photoshop. However it also includes a batch mode that allows you to perform image processing tasks from the command line and to easily apply the same set of operations to a number of images.

Scanned document images often need to be optimized in order to enhance their contrast or to scale them to a certain size. This step is usually part of the post-processing workflow where images are prepared for visual presentation or they are analyzed using OCR and text processing software. By integrating image manipulation software such as GIMP into the post-processing workflow, images can be automatically enhanced using all the operations and features that the software has to offer. They can be resized, optimized or otherwise edited in one single step without any manual intervention. All this is achieved by writing small programs in a language called “Script-Fu” and applying these programs to a set of input images.

Non-technical requirements
The GIMP batch-mode uses a scripting language called “Script-Fu”. A script written in this language is a small program which instructs the software on how to manipulate a given image. GIMP therefore requires knowledge on how to write such a script and how to use the command-line to execute and debug it.

Licensing
Gimp is licensed under the LGPL v3+ and GPLv3+ license.

Files
Binary releases can be downloaded from the GIMP website at.

They usually include an installation assistant which guides the user through the installation process.

Installation Instructions
Installation instructions are available for Unix, Mac OS X, and Windows systems. Please refer to for detailed instructions.

Quick Start Guide
The first step for using GIMP as a command-line tool for image processing is to learn the scripting language “Script-Fu”. The easiest way to learn writing scripts in Script-Fu is to try out the different commands using the Script-Fu console. Just start the GIMP software and in the navigation bar of the graphical user interface choose Filter > Script-Fu > Console. The GIMP documentation provides a tutorial on how to get started with the language and how to write simple scripts:

The following example script takes a filename and some numeric parameters. It opens the respective file, applies the Unsharp Mask filter and saves the image again:

(define (simple-unsharp-mask filename radius amount threshold)

(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))

(drawable (car (gimp-image-get-active-layer image))))

(plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable radius amount threshold)

(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)

(gimp-image-delete image)))

In order to do image processing from the command-line, you usually use GIMP’s Script-Fu batch interpreter. This interpreter is called by using the “-b“ parameter with the GIMP executable:

-b, --batch= Batch command to run (can be used multiple times)

To run the above example, save the script with the .scm extension in the scripts directory. Then run it like this:

gimp -i -b '(simple-unsharp-mask "foo.png" 5.0 0.5 0)' -b '(gimp-quit 0)'

More examples and explanations on how to use the GIMP batch mode can be found here:.

Configuration and Customization
All configuration and customization is achieved by writing scripts that instruct GIMP how to process an image. Details and examples can be found on the documentation website at

Workflow Integration
GIMP can be integrated into any workflow or application that allows the execution of command-line tools. However, the actual execution parameters depend on the script that is executed with the GIMP batch interpreter.

Examples
For examples on how to use the GIMP Batch Mode, please refer to the tutorial provided at and. Additional examples are provided at and.