First we define a function which contains all the needed procedures. and save the script in
~/.gimp-2.8/scripts
with .scm extension.
In 2.10, the script directory is ~/.config/GIMP/2.10/scripts
(define (batch-reduce-img-size pattern reduceby) (let* ((filelist (cadr (file-glob pattern 1)))) (while (not (null? filelist)) (let* ((filename (car filelist)) (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))) (imageWidth (car (gimp-image-width image))) (imageHeight (car (gimp-image-height image))) (newWidth (* imageWidth reduceby)) (newHeight (* imageHeight reduceby)) (drawable (car (gimp-image-get-active-layer image)))) (gimp-image-scale image newWidth newHeight) (gimp-file-save 1 image drawable filename filename) (gimp-image-delete image)) (set! filelist (cdr filelist)))))
run the script as
gimp -i -b '(batch-reduce-img-size "*.JPG" 0.5)' -b '(gimp-quit 0)
IMPORTANT: The images will get over written
No comments:
Post a Comment