Re: [Gimp-user] Unable to use 'system' command for script-fu -- Almost done

2007-03-12 Thread saulgoode
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

2007-03-12 Thread Bogus
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

2007-03-11 Thread Sven Neumann
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

2007-03-11 Thread John R. Culleton
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

2007-03-11 Thread Joao S. O. Bueno Calligaris
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

2007-03-11 Thread Tony Freeman
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 xtns-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 -- Almost done

2007-03-11 Thread Tony Freeman
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,
Image/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


[Gimp-user] Unable to use 'system' command for script-fu

2007-03-10 Thread Tony Freeman
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
Toolbox/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-IMAGEThe Image0
SF-STRINGFile Nameweb-image.png
 )
[/code]

Any help would be appreciated.

-- 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

2007-03-10 Thread Sven Neumann
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


Re: [Gimp-user] Unable to use 'system' command for script-fu

2007-03-10 Thread saulgoode
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

2007-03-10 Thread Tony Freeman
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

2007-03-10 Thread Tony Freeman
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

2007-03-10 Thread Joao S. O. Bueno Calligaris
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 xtns-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

2007-03-10 Thread David Gowers

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