Le 26/05/2015 23:43, Saul Goode a écrit :
The following code will work on GNU/Linux systems. It will only process the 
filesin the current directory (it will not recurse into subdirectories).

What is that for a lisp-like code ?

JL


gimp -i -f -b - <<HERE
   (let ((outdir "/tmp/destdir") ; <<== change this to the destination folder 
(which MUST exist)
         (patterns '("*.gif" "*.jpg" "*.png")))
     (when (and (file-exists? outdir) (= (file-type outdir) 2))
       (let loop ((filepaths (foldr  append '() (map (lambda (x) (cadr 
(file-glob x 1))) patterns))))
         (unless (null? filepaths)
           (let* ((filepath (car filepaths))
                  (image (catch #f (car (gimp-file-load RUN-NONINTERACTIVE
                                                        filepath
                                                        filepath ))))
                  (layer (if image (car (gimp-image-get-active-layer image)) 
#f))
                  (filename (string-append outdir
                                           DIR-SEPARATOR
                                           (car (last (strbreakup filepath 
DIR-SEPARATOR))))))
             (unless (null? filepaths)
               (when image
                 (let* ((w (car (gimp-image-width image)))
                        (h (car (gimp-image-height image)))
                        (aspect (/ h w))
                        (factor (/ (max w h) 1000)))
                   (when (> factor 1)
                     (gimp-image-scale image (/ w factor) (/ h factor))
                     (set! w (car (gimp-image-width image)))
                     (set! h (car (gimp-image-height image))))
                   (if (< w h)
                     (gimp-image-resize image (max w h) (max w h) (/ (- h w) 2) 
0)
                     (gimp-image-resize image (max w h) (max w h) 0 (/ (- w h) 
2))))
                 (gimp-file-save 1 image (car (gimp-image-flatten image)) 
filename filename)
                 (gimp-image-delete image))
               (loop (cdr filepaths)))))))
     (gimp-quit 0))
HERE

_______________________________________________
gimp-user-list mailing list
List address:    gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list



_______________________________________________
gimp-user-list mailing list
List address:    gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list

Reply via email to