[Gimp-user] script-fu plugin
Bernd Weber
weber.freiburg at freenet.de
Tue Sep 30 03:36:47 PDT 2008
Hi,
I checked your script a little. I have to admit, that I don't know
scheme very much, because I don't like LISP very much (Lots of
Irritating Superfluous Parentheses). I rather work with perl-gimp. But
there is an error in your script. Scheme has a built-in function cons.
Cons needs two arguments. There is only given one:
(if (= tmp TRUE)
(set! viewable (append viewable (cons (aref all-layers
(- i 1))))))
To make it clearer: The one argument is: aref all-layers (- i 1)
I don't know which argument to give as second. It would take me a while
to figure it out.
One other thing is disturbing: In the register-function isn't given if
it is a stand allone script or if it should work on an image. I assumed
it should work on an image.
To test your script I set: "<Image>/Script-Fu/_Copy mask"
.
May be in special cases, the function aref provides twp arguments for
cons, for example if you have sufficient layers and layer masks, but in
others it doesn*t. Anyhow the error isn't caught.
I am working with LINUX, so you see that the error is OS-Independent.
Greetings
Bernd
gimp-user-request at lists.XCF.Berkeley.EDU schrieb:
> Send Gimp-user mailing list submissions to
> gimp-user at lists.XCF.Berkeley.EDU
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
> or, via email, send a message with subject or body 'help' to
> gimp-user-request at lists.XCF.Berkeley.EDU
>
> You can reach the person managing the list at
> gimp-user-owner at lists.XCF.Berkeley.EDU
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Gimp-user digest..."
>
>
> Today's Topics:
>
> 1. script-fu plugin (Adonj Adonj)
> 2. Re: script-fu plugin (peter kostov)
> 3. Re: Best way to semi-flatten a transparent gif against a
> background image (Justyn Butler)
> 4. Script-fu (Adonj Adonj)
> 5. Re: Best way to semi-flatten a transparent gif against a
> background image (David Gowers)
> 6. Re: script-fu plugin (saulgoode at flashingtwelve.brickfilms.com)
> 7. Re: Gimp-user Digest, Vol 72, Issue 22 (Mike W)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 28 Sep 2008 00:03:52 -0400
> From: Adonj Adonj <adonj at hotmail.com>
> Subject: [Gimp-user] script-fu plugin
> To: "gimp-user at lists.XCF.Berkeley.EDU"
> <gimp-user at lists.xcf.berkeley.edu>
> Message-ID: <BLU111-W277D9077C61273FC73D866A1410 at phx.gbl>
> Content-Type: text/plain; charset="iso-8859-1"
>
>
>
> I'm using gimp2.4.7 in windows XP. I copied a script-fu plugin I found to my C:\Program Files\GIMP-2.0\lib\gimp\2.0\plug-ins, which should
> copy a layer mask to multiple layers or apply a layer mask to multiple layers.
> I get an error each time I make an attempt to use it, which states:
> "Error: cons: needs 2 argument(s)"
> I'm not familiar with the script. Could there be a simple solution to that?
> Here is the script:
>
> ; This program is free software; you can redistribute it and/or modify
> ; it under the terms of the GNU General Public License as published by
> ; the Free Software Foundation; either version 2 of the License, or
> ; (at your option) any later version.
> ;
> ; This program is distributed in the hope that it will be useful,
> ; but WITHOUT ANY WARRANTY; without even the implied warranty of
> ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> ; GNU General Public License for more details.
> (define (script-fu-copy-mask-to-layers image drawable)
> (define (visible-layers img)
> (let* (
> (all-layers (gimp-image-get-layers img))
> (i (car all-layers))
> (viewable ())
> (tmp FALSE))
> (set! all-layers (cadr all-layers))
> (while (> i 0)
> (set! tmp (car (gimp-drawable-get-visible (aref
> all-layers (- i 1)))))
> (if (= tmp TRUE)
> (set! viewable (append viewable (cons (aref all-layers
> (- i 1))))))
> (set! i (- i 1)))
> viewable))
> (let* (
> (active-layer (car (gimp-image-get-active-layer image)))
> (source-layer)
> (source-mask)
> (layers)
> (mask))
> (set! layers (visible-layers image))
> (gimp-image-undo-group-start image)
> (set! source-layer (car (gimp-layer-new-from-drawable
> active-layer image)))
> (gimp-image-add-layer image source-layer -1)
> (set! source-mask (car (gimp-layer-get-mask source-layer)))
> (if (= source-mask -1)
> (begin
> (set! source-mask (car (gimp-layer-create-mask
> source-layer ADD-COPY-MASK)))
> (gimp-layer-add-mask source-layer source-mask)))
> (while (car layers)
> (if (= (car (gimp-layer-get-mask (car layers))) -1)
> (if (= (car (gimp-drawable-has-alpha (car layers))) 1)
> (set! mask (car (gimp-layer-add-mask (car layers)
> source-mask)))))
> (set! layers (cdr layers)))
> (gimp-image-remove-layer image source-layer)
> (gimp-image-undo-group-end image)
> (gimp-displays-flush)))
> (script-fu-register "script-fu-copy-mask-to-layers"
> "/Script-Fu/_Copy mask"
> "Copy the mask from the current layer to all visible layers"
> "Saul Goode"
> "Saul Goode"
> "6/14/2006"
> ""
> SF-IMAGE "Image" 0
> SF-DRAWABLE "Drawable" 0
> )
>
> _________________________________________________________________
>
>
>
> ------------------------------
>
> Message: 2
> Date: Sun, 28 Sep 2008 11:28:50 +0300
> From: peter kostov <gimp at light-bg.com>
> Subject: Re: [Gimp-user] script-fu plugin
> To: Adonj Adonj <adonj at hotmail.com>
> Cc: "gimp-user at lists.XCF.Berkeley.EDU"
> <gimp-user at lists.xcf.berkeley.edu>
> Message-ID: <48DF4042.6090205 at light-bg.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Adonj Adonj wrote:
>
>> I'm using gimp2.4.7 in windows XP. I copied a script-fu plugin I found to my C:\Program Files\GIMP-2.0\lib\gimp\2.0\plug-ins, which should
>> copy a layer mask to multiple layers or apply a layer mask to multiple layers.
>> I get an error each time I make an attempt to use it, which states:
>> "Error: cons: needs 2 argument(s)"
>> I'm not familiar with the script. Could there be a simple solution to that?
>> Here is the script:
>>
>> ; This program is free software; you can redistribute it and/or modify
>> ; it under the terms of the GNU General Public License as published by
>> ; the Free Software Foundation; either version 2 of the License, or
>> ; (at your option) any later version.
>> ;
>> ; This program is distributed in the hope that it will be useful,
>> ; but WITHOUT ANY WARRANTY; without even the implied warranty of
>> ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> ; GNU General Public License for more details.
>> (define (script-fu-copy-mask-to-layers image drawable)
>> (define (visible-layers img)
>> (let* (
>> (all-layers (gimp-image-get-layers img))
>> (i (car all-layers))
>> (viewable ())
>> (tmp FALSE))
>> (set! all-layers (cadr all-layers))
>> (while (> i 0)
>> (set! tmp (car (gimp-drawable-get-visible (aref
>> all-layers (- i 1)))))
>> (if (= tmp TRUE)
>> (set! viewable (append viewable (cons (aref all-layers
>> (- i 1))))))
>> (set! i (- i 1)))
>> viewable))
>> (let* (
>> (active-layer (car (gimp-image-get-active-layer image)))
>> (source-layer)
>> (source-mask)
>> (layers)
>> (mask))
>> (set! layers (visible-layers image))
>> (gimp-image-undo-group-start image)
>> (set! source-layer (car (gimp-layer-new-from-drawable
>> active-layer image)))
>> (gimp-image-add-layer image source-layer -1)
>> (set! source-mask (car (gimp-layer-get-mask source-layer)))
>> (if (= source-mask -1)
>> (begin
>> (set! source-mask (car (gimp-layer-create-mask
>> source-layer ADD-COPY-MASK)))
>> (gimp-layer-add-mask source-layer source-mask)))
>> (while (car layers)
>> (if (= (car (gimp-layer-get-mask (car layers))) -1)
>> (if (= (car (gimp-drawable-has-alpha (car layers))) 1)
>> (set! mask (car (gimp-layer-add-mask (car layers)
>> source-mask)))))
>> (set! layers (cdr layers)))
>> (gimp-image-remove-layer image source-layer)
>> (gimp-image-undo-group-end image)
>> (gimp-displays-flush)))
>> (script-fu-register "script-fu-copy-mask-to-layers"
>> "/Script-Fu/_Copy mask"
>> "Copy the mask from the current layer to all visible layers"
>> "Saul Goode"
>> "Saul Goode"
>> "6/14/2006"
>> ""
>> SF-IMAGE "Image" 0
>> SF-DRAWABLE "Drawable" 0
>> )
>>
>>
> Isn't that a script rather a plug-in? If so it should reside in the
> scripts folder... But this is gust a guess. I am not familiar with
> script-fu eithe :(
>
> Peter
>
>> _________________________________________________________________
>>
>> _______________________________________________
>> Gimp-user mailing list
>> Gimp-user at lists.XCF.Berkeley.EDU
>> https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
>>
>>
>
>
>
More information about the Gimp-user
mailing list