This weekend I got the latest version of Gimp running on my Mac, and started playing with some of the artistic filters.

I came across a combination that results in a look somewhat reminiscent of look of the movie A Scanner Darkly, and decided to write a Gimp script to apply this combination. Then I got curious about applying this to video, and ended up figuring out how to do that. The results are pretty cool looking.

  1. Split your video into frames at 30fps. I used iMovie ’08 to do this.
  2. Run the batch-scanner-gimply command in Gimp to batch-process all the frames. This can be done from the command-line, eg:
    /Applications/ -i -b
    '(batch-scanner-gimply "/Users/chris/Movies/Snorkeling/"
    "Snorkeling*.jpg" 17 50 75)' -b '(gimp-quit 0)'
  3. Use QuickTime 7 Pro to compose the processed frames back into a .mov file
  4. Bring it back into iMovie if you want to add the audio track back in. (Note that iMovie ’08 has hidden the “extract audio” feature, but it’s still there.)

Here’s the scanner-gimply.scm file that needs to go in your Gimp scripts folder:

(define (batch-scanner-gimply folder
  (let* ((filelist (cadr (file-glob (string-append folder filepattern) 1)))
         (dirlength (string-length folder)))
    (print "Start batch-scanner-gimply")
    (while (not (null? filelist))
           (let* ((filepath (car filelist))
                  (filename (substring filepath dirlength (string-length filepath)))
                  (image (car (gimp-file-load RUN-NONINTERACTIVE
                                              filepath filename)))
                  (baselayer (car (gimp-image-get-active-layer image)))
                  (oillayer (car (gimp-layer-copy baselayer FALSE))))
             (print (string-append "Processing " folder filename))
             (gimp-image-add-layer image oillayer -1)
             (plug-in-oilify RUN-NONINTERACTIVE image oillayer oilsize 1)
             (plug-in-edge RUN-NONINTERACTIVE image oillayer edgeamount 1 4)
             (gimp-layer-set-mode oillayer 21)
             (gimp-layer-set-opacity oillayer edgeopacity)
             (gimp-image-flatten image)
             (gimp-file-save RUN-NONINTERACTIVE
                             image (car (gimp-image-get-active-layer image))
                             filepath filename)
             (print (string-append "Saved " filename))
             (gimp-image-delete image))
           (set! filelist (cdr filelist)))))
Blogged with the Flock Browser