(define (num2str x y) (let* ((s (number->string x)) (len (string-length s))) (while (< len y) (set! s (string-append "0" s)) (set! len (+ 1 len))) s)) (define (string-ref t i) (substring t i (+ 1 i))) (define (script-fu-uglify-all path prefix newPrefix extension minInd maxInd x1 y1 x2 y2 inter) (let ((inter (if (= 0 inter) 1 0)) (fullPath (if (= 0 (strcmp "" path)) "./" (if (= 0 (strcmp (string-ref path (- (string-length path) 1)) "/")) path (string-append path "/")))) (i minInd)) (while (<= i maxInd) (let* ((oldName (string-append prefix (num2str i 3) "." extension)) (oldFullName (string-append fullPath oldName)) (newName (string-append newPrefix (num2str i 3) ".xbm")) (newFullName (string-append fullPath newName)) (pic (car (gimp-file-load inter oldFullName oldName))) (disp (if (= 0 inter) (car (gimp-display-new pic))) 0) (draw (car (gimp-image-active-drawable pic)))) ; insert conversions here: (gimp-convert-indexed pic 0 3 2 0 0 "") (gimp-crop pic (- x2 x1) (- y2 y1) x1 y1) (gimp-selection-none pic) (plug-in-rotate inter pic draw 3 1) ; end of conversions ; save procedure: (file-xbm-save inter pic draw newFullName newName "" 0 0 0 "" 0 "") (if (= 0 inter) (gimp-display-delete disp) (gimp-image-delete pic)) (set! i (+ 1 i)))))) (script-fu-register "script-fu-uglify-all" "/Xtns/Script-Fu/Misc/Uglify All" "Take all images from path starting with prefix and continuing with three digits from range min to max inclusive and transform them to 2 colors, rotate 270 deg and save to xbm. When interactive nonzero, progress is shown on the screen with prompts (slow)." "Petr Zika" "2002, Petr Zika" "5.11.2002" "" SF-VALUE "File path:" "\"\"" SF-VALUE "File prefix" "\"thr\"" SF-VALUE "File new prefix" "\"ahr\"" SF-VALUE "File ext:" "\"tiff\"" SF-VALUE "File min range:" "0" SF-VALUE "File max range:" "0" SF-VALUE "Start x:" "40" SF-VALUE "Start y:" "40" SF-VALUE "End x:" "2300" SF-VALUE "End y:" "2850" SF-VALUE "Interactive:" "0" )