Hi,

I try to write a gimp-fu script to save the current image as a gif.
I found a sample script on the web that seems to fit:
--------------------------------------------------------
(define (script-fu-glogo-simple2 srcimg dummy filename)
        (let*
                (
                        (img2   (car (gimp-channel-ops-duplicate srcimg)))
                        (img16  (car (gimp-channel-ops-duplicate srcimg)))
                        (img224 (car (gimp-channel-ops-duplicate srcimg)))
                        (drawa  (car (gimp-image-active-drawable srcimg)))
                        (drcol  (car (gimp-drawable-color drawa)))
                )
                ;
                ; Set names to the images (debug-info)
                ;
                (gimp-image-set-filename img2   "glogo-bw")
                (gimp-image-set-filename img16  "glogo-16")
                (gimp-image-set-filename img224 "glogo-224")
                ;
                ; Resize (i.e. scale) them all
                ;
                (gimp-image-scale img2   80 80)
                (gimp-image-scale img16  80 80)
                (gimp-image-scale img224 80 80)
                ;
                ; Convert them to RGB if they are not
                ;
                (if (= drcol 0)
                        (begin
                                (gimp-convert-rgb img2)
                                (gimp-convert-rgb img16)
                                (gimp-convert-rgb img224)
                        )
                )
                ;
                ; Flatten it
                ;
                (gimp-image-flatten img2)
                (gimp-image-flatten img16)
                (gimp-image-flatten img224)
                ;
                ; Now change the palletes
                ;
                (gimp-convert-indexed-palette img2   1 3 0   "")
                (gimp-convert-indexed-palette img16  1 0 16  "")
                (gimp-convert-indexed-palette img224 1 0 224 "")
                ;
                ; Save it as gifs (not needed anymore)
                ;
;               (file-gif-save 1 img2   (car (gimp-image-active-drawable img2))
;                                       "/tmp/x-2.gif"   "/tmp/x-2.gif"   0 0 0 
0)
;               (file-gif-save 1 img16  (car (gimp-image-active-drawable img16))
;                                       "/tmp/x-16.gif"  "/tmp/x-16.gif"  0 0 0 
0)
;               (file-gif-save 1 img224 (car (gimp-image-active-drawable 
img224))
;                                       "/tmp/x-224.gif" "/tmp/x-224.gif" 0 0 0 
0)
                ;
                ; Save it as linux boot logo
                ;
;               (gimp-message (string-append "Debug-Info: img2=" 
(number->string img2 10)
;                                            " img16=" (number->string img16 10)
;                                            " img224=" (number->string img224 
10)))
                (extension-linux-logo 1 filename
                                      (car (gimp-image-active-drawable img2))
                                      (car (gimp-image-active-drawable img16))
                                      (car (gimp-image-active-drawable img224)) 
)
                ;
                ; Free the images
                ;
                (gimp-image-delete img2)
                (gimp-image-delete img16)
                (gimp-image-delete img224)
        )
)

(script-fu-register "script-fu-glogo-simple2"
        "<Image>/Script-Fu/Save as Linux Boot Logo2"
        "Saves any given image as Linux Boot Logo2"
        "Clifford Wolf"
        "Clifford Wolf"
        "Aug 1998"
        ""
        SF-IMAGE "Image to Glogo Simple" 0
        SF-DRAWABLE "Drawable to Glogo Simple" 0
        SF-VALUE "File Name" "/tmp/x.gif"
)
--------------------------------------------------------
(In the script file-gif-save is commented out, 
it fails at refresh, if not commented out)

However when I run this script I get following error message:
Script-Fu error when executing (script-fu-glogo-simple2 35 219 /tmp/x.gif
Error: unbound variable (errobj /tmp/x.gif)

I found in the tutorial following hint:
http://www.seul.org/~grumbel/gimp/script-fu/script-fu-tut.html
-----------------------------------------------------------------------
You might also want to open a directory and open all the images in it. Not even 
that is possible. The SIOD webpage describes the opendir function, but when you 
try it in Script-Fu it will not work as many other SIOD function.
=> (opendir "/")
ERROR: unbound variable (errobj opendir)
To solve this you have to work-around this by dumping the directory contents to 
a file and read that file instead, or you can write a Perl-Fu, Python-Fu or a 
Gimp Plug-in.
---------------------------------------------------------------------

Does this mean, I will never be able to save any files in script-fu?

I have no chance to use perl or python, because perl needs gimptool, I do not
have, and python for gimp tool can not be found on the web.

Thanks in advance for any hint,
-eleonora

-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply via email to