Search code examples
schemegimpscript-fu

Compare image width to number fails


This script fails at the if statement with "Error: ( : 1) >: argument 2 must be: number", why?

(define x 1500)

(if(> x (gimp-image-width image))
(set! x (gimp-image-width image))
)

Is there any good reference on version of Scheme used in GIMP?


Solution

  • When you try it in the script-fu console gimp-image-width returns a list and not a number:

    (gimp-image-width 1)
    (400)
    

    So you have to extract the element of the list:

    (define x 1500)
    (if(> x (car (gimp-image-width 1)))
    (set! x (gimp-image-width 1))
    )
    

    As a side note, if you are starting writing Gimp scripts, use Python, it is much easier:

    width=min(1500,image.width)