Gimp's scheme code to extract text from layers

Discussion of Scheme and Racket

Gimp's scheme code to extract text from layers

Postby christian urgese » Wed Feb 08, 2017 1:01 pm

I'm a newbe, what goes wrong in this scheme script?
"gimp -n -i -b - <<EOF
(let* ((ff (cadr (file-glob "*.xcf" 1)))) (filename "") (image 1) (layer 0))
(while (not (null? ff))
(set! image (car (gimp-file-load RUN-NONINTERACTIVE (car ff) (car ff) )))
(set! layer (vector-ref (cadr (gimp-image-get-layers image)) 0))
(set! layers (car (gimp-image-get-layers image)))
(set! visible (car (gimp-drawable-get-visible layer)))
(set! filename (string-append (substring (car ff) 0 (- (string-length (car ff)) 4)) "_del.xcf"))

(while (>= layers 0)
(if (= visible 0) (gimp-drawable-delete layer))
(set! layer (vector-ref (cadr (layer image)) 0))
(set! layers (- layers 1))))

(gimp-file-save RUN-NONINTERACTIVE image image filename filename)
(gimp-image-delete image)
(set! ff (cdr ff))
)
(gimp-quit 0)
)

EOF"
christian urgese
 
Posts: 1
Joined: Wed Feb 08, 2017 12:57 pm

Re: Gimp's scheme code to extract text from layers

Postby peterlane » Fri Feb 10, 2017 5:03 pm

I don't know Gimp, but your bracketing is off.

christian urgese wrote:(let* ((ff (cadr (file-glob "*.xcf" 1)))) (filename "") (image 1) (layer 0))


For example, write the start like this:

Code: Select all
(let* ((ff (cadr (file-glob "*.xcf" 1)))) <-- you have one too many close brackets here, they should only close up to the one before 'ff'
                  (filename "")
                  (image 1)
                  (layer 0)) <-- leaving this one to close off the one before the one before 'ff'.


Should the sccond while loop be 'within' the first while loop, as it is now, or in sequence with it? If in sequence, you need an extra close bracket after (set! filename ...)

The close brackets before and after (gimp-quit 0) do not match anything.

I suggest you put your code into a scheme aware editor, which will match up and indent according to your brackets.
peterlane
 
Posts: 6
Joined: Wed Jan 18, 2017 5:34 am


Return to Scheme

Who is online

Users browsing this forum: No registered users and 3 guests