RSS/Atom feed Twitter
Site is read-only, email is disabled

Script-fu help

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

3 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

Script-fu help ASJF 28 May 21:13
  Script-fu help saulgoode@flashingtwelve.brickfilms.com 28 May 22:01
  Script-fu help RalfGesellensetter 29 May 14:04
ASJF
2007-05-28 21:13:33 UTC (over 17 years ago)

Script-fu help

Hi everybody !

I have made a script to resize picture... but it doesn't work anymore, I have change something but I don't remember what... Can someone help me?
Thanks a lot !

Jeff

Here is my code :

(define (script-fu-image-resize filename f-width f-height f-quality) (let* (
(img 0)
(drw 0)
(height1 0)
(width1 0)
(fileparts (strbreakup filename ".")) )
(set! img (car (file-jpeg-load 1 filename filename))) (set! height1 (car (gimp-image-height img))) (set! width1 (car (gimp-image-width img))) (if (< height1 width1)
(begin
(set! f1-height f-height)
(set! f1-width f-width)
)
)
(if (> height1 width1)
(begin
(set! f1-height f-width)
(set! f1-width f-height)
)
)
;; set image resolution to 72dpi (gimp-image-set-resolution img 72 72) ;; create 'full-size' image
(gimp-image-scale img f1-width f1-height) ;; also flatten image to reduce byte storage even further (set! drw (car (gimp-image-flatten img))) ;; save at quality level of .75 (gimp default) - saves storage (file-jpeg-save 1 img drw
(string-append (car fileparts) "-mini.jpg") (string-append (car fileparts) "-mini.jpg") f-quality 0 0 0 " " 0 1 0 1) )
)

saulgoode@flashingtwelve.brickfilms.com
2007-05-28 22:01:54 UTC (over 17 years ago)

Script-fu help

Quoting ASJF :

Hi everybody !

I have made a script to resize picture... but it doesn't work anymore, I have change something but I don't remember what... Can someone help me?

I suspect that you are using the development version (2.3) of the GIMP and your difficulty is caused by the fact that Script-fu has become more demanding that you follow proper Scheme programming guidelines than it used to be.

In previous versions of Script-fu, you were allowed to 'set!' an undeclared variable and Script-fu would happily go ahead and define it for you. This is no longer acceptable -- you must declare your variables (with either 'define' or 'let*') before you use them.

In particular, you have two variables -- 'f1-height' and 'f1-width' -- which need to be included in your 'let*' block. Once you do this, I think you will find your script to be functional.

RalfGesellensetter
2007-05-29 14:04:47 UTC (over 17 years ago)

Script-fu help

Am Montag 28 Mai 2007 21:13 schrieb ASJF:

I
have change something but I don't remember what... Can someone help me?

Don't you have a working copy? If you don't use a CVS/SVN, you might get help from diff (or kdiff3 if you use KDE).

Otherwise: Thanks for sharing your script ;)