Re: [Gimp-user] Unable to use 'system' command for script-fu
On 10 Mar 2007, [EMAIL PROTECTED] 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 -- Bogus ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] Unable to use 'system' command for script-fu <-- Almost done
Quoting Tony Freeman: > 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) To the best of my knowledge, it is impossible for a script to close the display unless it was created through PDB calls (i.e., you cannot delete an image created or opened by the user). The PDB function, 'gimp-image-delete', only works with images that have been created through the PDB. Since the call to 'gimp-display-delete' will attempt to delete the image if the display you are deleting is the only one associated with the image, you end up effectively violating the conditions of 'gimp-image-delete'. ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] 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 <[EMAIL PROTECTED]>", "National Weather Service, Louisville", "2007", "/NWS/Send to web...", "RGB*, GRAY*", [ (PF_STRING, "filename", "Filename", "web-image.png"), ], [], python_send_to_web) main() ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] 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 >> > ___ > Gimp-user mailing list > Gimp-user@lists.XCF.Berkeley.EDU > https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user > > > ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] 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 -><- ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] 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. -- John Culleton Able Indexing and Typesetting Precision typesetting (tm) at reasonable cost. Satisfaction guaranteed. http://wexfordpress.com ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] 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 ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] Unable to use 'system' command for script-fu
On 3/11/07, Joao S. O. Bueno Calligaris <[EMAIL PROTECTED]> 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. ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] 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 ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] 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 > > > [EMAIL PROTECTED] wrote: > >> Quoting Tony Freeman <[EMAIL PROTECTED]>: >> >> >> >>> 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. >> >> >> ___ >> Gimp-user mailing list >> Gimp-user@lists.XCF.Berkeley.EDU >> https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user >> >> >> >> > ___ > Gimp-user mailing list > Gimp-user@lists.XCF.Berkeley.EDU > https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user > > > ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] 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 [EMAIL PROTECTED] wrote: > Quoting Tony Freeman <[EMAIL PROTECTED]>: > > >> 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. > > > ___ > Gimp-user mailing list > Gimp-user@lists.XCF.Berkeley.EDU > https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user > > > ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] Unable to use 'system' command for script-fu
Quoting Tony Freeman <[EMAIL PROTECTED]>: > 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. ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] 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 ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user