houghi <houghi@[EMAIL PROTECTED]
> writes:
> houghi wrote:
>>> To use the "script-fu-fuzzy-border" function in batch
>>> mode you need to first execute the required gimp
>>> functions to load an image by reading one from a file.
>>
>> OK and how do I do that?
>
> OK, I am again loosing several hours over this. I start with
> http://www.gimp.org/tutorials/Basic_Batch/
and that works.
>
> What I see there is absolutely no serious attempt to explain anything.
> It is more a 'How to drive a car? You step in and drive away.' type of
> thing. Pity to see that sch a thing where the GIMP could beat anything
> is so neglected. :-( Anywah ..
>
> I see two places where things are defined. The first is the define of
> simple-unsharp-mask. The second is the plug-in-unsharp-mask.
>
> Let me look at the first thing. There I see respectivaly filename,
> radius, amount and threshold. Those are used as well in the commandline
> with "foo.png" 5.0 0.5 0.
>
> However when I look in Xtns, I see much more parameters. With a lot of
> trial and error I was able to make a sharpen script that worked.
>
> So I then try to re-write it for the fuzzy border and get to the
> following:
> (define (border-fuzz filename
> color
> value
> toggle
> value
> toggle
> value
> toggle
> toggle
> )
> (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename
> filename)))
> (drawable (car (gimp-image-get-active-layer image))))
> (script-fu-fuzzy-border RUN-NONINTERACTIVE
> image drawable
> color
> value
> toggle
> value
> toggle
> value
> toggle
> toggle
> )
> (set! drawable (car (gimp-image-get-active-layer image)))
> (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
> (gimp-image-delete image)))
>
> As command I give the following on one line:
> gimp -i -b '(border-fuzz "foo.png" (0;0;0) 50 0 50 0 0 0 0)' -b
> '(gimp-quit 0)'
>
> It tells me it is successfull and nothing happens. I have no idea where
> I am going wrong as there is no do***entation available. I also doubt
> that I am the only person in the world wjo wants to use gimp in a script
> mode. So please can somebody show me what it must be instead of what I
> have. No explanation, just the raw code. I can then try to fugure out
> myself what I am doing wrong and apply it to other things.
>
> I will then probably even write it all down for others to use.
>
> houghi
> --
> The whole principle [of censor****p] is wrong. It's like demanding that
> grown men live on skim milk because the baby can't have steak.
> -- Robert A. Heinlein in "The Man Who Sold the Moon"
Sorry, not giving the raw code, but code interspersed with comments. I
agree that do***entation on script-fu scripting is poor, and
discoverability low. To aid myself in writing script-fu scripts, I
have written a gimp-mode for Emacs, that helps a lot (by completing
arguments and functions, providing easy access from within the code to
the procedural do***entation, having an interactive REPL, etc.). You may
find that of use (if you already use Emacs), though granted, it is not
yet as stable as I would like it to be and I do not guarantee
flawlessness. It is at http://niels.kicks-ass.org/gimpmode/
If you do not want to use that, in the development thereof, I have
searched the web, and found the following resources to be of use:
http://docs.gimp.org/en/gimp-using-script-fu-tutorial.html
http://www.ve3syb.ca/wiki/doku.php?id=software:sf:start
http://mitpress.mit.edu/sicp/full-text/book/book.html
http://tech.groups.yahoo.com/group/script-fu/
Besides that, Akkana Peck's book on the GIMP also has a part on script-fu.
And you can of course always browse the procedural browser inside the
GIMP and have a script-fu console to test your scripts interactively,
though its usability is quite low (hence gimp-mode). And be wary of
the RUN-(NON)INTERACTIVE argument to be left out (gimp-mode simply
strips these arguments from the do***entation so as not to confuse us
poor script-fu coders).
Another way of debugging your scripts is turning tracing on, by issuing
(tracing TRUE), so, for instance:
gimp -ic -b "(begin (tracing TRUE) (your code ... ) (gimp-quit
RUN-NONINTERACTIVE))"
and you can turn it off with (tracing FALSE).
;; the code: (comments run from a semicolon to end of line, and are
;; ignored by the scheme reader)
(define (border-fuzz filename
color
border-size
blur-border?
granularity
add-shadow?
shadow-weight
;; As you are saving to the same file again,
;; working on a copy is nonsense, so do not ask
;; for work-on-copy?
;;work-on-copy?
;; You will always want to flatten your image, as
;; you are performing batch mode, so we will
;; simply pass the value TRUE to
;; script-fu-fuzzy-border for flatten-image argument. (If
;; given value FALSE, you'll end up with a black
;; image).
;;flatten-image?
)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename
filename)))
(drawable (car (gimp-image-get-active-layer image))))
(script-fu-fuzzy-border
;; As I said in an earlier post, script-fu calling script-fu
;; leaves out first RUN-(NON)INTERACTIVE argument. Commented out
;; RUN-NONINTERACTIVE
image
drawable
color
border-size
blur-border?
granularity
add-shadow?
shadow-weight
;; see first comment
FALSE
;; see first comment
TRUE)
(set! drawable (car (gimp-image-get-active-layer image)))
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image)))
;; Example of usage:
(border-fuzz "/home/sharik/Pictures/skrinka.jpg"
;; this is how we specify a color (a semicolon means the
;; rest of the line is to be seen as a comment, so
;; '(0;0;0) was incorrect) :
'(0 0 0)
50
0
;; (max value for granularity in script-fu-fuzzy-border is 16)
16
FALSE
;; (though minimum value says 0, this results in a
;; division by zero; this looks like a bug in
;; script-fu-fuzzy-border so maybe we should file a re****t.)
1
;; as said in first comment, work-on-copy should always
;; be FALSE, and flatten-image should always be TRUE, so
;; getting rid of these arguments.
)
From bash:
gimp -i -b "(begin (border-fuzz \"foo.png\" '(0 0 0) 50 0 16 FALSE 1
FALSE) (gimp-quit RUN-NONINTERACTIVE))"
Hope this is of use.
Regards,
Niels Giesen.


|