Archives for posts with tag: script-fu

I’m currently working on a portfolio website for my dad’s paintings.  He gave me a ton of hi-res images that I needed to scale down to a maximum dimension of 400px.  I wrote this Gimp script to help automate the process:

scale-to-max.scm

(define (scale-to-max infile
                      outfile
                      newmax)
  (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE infile infile)))
         (oldwidth (car (gimp-image-width image)))
         (oldheight (car (gimp-image-height image)))
         (oldmax (max oldwidth oldheight))
         (newwidth (round (/ (* oldwidth newmax) oldmax)))
         (newheight (round (/ (* oldheight newmax) oldmax))))
    (print (string-append "scale-to-max " infile " " (number->string newwidth) "x" (number->string newheight)))
    (gimp-image-scale image newwidth newheight)
    (let* ((drawable (car (gimp-image-get-active-layer image))))
      (gimp-file-save RUN-NONINTERACTIVE image drawable outfile outfile))))

It takes 3 parameters:

  1. Infile
  2. Outfile
  3. Newmax

To run it, put the file in your Gimp scripts folder and then run a command like this:
gimp -i -b '(scale-to-max "<path-to-original>" "<path-to-outfile>" 400)' -b '(gimp-quit 0)'

Blogged with the Flock Browser
Advertisements

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/Gimp.app/Contents/Resources/bin/gimp -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
                              filepattern
                              oilsize
                              edgeamount
                              edgeopacity)
  (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