; eseguire nella cartella con le immagini da trattare: ; ; gimp -i -b '(batch-format-convert "*.jpg" ".png")' -b '(gimp-quit 0)' ; ; input: *.jpg *.gif *.tiff *.png *.xcf ; output: .jpg .gif .tiff .png ; (define (batch-format-convert pattern-in format-out) (let* ( (filelist (cadr (file-glob pattern-in 1))) (fmt-out format-out) ) (while (not (null? filelist)) (let* ( (filename (car filelist)) (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))) (drawable (car (gimp-image-flatten image))) ) (if (and (equal? fmt-out ".gif") (not (= (car(gimp-drawable-type drawable)) INDEXED-IMAGE) ) ) (gimp-convert-indexed image FS-DITHER MAKE-PALETTE 256 FALSE TRUE "aaa") ) (if (and (equal? fmt-out ".jpg") (not (= (car(gimp-drawable-type drawable)) RGB-IMAGE) ) ) (gimp-convert-rgb image) ) (set! filename (string-append (substring filename 0 (- (string-length filename) (- (string-length pattern-in) 1) ) ) "_out" fmt-out ) ) (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename) (gimp-image-delete image) ) (set! filelist (cdr filelist)) ) ) )