(define (batch-scale 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)))) (let* ( (max-length 480) (image-width (car (gimp-image-width image))) (image-height (car (gimp-image-height image))) (scale-factor (/ max-length image-height)) (final-width (* scale-factor image-width)) (final-height (* scale-factor image-height)) ) (if (< image-height image-width) (begin (set! scale-factor (/ max-length image-width)) (set! final-width (* scale-factor image-width)) (set! final-height (* scale-factor image-height)) ) ) (gimp-image-scale image final-width final-height) ) (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename) (gimp-image-delete image)) (set! filelist (cdr filelist)))))