You are here

[solved] Need fix for a script-fu (illegal function)

Hello,

I am a newbie trying to create some script-fu to make my activities easier and have a problem with a very simple resizing script. Gimp says I use an illegal function and after looking for the solution, it looks like I don't really use the good syntax. Could someone help me ? Here is the code :


; Vignette : resize to 250px max
; CC-BY-SA anxest
; This software is released under the terms of the
; GNU General Public License version 3.0 or later
(define (vignette image drawable)
(let* (
(newwidth 0)
(newheight 0)
(oldwidth (car (gimp-image-width image)))
(oldheight (car (gimp-image-height image)))
(newdpi 72)
)
(cond
((>= oldwidth oldheight)
((set! newwidth 250)
(set! newheight (round (/ (* newwidth oldheight) oldwidth)))))
(else
(set! newheight 250)
(set! newwidth (round (/ (* newheight oldwidth) oldheight)))))
(gimp-image-undo-group-start image)
(gimp-image-scale image newwidth newheight)
(gimp-image-set-resolution image newdpi newdpi)
(gimp-image-undo-group-end image)
))

(define (newdpi filename output newwidth newheight)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image)))
)
(newdpi image drawable newwidth newheight)
(gimp-file-save RUN-NONINTERACTIVE image drawable output output)
(gimp-image-delete image)
))

(define (newdpi_multi pattern outdir newwidth newheight)
(let* ((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let* ((filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image)))
(outf (string-append outdir "/" filename)))
(newdpi image drawable newwidth newheight)
(gimp-file-save RUN-NONINTERACTIVE image drawable outf outf)
(gimp-image-delete image))
(set! filelist (cdr filelist)))))

(script-fu-register "vignette"
"/Script-Fu/vignette"
"Resize to 250px max"
"Anxest"
"Anxest"
"2012-03-16"
"RGB*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)

For your information, I'm working with Gimp 2.6.11 on Windows 7 (64)

All I did was to put all the indenting in so I could read it and change the menu registration point to a valid position and I didn't get an error message. (Using GIMP 2.6.7 on Windows XP which shouldn't make any difference to the version you are using.)

; Vignette : resize to 250px max
; CC-BY-SA anxest
; This software is released under the terms of the
; GNU General Public License version 3.0 or later
(define (vignette image drawable)
  (let* (
         (newwidth 0)
         (newheight 0)
         (oldwidth (car (gimp-image-width image)))
         (oldheight (car (gimp-image-height image)))
         (newdpi 72)
        )
        (cond
          ( (>= oldwidth oldheight) ( (set! newwidth 250) (set! newheight (round (/ (* newwidth oldheight) oldwidth)))) )
          (else
            (set! newheight 250)
            (set! newwidth (round (/ (* newheight oldwidth) oldheight)))
          )
        )
        (gimp-image-undo-group-start image)
        (gimp-image-scale image newwidth newheight)
        (gimp-image-set-resolution image newdpi newdpi)
        (gimp-image-undo-group-end image)
  )
)

(define (newdpi filename output newwidth newheight)
     (let* (
             (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
             (drawable (car (gimp-image-get-active-layer image)))
           )
           (newdpi image drawable newwidth newheight)
           (gimp-file-save RUN-NONINTERACTIVE image drawable output output)
           (gimp-image-delete image)
     )
)

(define (newdpi_multi pattern outdir newwidth newheight)
   (let* (
           (filelist (cadr (file-glob pattern 1)))
         )
      (while (not (null? filelist))
        (let* (
               (filename (car filelist))
               (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
               (drawable (car (gimp-image-get-active-layer image)))
               (outf (string-append outdir "/" filename))
            )
            (newdpi image drawable newwidth newheight)
            (gimp-file-save RUN-NONINTERACTIVE image drawable outf outf)
            (gimp-image-delete image))
            (set! filelist (cdr filelist))
      )
    )
 )

(script-fu-register "vignette"
"<Image>/contributed/vignette"
"Resize to 250px max"
"Anxest"
"Anxest"
"2012-03-16"
"RGB*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)

And unhelpfully the forum has interpreted the <Image> as formatting and probably removed it from your code.

There exist already a vignette script so don't call it vignette. After modifying vignette the script is in my procedure database but it is not visible in the filtersection. Where did you put it??

Out of curiosity what is the script to do

Subscribe to Comments for "[solved] Need fix for a script-fu (illegal function)"