I downloaded a script to batch convert images to a .gbr and It's outdated and doesn't work with current version of GIMP. I don't know much about script-fu so when I got the first error "Error: set!: unbound variable: a" I did a search and found out that after GIMP 2.4 when initially defining variables you use "define" and not "set!".
I fixed all those instances and then got this new error "Error: eval: unbound variable: newimage". The error is quite vague on which reference of "newimage" it's talking about so I started changing declared variables from "define" back to "set!" cause I know that give me an error and that means the code hasn't executed the reference of "newimage" it has a problem with.
I changed "filename2" and got the "set!" error which is at the end of the block so I know its something is going in the last block.
I really don't want to go through the script-fu tutorials in the GIMP manual and learn about to maybe get my answer after understanding the code better although I already read some (the only code Im familiar with is C++). I also have a digital painting course I need to get back to so hopefully there is someone who can shed light on this issue. Thanks in advance.
(define (brush-batch load opt name filename spacing location)
(define a(cond (( equal? opt 0 ) ".jpg" )
(( equal? opt 1 ) ".bmp" )
(( equal? opt 2 ) ".xcf" )
(( equal? opt 3 ) ".png" )
(( equal? opt 4 ) ".gif" )))
(let* ((filelist (cadr (file-glob (string-append load "\\*" a) 1)))
(s 1))
(while filelist
(let* (
(loadfile (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE loadfile loadfile)))
)
(gimp-image-flatten image)
(define drawable (gimp-image-get-active-drawable image))
(if (= 1 (car (gimp-selection-is-empty image)))
(gimp-selection-all image))
(gimp-displays-flush)
(gimp-edit-copy (car drawable) )
(define selection-bounds (gimp-selection-bounds image))
(define sx1 (cadr selection-bounds))
(define sy1 (caddr selection-bounds))
(define sx2 (cadr (cddr selection-bounds)))
(define sy2 (caddr (cddr selection-bounds)))
(gimp-image-delete image)
(define swidth (- sx2 sx1))
(define sheight (- sy2 sy1))
(define newimage (gimp-image-new swidth sheight 0))
(define newlayer (gimp-layer-new (car newimage) swidth sheight 1 "newlayer" 100 0))
(gimp-image-add-layer (car newimage) (car newlayer) 0)
(gimp-drawable-fill (car newlayer) 3)
(gimp-edit-paste (car newlayer) 0 )
(gimp-image-flatten (car newimage))
(define active (gimp-image-get-active-drawable (car newimage)))
(gimp-desaturate (car active))
(gimp-image-convert-grayscale (car newimage))
(gimp-displays-flush)
(gimp-selection-all (car newimage))
(define filename2 (string-append location "/" filename (string-append (number->string s))".gbr"
))
(file-gbr-save 1 (car newimage) (car active) filename2 (string-append name (number->string s)) spacing (string-append name (number->string s))))
(define s (+ s 1))
(gimp-image-delete (car newimage))
(define filelist (cdr filelist))))
)
(script-fu-register "brush-batch"
"<Toolbox>/Xtns/Script-Fu/Gimp-talk.com/Brush-batch..."
"turns a folder of files into brush's works with jpg, bmp, xcf, png and gif"
"Karl Ward"
"Karl Ward"
"April 2006"
""
SF-DIRNAME "Load from" ""
SF-OPTION "File Type"'("jpg" "bmp""xcf""png""gif")
SF-STRING "Brush Name" "name"
SF-STRING "File Name" "filename"
SF-ADJUSTMENT "spacing" '(25 0 1000 1 1 1 0)
SF-DIRNAME "SAVE TO FOLDER" "")