Saturday, November 24, 2007

Automatic Picture Manipulation with The GIMP

We like sepia-tone pictures, especially for romantic stuff like weddings. In case you ever have a thousand or even ten pictures you'd like to see in sepia, try this script for The GIMP instead of pointing and clicking:

(define (batch-old-photo 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)))
(drawable (car (gimp-image-get-active-layer image))))
(script-fu-old-photo
image
drawable
TRUE
0
TRUE
FALSE
FALSE)
(set! drawable (car (gimp-image-get-active-layer image)))
(gimp-file-save RUN-NONINTERACTIVE
image drawable filename filename)
(gimp-image-delete image))
(set! filelist (cdr filelist)))))

You can use this script by:
  1. save everything between the parentheses above in a file named ~/.gimp-2.2/scripts/batch-old-photo.scm
  2. copy the files you'd like to convert to sepia to a new directory. WARNING: this script modifies the files it's reading, so make sure you've made copies or your originals will be gone
  3. change into that directory and execute:
gimp -i -b '(batch-old-photo "*.jpg")' -b '(gimp-quit 0)'

For more on the basics of scripting The GIMP, see their tutorial.

Enjoy your new old-timey photos.

1 comment:

Anonymous said...

Weird romantic in sepia?
That´s not romantic, just obsolete stuff, also useless!