Post Reply 

Script-Fu Difficulties

Nov 22, 2011, 03:37
Post: #1
Script-Fu Difficulties
I've been racking my brain all day over the creation of a script. My ultimate goal is to take a folder of images and mass apply a scale2x filter to them and then save the results. So as not to accidentally destroy my original images (which I've already done several times due to GIMP loading random directories when no directory was specified in the script), I'm now setting it up to ask the user a directory to load from and save to.

I've devised what I have so far based off reading various other example scripts. This is my current version:

(define (batch-scale2x inDir outDir)

(let* ((filelist (cadr (file-glob (string-append inDir "\\*") 1))))
    (while (not (null? filelist))
        (let* ((filename (car filelist))
                        (short_filename (substring filename (+ (string-length inDir)

1) (- (string-length filename) 4)))
            (image (car (gimp-file-load RUN-NONINTERACTIVE filename

            (drawable (car (gimp-image-get-active-layer image))))
        (python-fu-scale2x RUN-NONINTERACTIVE image drawable)
        (set! drawable (car (gimp-image-get-active-layer image)))
                (newfilename (string-append outDir "\\" short_filename ".png"))
        (gimp-file-save RUN-NONINTERACTIVE image drawable newfilename

        (gimp-image-delete image))
    (set! filelist (cdr filelist)))))

My issue right now is that I'm being told that "newfilename" is an unbounded variable so it errors while trying to save the resultant file. Any ideas on what I did wrong?
Find all posts by this user
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Script Fu top menu Dutchy 1 214 Feb 7, 2019 12:23
Last Post: paynekj
  Run script on action rchav 2 1,417 Aug 13, 2018 14:57
Last Post: rchav
  Script Fu Errors Gimp 2.10.4 lightsaber jd3481 1 960 Aug 2, 2018 05:13
Last Post: paynekj
  Script-fu script to conversion pdf to image 4ever 12 15,210 Jul 17, 2018 16:01
Last Post: paynekj
  Problems with a bat script :( ThaUnknown_ 1 723 Mar 26, 2018 21:14
Last Post: paynekj

Forum Jump:

GIMP ForumPortalArchiveContactTermsRSS