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

Unable to use 'system' command for script-fu

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.

13 of 13 messages available
Toggle history

Please log in to manage your subscriptions.

Unable to use 'system' command for script-fu Tony Freeman 10 Mar 23:48
  Unable to use 'system' command for script-fu Sven Neumann 10 Mar 23:53
  Unable to use 'system' command for script-fu saulgoode@flashingtwelve.brickfilms.com 11 Mar 03:04
   Unable to use 'system' command for script-fu Tony Freeman 11 Mar 03:25
    Unable to use 'system' command for script-fu Tony Freeman 11 Mar 05:25
     Unable to use 'system' command for script-fu Joao S. O. Bueno Calligaris 11 Mar 07:04
      Unable to use 'system' command for script-fu John R. Culleton 11 Mar 03:30
       Unable to use 'system' command for script-fu Joao S. O. Bueno Calligaris 11 Mar 16:25
      Unable to use 'system' command for script-fu David Gowers 11 Mar 07:50
      Unable to use 'system' command for script-fu Tony Freeman 11 Mar 20:17
       Unable to use 'system' command for script-fu <-- Almost done Tony Freeman 12 Mar 04:39
     Unable to use 'system' command for script-fu Sven Neumann 11 Mar 12:31
Unable to use 'system' command for script-fu Bogus 12 Mar 16:35
Tony Freeman
2007-03-10 23:48:21 UTC (about 17 years ago)

Unable to use 'system' command for script-fu

Hello,

I wonder if someone could help me with this problem I'm having using the 'system' command in a scheme file.

[code] ; launch system call to copy image to our www directory on ldad (set! command (string-append "/usr/bin/scp " SRCFilename " " RemoteImageDir))
(system command)

; Close out the image
(gimp-display-delete Image)
(delete-file SRCFilename)
[/code]

The first system call gives this error:

[error] Error while executing
(script-fu-Send-to-Web 1 "web-image.png") ERROR: unbound variable (errobj system) [/error]

The 'delete-file' call gives this error:

[error] Error while executing
(script-fu-Send-to-Web 1 "web-image.png") ERROR: unbound variable (errobj delete-file) [/error]

Below is the complete bit of code:

[code] (define RemoteImageDir "ls1:/home/tony/testdir/")

(define (script-fu-Send-to-Web Image Filename)
; the directory our file will be saved in (set! SRCFilename (string-append "/tmp/" Filename))
; scale the image to our optimum web size (set! width (car (gimp-image-width Image))) (set! height (car (gimp-image-height Image))) (if (> width 470)
(begin
(set! newHeight (/ (* 470 height) width)) (gimp-image-scale Image 470 newHeight) (gimp-displays-flush)
)
)

; add a drop shadow
(set! drawable (car (gimp-image-get-active-drawable Image))) (script-fu-drop-shadow Image drawable 8.0 8.0 15.0 '(0 0 0) 80.0 TRUE) (gimp-displays-flush)

; save as png file to local drive (gimp-image-merge-visible-layers Image 0) (gimp-displays-flush)
(set! drawable (car (gimp-image-get-active-drawable Image))) (file-png-save2 RUN-NONINTERACTIVE Image drawable SRCFilename Filename 1 9 0 0 0 1 1 0 0)
(gimp-displays-flush)

; launch system call to copy image to our www directory on ldad (set! command (string-append "/usr/bin/scp " SRCFilename " " RemoteImageDir))
(system command)

; Close out the image
(gimp-display-delete Image)
(delete-file SRCFilename)

; Let user know it's online
(gimp-message "Cool! Your picture is online. You may now include it in a 'Top News of the Day' article.") )

; Register the function with the GIMP: (script-fu-register
"script-fu-Send-to-Web"
"/NWS/Send To Web"
"Scales the image to 500px width and saves it to www images rsync directory on LDAD."
"Tony Freeman"
"2007, National Weather Service" "March 06, 2007"
"RGB* GRAY*"
SF-IMAGE "The Image" 0
SF-STRING "File Name" "web-image.png" )
[/code]

Any help would be appreciated.

-- Tony

Sven Neumann
2007-03-10 23:53:11 UTC (about 17 years ago)

Unable to use 'system' command for script-fu

Hi,

On Sat, 2007-03-10 at 17:48 -0500, Tony Freeman wrote:

I wonder if someone could help me with this problem I'm having using the 'system' command in a scheme file.

I don't think that the SIOD functions 'system' or 'delete-file' are implemented in Script-Fu.

Sven

saulgoode@flashingtwelve.brickfilms.com
2007-03-11 03:04:58 UTC (about 17 years ago)

Unable to use 'system' command for script-fu

Quoting Tony Freeman :

Hello,

I wonder if someone could help me with this problem I'm having using the 'system' command in a scheme file.

Unfortunately, the 'system' command is one of those rare SIOD functions that is not implemented in Script-fu. You may need to write a plug-in or a Python script to execute command line calls.

Tony Freeman
2007-03-11 03:25:53 UTC (about 17 years ago)

Unable to use 'system' command for script-fu

Thanks for all the comments,

I guess I'll investigate python-fu.

I do not see a tutorial on the gimp website for python-fu (http://www.gimp.org/tutorials/#Script) so I'll be doing some googling ... would anyone happen to know of a good basic tutorial I could check out?

Or better yet ... I like GTK/Glib ... maybe there's a tutorial or example you know of?

-- Tony

saulgoode@flashingtwelve.brickfilms.com wrote:

Quoting Tony Freeman :

Hello,

I wonder if someone could help me with this problem I'm having using the 'system' command in a scheme file.

Unfortunately, the 'system' command is one of those rare SIOD functions that is not implemented in Script-fu. You may need to write a plug-in or a Python script to execute command line calls.

John R. Culleton
2007-03-11 03:30:40 UTC (about 17 years ago)

Unable to use 'system' command for script-fu

On Sunday 11 March 2007 01:04, Joao S. O. Bueno Calligaris wrote:

On Sunday 11 March 2007 01:25, Tony Freeman wrote:

OK, I found this site ... I'll be studying this for a while :-)

http://developer.gimp.org/plug-in-template.html

You really be better trying out pythhon scripts first.

However I find that recent versions of Gimp blow up on compile unless one disables Python capability. I use Slackware Linux.

Tony Freeman
2007-03-11 05:25:11 UTC (about 17 years ago)

Unable to use 'system' command for script-fu

OK, I found this site ... I'll be studying this for a while :-)

http://developer.gimp.org/plug-in-template.html

-- Tony

Tony Freeman wrote:

Thanks for all the comments,

I guess I'll investigate python-fu.

I do not see a tutorial on the gimp website for python-fu (http://www.gimp.org/tutorials/#Script) so I'll be doing some googling ... would anyone happen to know of a good basic tutorial I could check out?

Or better yet ... I like GTK/Glib ... maybe there's a tutorial or example you know of?

-- Tony

saulgoode@flashingtwelve.brickfilms.com wrote:

Quoting Tony Freeman :

Hello,

I wonder if someone could help me with this problem I'm having using the 'system' command in a scheme file.

Unfortunately, the 'system' command is one of those rare SIOD functions that is not implemented in Script-fu. You may need to write a plug-in or a Python script to execute command line calls.

Joao S. O. Bueno Calligaris
2007-03-11 07:04:05 UTC (about 17 years ago)

Unable to use 'system' command for script-fu

On Sunday 11 March 2007 01:25, Tony Freeman wrote:

OK, I found this site ... I'll be studying this for a while :-)

http://developer.gimp.org/plug-in-template.html

You really be better trying out pythhon scripts first.

Only if you intend to perform image processing - like performign some algorithm on a pixel by pixel basis you'd have some advantage writting a plug-in in C nowadays.

The URL you did not find is:

http://www.gimp.org/docs/python/index.html Also, take a look at the example plug-instahtcome withthe GIMP, anbd try some python commands at the python console. Onm the python console, btw, start with:

from gimpfu import * img = gimp.list_images()[0]

-- now you have your first image open in the gimp as a python object named "img", and you can do :

dir (img)

(for example: img.scale (img.width * 0.5, img.height * 0.5) )

to see the methods and properties available.

Under the module pdb you have all the procedural database api, which you can browse with ->Procedure Browser,as in:

pdb.gimp_drawable_fill (img.layers[0], FOREGROUND_FILL)

(followed by gimp.displays_flush() to see the effect)
all procedure names use "_" instead of "-", and ignore (do not pass) "interactive/non-interactive" parameters.

. Now if you know that:
1) python blocks like procedure bodys, if blocks, for loop blocks are delimited only by intendation level, and statements that accept blocks end with a collon
2) The python for statement iterates over a list, and if you want numbers, use the "xrange" built-in function like: for i in xrange(1,11):
print i
3) it is easier if you copy the call to the "register" function from an existing script and just update the entries for your case

you are ready for python scripting.

But, if you want to create a custom gtk+ interface instead of the script-fu like automathed dialog, it is also possible - again, check the docs and examples.

js
->

-- Tony

David Gowers
2007-03-11 07:50:28 UTC (about 17 years ago)

Unable to use 'system' command for script-fu

On 3/11/07, Joao S. O. Bueno Calligaris wrote:

On Sunday 11 March 2007 01:25, Tony Freeman wrote:

OK, I found this site ... I'll be studying this for a while :-)

http://developer.gimp.org/plug-in-template.html

You really be better trying out pythhon scripts first.

Only if you intend to perform image processing - like performign some algorithm on a pixel by pixel basis you'd have some advantage writting a plug-in in C nowadays.

The URL you did not find is: Onm the python console, btw, start with:

from gimpfu import *

You don't need to do that, the python console does it when starting up.

img = gimp.list_images()[0]

img = gimp.image_list()[0] is correct.

Sven Neumann
2007-03-11 12:31:51 UTC (about 17 years ago)

Unable to use 'system' command for script-fu

Hi,

On Sat, 2007-03-10 at 23:25 -0500, Tony Freeman wrote:

OK, I found this site ... I'll be studying this for a while :-)

http://developer.gimp.org/plug-in-template.html

The plug-in template is more about packaging and distributing a complex plug-in for GIMP than about writing a simple one. You don't need most of the things covered there. A simple .c file compiled and installed with gimptool should be sufficient.

Sven

Joao S. O. Bueno Calligaris
2007-03-11 16:25:16 UTC (about 17 years ago)

Unable to use 'system' command for script-fu

On Saturday 10 March 2007 23:30, John R. Culleton wrote:

On Sunday 11 March 2007 01:04, Joao S. O. Bueno Calligaris wrote:

On Sunday 11 March 2007 01:25, Tony Freeman wrote:

OK, I found this site ... I'll be studying this for a while :-)

http://developer.gimp.org/plug-in-template.html

You really be better trying out pythhon scripts first.

However I find that recent versions of Gimp blow up on compile unless one disables Python capability. I use Slackware Linux.

Please, take a look at the fix available here: http://bugzilla.gnome.org/show_bug.cgi?id=381389

Newer versions of pygtk, as they come out, will have this fix implemented.,

Forgot 2 other things:

4) you get the "system" as in:

import os os.system ("your command here")

although, if you take a look at the api docs in www.python.org, you soon will find yourself needing 'system' very little

5) Although I said that if you need to iterate over every pixel , you'd be better using a C plug-in, you _can_ do it in python (which does not happen with script-fu) - the only issue is that it is painfully slow to do so - but it can work as a prototype for aC plug-in.

js
->

Tony Freeman
2007-03-11 20:17:41 UTC (about 17 years ago)

Unable to use 'system' command for script-fu

Thanks Joao,

I see what you mean about C. I just tried to do a drop shadow in C and could not find any examples.

I'm reading the python-fu stuff now :-)

-- Tony

Joao S. O. Bueno Calligaris wrote:

On Sunday 11 March 2007 01:25, Tony Freeman wrote:

OK, I found this site ... I'll be studying this for a while :-)

http://developer.gimp.org/plug-in-template.html

You really be better trying out pythhon scripts first.

Only if you intend to perform image processing - like performign some algorithm on a pixel by pixel basis you'd have some advantage writting a plug-in in C nowadays.

The URL you did not find is:

http://www.gimp.org/docs/python/index.html Also, take a look at the example plug-instahtcome withthe GIMP, anbd try some python commands at the python console. Onm the python console, btw, start with:

from gimpfu import * img = gimp.list_images()[0]

-- now you have your first image open in the gimp as a python object named "img", and you can do :

dir (img)

(for example: img.scale (img.width * 0.5, img.height * 0.5) )

to see the methods and properties available.

Under the module pdb you have all the procedural database api, which you can browse with ->Procedure Browser,as in:

pdb.gimp_drawable_fill (img.layers[0], FOREGROUND_FILL)

(followed by gimp.displays_flush() to see the effect)
all procedure names use "_" instead of "-", and ignore (do not pass) "interactive/non-interactive" parameters.

. Now if you know that:
1) python blocks like procedure bodys, if blocks, for loop blocks are delimited only by intendation level, and statements that accept blocks end with a collon
2) The python for statement iterates over a list, and if you want numbers, use the "xrange" built-in function like: for i in xrange(1,11):
print i
3) it is easier if you copy the call to the "register" function from an existing script and just update the entries for your case

you are ready for python scripting.

But, if you want to create a custom gtk+ interface instead of the script-fu like automathed dialog, it is also possible - again, check the docs and examples.

js
->

-- Tony

Tony Freeman
2007-03-12 04:39:57 UTC (about 17 years ago)

Unable to use 'system' command for script-fu <-- Almost done

Almost done!

One last thing that I cannot figure out is: how do you close the dialog box that the image is sitting in? In Scheme you do it like so:

(gimp-display-delete Image)

I've tried the following (with variations), but it causes the python-fu to hang:

pdb.gimp_display_delete(img)

Anyway ... here's the code so far:

#!/usr/bin/env python

# Send to Web - Re-samples an image, adds drop shadow, and saves it # to ls1 www images directory so that it can be used # in a 'Top News of the Day' article.

import os from gimpfu import *

def python_send_to_web(img, drawable, filename): img.disable_undo()

# local variables:
SRCFilename = "/tmp/" + filename RemoteDirectory = "ls1:/home/tony/" SCPProgram = "/usr/bin/scp"

width = img.width
height = img.height

# hack to make the next section work: blank_layer = gimp.Layer(img, "blank", width, height, RGB_IMAGE, 0, NORMAL_MODE)
img.add_layer(blank_layer, 0)
gimp.displays_flush()

# merge all the layers for just in case the user has done some editing: pdb.gimp_image_merge_visible_layers(img, 0) # screwed up the drawable when I merged the layers: drawable = pdb.gimp_image_get_active_drawable(img)
# scale the image if it's too big: if (width > 470):
newheight = ((height * 470) / width) pdb.gimp_image_scale(img, 470, newheight) gimp.displays_flush()

# add a drop shadow:
pdb.script_fu_drop_shadow(img, drawable, 8.0, 8.0, 15.0, [0,0,0], 80.0, TRUE)
gimp.displays_flush()

# final layer merge:
pdb.gimp_image_merge_visible_layers(img, 0) drawable = pdb.gimp_image_get_active_drawable(img)
# save the image in png format to disk: pdb.file_png_save2(img, drawable, SRCFilename, filename, FALSE, 6, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE) gimp.displays_flush()

# close the python-fu dialog box: gimp.delete(img)

# send the image to our ls1 directory: command = SCPProgram + " " + SRCFilename + " " + RemoteDirectory os.popen(command)

# user needs some feedback:
pdb.gimp_message("Cool! Your picture is online. You may now include it in a 'Top News of the Day' article.")
# I'd like to be able to close the dialog that the image is sitting in ...
# but I cannot figure out how to do this. I'll leave it open. Hopefully the
# user will not be too confused by this. #pdb.gimp_display_delete(img)

register( "python_fu_send_to_web",
"Send an image to ls1 rsync directory", "Send image to ls1 for rsync to web farm after resampling it to proper size and adding drop shadow.", "Tony Freeman ",
"National Weather Service, Louisville", "2007",
"/NWS/Send to web...",
"RGB*, GRAY*",
[
(PF_STRING, "filename", "Filename", "web-image.png"), ],
[],
python_send_to_web)

main()

Bogus
2007-03-12 16:35:51 UTC (about 17 years ago)

Unable to use 'system' command for script-fu

On 10 Mar 2007, sven@gimp.org wrote:

Hi,

On Sat, 2007-03-10 at 17:48 -0500, Tony Freeman wrote:

I wonder if someone could help me with this problem I'm having using the 'system' command in a scheme file.

I don't think that the SIOD functions 'system' or 'delete-file' are implemented in Script-Fu.

Sven

Any chance to have "(system ...)" implemented in 2.4 ???

Many of us would like to call external program (such as "wine neatimage...") from scriptfus when do photo touch-up.

Thanx