The Gimp has a wonderful feature that allows you to run it non-interactively (no User Interface) from the ‘command line’. This allows you to write scripts that can be used in the shell!
I have lots of film negatives that have been scanned to the computer and all were saved as .BMP files. I wrote a simple script to open each file, adjust the levels, and save as a .JPG.
; ec-levels-stretch
(define (ec pattern)
(let* ((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let*
(
(filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(new_filename (string-append filename “.jpg”))
(drawable (car (gimp-image-get-active-layer image)))
)
; (gimp-levels-stretch drawable)
(file-jpeg-save 1 image drawable new_filename “” 0.85 0 1 0 “” 0 1 0 1)
(gimp-image-delete image)
)
(set! filelist (cdr filelist))
)
)
)(script-fu-register “ec”
“ec”
“Batch Auto Levels”
“Emery clark”
“Emery Clark”
“2010″
“RGB* GRAY*”)
(script-fu-menu-register “ec”
“/Filters”)
; End script
Put the script in ‘/home/your_username/.gimp-2.6/scripts’ You can run this from the command line by ‘cd /dir/with/images/’ then:
gimp -i -b ‘(ec ” *.png ” )’ -b ‘(gimp-quit 0)’
Read more about batch mode http://www.gimp.org/tutorials/Basic_Batch/. Note: I have tried a modified version of this script and have yet to get it working on the Windows XP command line, please let me know if you can do it. I had to resort to a linux machine.
