Post
Topic
Board Services
Re: Help me with GIMP (0.025BTC reward)
by
ChasingCarsEU
on 29/04/2016, 16:04:18 UTC
(define (batch-resize pattern width height)
(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-image-scale-full image width height INTERPOLATION-CUBIC)
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image))
(set! filelist (cdr filelist)))))

This particular script takes a pattern for filename, desired width and height as inputs and resize all image files that are matched. This script overwrites the existing file. In order to run the script, save it with .scm extension in the ~/.gimp-/scripts/ directory.

Then goto the directory which contains images, then run the following command to resize images:

gimp -i -b '(batch-resize "./pics/*.jpg" 500 500)' -b '(gimp-quit 0)'