It is currently Thu Jul 04, 2024 11:34 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Problem with a script-fu
PostPosted: Tue Jun 14, 2016 10:45 am  (#1) 
Offline
New Member

Joined: Jun 14, 2016
Posts: 3
Hello,
I want to convert files with the extension .png to .gbr format on batch. To do that I used a script found on the web: brush-batch.scm. This one does not work on my computer that is why I used it to create a new one. My code is lauching but it stops during loading file.
If you can help me to understand why that could be great.

This is my code:
(define (convert-pngtogbr load name location)


(gimp-context-set-foreground '(0 0 0))
(gimp-context-set-background '(255 255 255))
(let* (
(filelist (cadr (file-glob (string-append load "\\*.png") 1)))
(s 1)
)
(while filelist
(let* (
(loadfile (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE loadfile loadfile)))
)
(set! drawable (gimp-image-get-active-drawable image))
(set! filename2 (string-append location "/" name ".gbr"
))
(file-gbr-save 1 image drawable filename2 name 15 name))
(set! s (+ s 1))
(gimp-image-delete (car image))
(set! filelist (cdr filelist))))
)
(script-fu-register "convert-pngtogbr"
"<Toolbox>/Xtns/Script-Fu/PngToGbr..."
"Convert png to gbr"
"XX"
"XX"
"Juin 2016"
""
SF-DIRNAME "Load from" ""
SF-STRING "Brush Name" "name"
SF-DIRNAME "SAVE TO FOLDER" "")


Thank you very much
Best regards
Tahoser


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Problem with a script-fu
PostPosted: Tue Jun 14, 2016 11:24 am  (#2) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
It's so much easier to read if you put it in [ code ] tags:
(define (convert-pngtogbr load name location)
  (gimp-context-set-foreground '(0 0 0))
  (gimp-context-set-background '(255 255 255))
  (let*
    (
      (filelist (cadr (file-glob (string-append load "\\*.png") 1)))
      (s 1)
    )
    (while filelist
      (let*
        (
          (loadfile (car filelist))
          (image (car (gimp-file-load RUN-NONINTERACTIVE loadfile loadfile)))
        )
        (set! drawable (gimp-image-get-active-drawable image))
        (set! filename2 (string-append location "/" name ".gbr"))
        (file-gbr-save 1 image drawable filename2 name 15 name)
      )
      (set! s (+ s 1))
      (gimp-image-delete (car image))
      (set! filelist (cdr filelist))
    )
  )
)

(script-fu-register "convert-pngtogbr"
"<Toolbox>/Xtns/Script-Fu/PngToGbr..."
"Convert png to gbr"
"XX"
"XX"
"Juin 2016"
""
SF-DIRNAME "Load from" ""
SF-STRING "Brush Name" "name"
SF-DIRNAME "SAVE TO FOLDER" "")


I've not tried it, but one obvious problem is that you've not defined drawable or filename2 before using them.

Kevin


Top
 Post subject: Re: Problem with a script-fu
PostPosted: Wed Jun 15, 2016 4:28 am  (#3) 
Offline
New Member

Joined: Jun 14, 2016
Posts: 3
Thank you for your information about code tag. I will use it now.

filename2 is defined as that:
(set! filename2 (string-append location "/" name ".gbr"))


and drawable as that:
(set! drawable (gimp-image-get-active-drawable image))


The problem seems to come from uploading file. On the screen, the dialog box closes at that time.

Thank you

Best regards
Tahoser


Top
 Post subject: Re: Problem with a script-fu
PostPosted: Wed Jun 15, 2016 5:21 am  (#4) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
tahoser wrote:
Thank you for your information about code tag. I will use it now.

filename2 is defined as that:
(set! filename2 (string-append location "/" name ".gbr"))


and drawable as that:
(set! drawable (gimp-image-get-active-drawable image))



No!

You have to define something BEFORE you use set!

otherwise you get this:
> (set! fred 1)
Error: set!: unbound variable: fred


Kevin


Top
 Post subject: Re: Problem with a script-fu
PostPosted: Wed Jun 15, 2016 8:21 am  (#5) 
Offline
New Member

Joined: Jun 14, 2016
Posts: 3
OK. Do you have an example?
I join the code I used because I did not understand where and how I have to do what you said.

Thank you


Attachments:
File comment: Code
brush_batch.scm [2.3 KiB]
Downloaded 97 times
Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Looking for Script Coder to make Script of my VHS effect

2

No new posts Attachment(s) A liitle Start Help with a Script-Fu Script

3

No new posts Attachment(s) Cannot run test script-fu script via console

7

No new posts Attachment(s) Script-fu

6

No new posts Attachment(s) Rotate Hue Script

74



* Login  



Powered by phpBB3 © phpBB Group