Skip to content

Danielle and Roger Blog

  • Cantenna Testing
  • HourChime
  • Cooking
  • St Johns Bach Foundation
April 5, 2015 / IT

Cropping multiple images with Gimp and script-fu

I recently had a series of video screenshots from a Gotomeeting screencapture. The presenter screen had resolution 1366×768; the meeting organiser 1920×1080.

The result was that all the images were surrounded with a black border. In turning the screencapture into a set of stills to represent as narrated video, I used the following in Gimp

  • Start Gimp and enter Filters | Script-fu | Console
  • In the console that comes up, paste the following to define the batch-resize function
(define (batch-resize pattern
                      new-width
                      new-height
                      offx
                      offy)
(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))))
        (gimp-layer-resize drawable new-width new-height offx offy)
        (gimp-image-resize-to-layers image)
        (gimp-file-save RUN-NONINTERACTIVE
                        image drawable filename filename)
        (gimp-image-delete image))
        (set! filelist (cdr filelist)))))

  • Then in the same console you can run the following
(batch-resize "/path/to/screenshots/*png" 1366 768 -272 -157)

Note that this was on a windows system – and the format of the filesystem path is still with forward slash. Note also, this will replace existing files with modified versions.

If you want to perform some other form of processing on each file, the key function to replace is (gimp-layer-resize …)

Form more information, see the Script-fu Tutorial or the Gimp scripting manualIT

Post navigation

Previous Post:

Meal plan Easter 2015

Next Post:

Meal plan w/c 10/5

Recent Posts

  • Slackbot on Raspberry Pi
  • Windows 10 Boot Recovery or Not
  • 20 Minute VC – the schizophrenia of raising v.s. running the business
  • SaaStr 2017
  • Testing Openstack with Ansible and all-in-one install on Hyper-V

Categories

  • 2012 Trip
  • 2014 trip
  • Cooking
  • IT
  • Knitting
  • Radio Control
  • SaaS
  • Uncategorized

Recent Comments

  • roger on Cooking for the cold this week
  • roger on Some things this week
  • danielle on Preserving olives
  • roger on Meal plan w/c 3/12
  • roger on Meal plan w/c 26/11

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2025 Danielle and Roger Blog