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

reconciling script-fu interactive and batch arguments

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.

2 of 2 messages available
Toggle history

Please log in to manage your subscriptions.

reconciling script-fu interactive and batch arguments Gary Aitken 29 Aug 22:35
  reconciling script-fu interactive and batch arguments Kevin Brubeck Unhammer 30 Aug 12:09
Gary Aitken
2013-08-29 22:35:16 UTC (about 11 years ago)

reconciling script-fu interactive and batch arguments

I have never learned / figured out / been pointed at an example for how to properly write a script which is usable in both interactive and batch modes.

Let's say I have a script-fu add-on:

(define (add-watermark orgImg drw watermarkFileName relHt opacity) ...
)

(script-fu-register
"add-watermark"
"Add Watermark..."
"Adds a scaled, partially transparent image to an image" "Gary Aitken"
"Copyright 2013, Gary Aitken"
"2013-08-28 v 0.1"
""
; SF-MODE "Mode" "RUN-INTERACTIVE" ; First arg is run mode ; SF-STRING "Main image file" "" ; name of main image to modify SF-IMAGE "Image" 0 ; main image to modify SF-DRAWABLE "Drawable" 0 ; unused SF-STRING "Added image file" "myfile.png" SF-VALUE "Relative (percent) height of added image" "5" SF-VALUE "Opacity of added image" "50" )

As written above, with the
SF-MODE "Mode" "RUN-INTERACTIVE" SF-STRING "Main image file" ""
arguments commented out, this script works in interactive mode, operating on the active drawable in the active image; the first two arguments to the function (orgImg and drw) are filled in automagically by the gimp when the script is activated.

The only way I have figured out how to use this from batch mode is to add another script which contains the name of the base file to process:

(define (batch-add-watermark inFileName watermarkFileName outFileName relHt opacity) (let* (
(orgImg (car (gimp-file-load RUN-NONINTERACTIVE inFileName inFileName))) (drw (car (gimp-image-get-active-layer orgImg))) )
(add-watermark orgImg drw watermarkFileName relHt opacity) (gimp-file-save RUN-NONINTERACTIVE orgImg drw outFileName outFileName) (gimp-image-delete orgImg)
)
)

This works, but neither procedure is making any use of what should be the first argument (missing from add-watermark above but present in batch-add-watermark) which is the mode.

My gut says the mode is there to make this all much easier, but I can't figure it out.
Can someone give me a proper explanation of how to do this, or point me at something?

Thanks,

Gary

Kevin Brubeck Unhammer
2013-08-30 12:09:50 UTC (about 11 years ago)

reconciling script-fu interactive and batch arguments

Gary Aitken writes:

I have never learned / figured out / been pointed at an example for how to properly write a script which is usable in both interactive and batch modes.

[...]

This works, but neither procedure is making any use of what should be the first argument (missing from add-watermark above but present in batch-add-watermark) which is the mode.

My gut says the mode is there to make this all much easier, but I can't figure it out.

http://thread.gmane.org/gmane.comp.video.gimp.user/23601 seems like you can't use run-mode from script-fu (though you can from e.g. Python).

Kevin Brubeck Unhammer

GPG: 0x766AC60C