Re: [Gimp-developer] Using GIMP from my own program

2008-12-16 Thread Pablo Yaggi
Ok, I made it work, I just replaced newlayer for newimage in the
gimp-edit-paste call and it worked.
But pasting into the image should work, shouldn't ?, do I have
to set up a current layer or something ?
bests,
Pablo


On Tuesday 16 December 2008 12:52:49 Pablo Yaggi wrote:
 Well, following all advices I decide to make the plugins I need for gimp,
 and use it in batch mode, this way plugins will be available for everybody.
 But my first attempt is not working fine, I'm coping/pasting the following
 code into the script-fu console, and I get a black image as glam-out.jpg
 with correct size, could you tell me why ?,
 (this is a test that should make an image which is double in height than
 input, and the upper half size has the input copied as is and the lower
 half size has the input copied rotated 180)

 (let* (
   (image (car(gimp-file-load 1 /home/pablo/glam.jpg
 /home/pablo/glam.jpg)))
   (width (car (gimp-image-width image)))
   (height (car (gimp-image-height image)))
   (newheight (* height 2))
   (newimage (car(gimp-image-new width newheight RGB)))
   (newlayer (car (gimp-layer-new newimage width newheight RGBA-IMAGE
 Copy 100 NORMAL-MODE)))
   )
   (gimp-context-push)

   (gimp-image-add-layer newimage newlayer -1)
   (gimp-drawable-set-visible newlayer TRUE)
   (gimp-selection-all image)
   (gimp-edit-copy-visible image)
   (gimp-rect-select newimage 0 0 width height CHANNEL-OP-ADD FALSE 0)
   (let  ((floating-sel (car (gimp-edit-paste newimage FALSE
   (gimp-floating-sel-anchor floating-sel)
   )
   (gimp-selection-none newimage)
   (gimp-rect-select newimage 0 height width height CHANNEL-OP-ADD FALSE 0)
   (let  ((floating-sel (car (gimp-edit-paste newimage FALSE
   (gimp-rotate floating-sel FALSE 180)
   (gimp-floating-sel-anchor floating-sel)
   )
   (gimp-file-save 1 newimage newlayer /home/pablo/glam-out.jpg
 /home/pablo/glam-out.jpg)

   (gimp-context-pop)
 )











 Best Regards,
 Pablo




 On Sunday 14 December 2008 16:36:10 saulgo...@flashingtwelve.brickfilms.com

 wrote:
  Quoting Pablo Yaggi pya...@alsurdelsur.com:
   So ..., I think a couple of things are not clear to me about gimp,
   if plugins communicate with the core of gimp thought a pipe, I
   should be able to create a plugin to do what i want, even
   call other plugins, but could that plugin be executed from outside
   the core ?, ...
 
  Yes.
 
   even so it is necesary that gimp is running before
   doing it ?
 
  Yes, if you want to use plug-ins or scripts then you will want GIMP to
  be running (unless you want to reimplement all of the functionality of
  handling those plug-ins using libgimp).
 
   are the core and gui strict releated, i mean are the same
   thing? can the gui be down, and the core working ?
 
  Yes, you can execute GIMP without the GUI by passing the
  '--no-interface' ('-i') option on the command line. Script-fu code can
  be passed to GIMP on the command line as well, if you know what that
  code is in advance. If you need a more interactive approach, you could
  also have GIMP running in a server mode where Script-fu commands are
  passed over TCP.
 
   In other words, is it possible in any way to use gimp for
   automatic image processing/generating, because GEGL its very
   promissing but gimp is fully charged with plugins and tools,
   and It sould be very nice to use all that power for automatic
   process.
 
  First, I would propose that you investigate Imagemagick command line
  tools ( http://www.imagemagick.org/ ) and see if they present a better
  solution.
 
  Second, you should investigate using GEGL. It is particularly targeted
  for the type of activity you are pursuing and your participation could
  help advance its progress.
 
  If neither of those two options seem desirable then I would present
  the following GIMP-based options:
 
  1) Invoke GIMP from your C program, passing the commands you wish
  executed as Script-fu in batch mode ('-b').
 
  2) If you need lower level processing than provided by Script-fu,
  write your code as a GIMP plug-in and invoke your plug-in from a batch
  Script-fu command. Example:
 gimp -i -b '(plug-in-pablos-function RUN-NONINTERACTIVE parameter1
  parameter2)' -b '(quit 0)'
 
  3) Run an interactive server, as briefly described in this ML posting:
  (
  http://flashingtwelve.brickfilms.com:2095/horde/imp/message.php?index=113
 69 )
 
  4) Write your code as a GIMP plug-in per the tutorial described here:
  ( http://gimp.org/docs/plug-in/sect-essentials.html )
 
  however, you should register an 'init' procedure which invokes your
  plug-in (perhaps passing it command line parameters).
 
  This will have the effect of your plug-in automatically being executed
  when GIMP is run; therefore do NOT put your autoexecuted plug-in into
  the standard GIMP plug-in folders (or you will break normal usage of
  GIMP). Instead, create a custom gimprc file (e.g.,
  $HOME/gimprc.pablo) which adds 

Re: [Gimp-developer] Using GIMP from my own program

2008-12-16 Thread saulgoode
Quoting Pablo Yaggi pya...@alsurdelsur.com:

 Ok, I made it work, I just replaced newlayer for newimage in the
 gimp-edit-paste call and it worked.
 But pasting into the image should work, shouldn't ?, do I have
 to set up a current layer or something ?

There is no paste-as-new-layer function provided as such by the PDB  
interface (though there is a menu command for that) and so you must  
perform a couple of separate functions to achieve the same result.

You do not need to set up a current layer, but you need to perform a  
'gimp-floating-sel-to-layer' after your 'gimp-edit-paste'. This will  
result in a new layer at the top of the layerstack -- unlike the menu  
command, which places the new layer above the active layer -- and  
therefore it does not matter which layer (or drawable) is active at  
the time the paste is performed.

If you instead wish the resulting new layer to appear just above the  
current layer then you will need to make note of the current layer's  
position (using 'gimp-image-get-layer-position') and lower the pasted  
layer accordingly (using 'gimp-image-lower-layer' the appropriate  
number of times).



___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Using GIMP from my own program

2008-12-16 Thread Pablo Yaggi
Well, following all advices I decide to make the plugins I need for gimp,
and use it in batch mode, this way plugins will be available for everybody.
But my first attempt is not working fine, I'm coping/pasting the following
code into the script-fu console, and I get a black image as glam-out.jpg
with correct size, could you tell me why ?, 
(this is a test that should make an image which is double in height than
input, and the upper half size has the input copied as is and the lower
half size has the input copied rotated 180)

(let* (
  (image (car(gimp-file-load 1 /home/pablo/glam.jpg 
/home/pablo/glam.jpg)))
  (width (car (gimp-image-width image)))
  (height (car (gimp-image-height image)))
  (newheight (* height 2))
  (newimage (car(gimp-image-new width newheight RGB)))
  (newlayer (car (gimp-layer-new newimage width newheight RGBA-IMAGE 
Copy 100 NORMAL-MODE)))
  )
  (gimp-context-push)

  (gimp-image-add-layer newimage newlayer -1)
  (gimp-drawable-set-visible newlayer TRUE)
  (gimp-selection-all image)
  (gimp-edit-copy-visible image)
  (gimp-rect-select newimage 0 0 width height CHANNEL-OP-ADD FALSE 0)
  (let  ((floating-sel (car (gimp-edit-paste newimage FALSE
(gimp-floating-sel-anchor floating-sel)
  )
  (gimp-selection-none newimage)
  (gimp-rect-select newimage 0 height width height CHANNEL-OP-ADD FALSE 0)
  (let  ((floating-sel (car (gimp-edit-paste newimage FALSE
(gimp-rotate floating-sel FALSE 180)
(gimp-floating-sel-anchor floating-sel)
  )
  (gimp-file-save 1 newimage newlayer /home/pablo/glam-out.jpg 
/home/pablo/glam-out.jpg)

  (gimp-context-pop)
)











Best Regards,
Pablo




On Sunday 14 December 2008 16:36:10 saulgo...@flashingtwelve.brickfilms.com 
wrote:
 Quoting Pablo Yaggi pya...@alsurdelsur.com:
  So ..., I think a couple of things are not clear to me about gimp,
  if plugins communicate with the core of gimp thought a pipe, I
  should be able to create a plugin to do what i want, even
  call other plugins, but could that plugin be executed from outside
  the core ?, ...

 Yes.

  even so it is necesary that gimp is running before
  doing it ?

 Yes, if you want to use plug-ins or scripts then you will want GIMP to
 be running (unless you want to reimplement all of the functionality of
 handling those plug-ins using libgimp).

  are the core and gui strict releated, i mean are the same
  thing? can the gui be down, and the core working ?

 Yes, you can execute GIMP without the GUI by passing the
 '--no-interface' ('-i') option on the command line. Script-fu code can
 be passed to GIMP on the command line as well, if you know what that
 code is in advance. If you need a more interactive approach, you could
 also have GIMP running in a server mode where Script-fu commands are
 passed over TCP.

  In other words, is it possible in any way to use gimp for
  automatic image processing/generating, because GEGL its very
  promissing but gimp is fully charged with plugins and tools,
  and It sould be very nice to use all that power for automatic
  process.

 First, I would propose that you investigate Imagemagick command line
 tools ( http://www.imagemagick.org/ ) and see if they present a better
 solution.

 Second, you should investigate using GEGL. It is particularly targeted
 for the type of activity you are pursuing and your participation could
 help advance its progress.

 If neither of those two options seem desirable then I would present
 the following GIMP-based options:

 1) Invoke GIMP from your C program, passing the commands you wish
 executed as Script-fu in batch mode ('-b').

 2) If you need lower level processing than provided by Script-fu,
 write your code as a GIMP plug-in and invoke your plug-in from a batch
 Script-fu command. Example:
gimp -i -b '(plug-in-pablos-function RUN-NONINTERACTIVE parameter1
 parameter2)' -b '(quit 0)'

 3) Run an interactive server, as briefly described in this ML posting:
 (
 http://flashingtwelve.brickfilms.com:2095/horde/imp/message.php?index=11369
 )

 4) Write your code as a GIMP plug-in per the tutorial described here:
 ( http://gimp.org/docs/plug-in/sect-essentials.html )

 however, you should register an 'init' procedure which invokes your
 plug-in (perhaps passing it command line parameters).

 This will have the effect of your plug-in automatically being executed
 when GIMP is run; therefore do NOT put your autoexecuted plug-in into
 the standard GIMP plug-in folders (or you will break normal usage of
 GIMP). Instead, create a custom gimprc file (e.g.,
 $HOME/gimprc.pablo) which adds the path of your autoexecuted plug-in
 to the plug-in search path:
(plug-in-path
 ${gimp_dir}/plug-ins:$HOME/.gimp-2.6/plug-ins:$HOME/autoexec/plug-ins)

 You then can invoke GIMP, specifying the alternate gimprc:
gimp -i -g $HOME/gimprc.pablo

 ===

 There is little difference between 2) and 4) in net effect, but I
 thought I would try to 

Re: [Gimp-developer] Using GIMP from my own program

2008-12-16 Thread Pablo Yaggi
Now I have my script running, It's a simple script that produces the
table-mirror effect apple does, but is it possible to check whether 
the interface is available or not, I mean if gimp is running with -i mode
(no interface).
Also, the script resizes the original image, is it possible to change the
actual zoom from inside the script? how ?
Bests,
Pablo

On Tuesday 16 December 2008 15:45:15 saulgo...@flashingtwelve.brickfilms.com 
wrote:
 Quoting Pablo Yaggi pya...@alsurdelsur.com:
  Ok, I made it work, I just replaced newlayer for newimage in the
  gimp-edit-paste call and it worked.
  But pasting into the image should work, shouldn't ?, do I have
  to set up a current layer or something ?

 There is no paste-as-new-layer function provided as such by the PDB
 interface (though there is a menu command for that) and so you must
 perform a couple of separate functions to achieve the same result.

 You do not need to set up a current layer, but you need to perform a
 'gimp-floating-sel-to-layer' after your 'gimp-edit-paste'. This will
 result in a new layer at the top of the layerstack -- unlike the menu
 command, which places the new layer above the active layer -- and
 therefore it does not matter which layer (or drawable) is active at
 the time the paste is performed.

 If you instead wish the resulting new layer to appear just above the
 current layer then you will need to make note of the current layer's
 position (using 'gimp-image-get-layer-position') and lower the pasted
 layer accordingly (using 'gimp-image-lower-layer' the appropriate
 number of times).



 ___
 Gimp-developer mailing list
 Gimp-developer@lists.XCF.Berkeley.EDU
 https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Using GIMP from my own program

2008-12-16 Thread David Gowers
Hi,

On Wed, Dec 17, 2008 at 6:15 AM, Pablo Yaggi pya...@alsurdelsur.com wrote:
 Now I have my script running, It's a simple script that produces the

 table-mirror effect apple does, but is it possible to check whether

 the interface is available or not, I mean if gimp is running with -i mode

 (no interface).

No, there is no reliable way to do that AFAIK.


 Also, the script resizes the original image, is it possible to change the

 actual zoom from inside the script? how ?
No. In python scripting this is possible using software like
'xdotool', but not in script-fu (because there is no command to shell
out and run another command).

After looking at your script, I suggest you also use '--no-data'
commandline parameter to GIMP to cut down on memory usage and startup
time, since you don't appear to use any brushes/gradients etc in your
script.

David
-- 
I must create a system or be enslaved by another man's; I will not
reason and compare: my business is to create
-- William Blake
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Using GIMP from my own program

2008-12-14 Thread Martin Nordholts
Pablo Yaggi wrote:

 Hi, is it possible to use gimp from a C program ?

 I want to open an image use some plugin on it and

 save it. I know perl does something like that, but

 I couldn't find info about that, could somebody

 point me in a good direction ?

 Bests,

 Pablo


Hi!

The different language wrappers for GIMP such as Perl, Python or Scheme
are themselves basically just wrappers for the PDB, Procedural DataBase.
If you want to call a PDB procedure from GIMP plug-in written in C you
would use gimp_run_procedure() [1] or gimp_run_procedure2(). (These are
the functions the language wrappers themselves use (the language
wrappers are themselves plug-ins)).

BR,
Martin

[1]
http://developer.gimp.org/api/2.0/libgimp/libgimp-gimp.html#gimp-run-procedure
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Using GIMP from my own program

2008-12-14 Thread Pablo Yaggi
But I don't want to call it from a gimp plugin, I want to call it from 
inside a simple c program, is it possible ?
I mean using libgimp outside Gimp, just linking to it, if it so
I suppose I need to make some initialization and I should
need to create some type of data object and so, any example ?
Best Regards
Pablo



On Sunday 14 December 2008 13:50:25 Martin Nordholts wrote:
 Pablo Yaggi wrote:
  Hi, is it possible to use gimp from a C program ?
 
  I want to open an image use some plugin on it and
 
  save it. I know perl does something like that, but
 
  I couldn't find info about that, could somebody
 
  point me in a good direction ?
 
  Bests,
 
  Pablo

 Hi!

 The different language wrappers for GIMP such as Perl, Python or Scheme
 are themselves basically just wrappers for the PDB, Procedural DataBase.
 If you want to call a PDB procedure from GIMP plug-in written in C you
 would use gimp_run_procedure() [1] or gimp_run_procedure2(). (These are
 the functions the language wrappers themselves use (the language
 wrappers are themselves plug-ins)).

 BR,
 Martin

 [1]
 http://developer.gimp.org/api/2.0/libgimp/libgimp-gimp.html#gimp-run-proced
ure

___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Using GIMP from my own program

2008-12-14 Thread Martin Nordholts
Pablo Yaggi wrote:

 So ..., I think a couple of things are not clear to me about gimp,

 if plugins communicate with the core of gimp thought a pipe, I

 should be able to create a plugin to do what i want, even

 call other plugins, but could that plugin be executed from outside

 the core ?


All plug-ins are executed outside the core as a separate process.
Plug-ins registers procedures that other plug-ins, typically language
wrappers, can call. GIMP takes care of inter-process communication.


 , even so it is necesary that gimp is running before

 doing it ? are the core and gui strict releated, i mean are the same

 thing? can the gui be down, and the core working ?

 In other words, is it possible in any way to use gimp for

 automatic image processing/generating, because GEGL its very

 promissing but gimp is fully charged with plugins and tools,

 and It sould be very nice to use all that power for automatic

 process.

 Pablo


GIMP has non-interactive and batch processing modes but I do not use
these very often so I don't have any further details to give than to
refer to Google and the GIMP source code.

- Martin
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Using GIMP from my own program

2008-12-14 Thread Pablo Yaggi
Ok, then I keep googling and I'll check gegl a little deep,
thank's Martin,
BR,
Pablo

On Sunday 14 December 2008 15:59:59 Martin Nordholts wrote:
 Pablo Yaggi wrote:
  So ..., I think a couple of things are not clear to me about gimp,
 
  if plugins communicate with the core of gimp thought a pipe, I
 
  should be able to create a plugin to do what i want, even
 
  call other plugins, but could that plugin be executed from outside
 
  the core ?

 All plug-ins are executed outside the core as a separate process.
 Plug-ins registers procedures that other plug-ins, typically language
 wrappers, can call. GIMP takes care of inter-process communication.

  , even so it is necesary that gimp is running before
 
  doing it ? are the core and gui strict releated, i mean are the same
 
  thing? can the gui be down, and the core working ?
 
  In other words, is it possible in any way to use gimp for
 
  automatic image processing/generating, because GEGL its very
 
  promissing but gimp is fully charged with plugins and tools,
 
  and It sould be very nice to use all that power for automatic
 
  process.
 
  Pablo

 GIMP has non-interactive and batch processing modes but I do not use
 these very often so I don't have any further details to give than to
 refer to Google and the GIMP source code.

 - Martin

___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Using GIMP from my own program

2008-12-14 Thread saulgoode
Quoting Pablo Yaggi pya...@alsurdelsur.com:

 So ..., I think a couple of things are not clear to me about gimp,
 if plugins communicate with the core of gimp thought a pipe, I
 should be able to create a plugin to do what i want, even
 call other plugins, but could that plugin be executed from outside
 the core ?, ...

Yes.

 even so it is necesary that gimp is running before
 doing it ?

Yes, if you want to use plug-ins or scripts then you will want GIMP to  
be running (unless you want to reimplement all of the functionality of  
handling those plug-ins using libgimp).

 are the core and gui strict releated, i mean are the same
 thing? can the gui be down, and the core working ?

Yes, you can execute GIMP without the GUI by passing the  
'--no-interface' ('-i') option on the command line. Script-fu code can  
be passed to GIMP on the command line as well, if you know what that  
code is in advance. If you need a more interactive approach, you could  
also have GIMP running in a server mode where Script-fu commands are  
passed over TCP.

 In other words, is it possible in any way to use gimp for
 automatic image processing/generating, because GEGL its very
 promissing but gimp is fully charged with plugins and tools,
 and It sould be very nice to use all that power for automatic
 process.

First, I would propose that you investigate Imagemagick command line  
tools ( http://www.imagemagick.org/ ) and see if they present a better  
solution.

Second, you should investigate using GEGL. It is particularly targeted  
for the type of activity you are pursuing and your participation could  
help advance its progress.

If neither of those two options seem desirable then I would present  
the following GIMP-based options:

1) Invoke GIMP from your C program, passing the commands you wish  
executed as Script-fu in batch mode ('-b').

2) If you need lower level processing than provided by Script-fu,  
write your code as a GIMP plug-in and invoke your plug-in from a batch  
Script-fu command. Example:
   gimp -i -b '(plug-in-pablos-function RUN-NONINTERACTIVE parameter1  
parameter2)' -b '(quit 0)'

3) Run an interactive server, as briefly described in this ML posting:
(  
http://flashingtwelve.brickfilms.com:2095/horde/imp/message.php?index=11369  
)

4) Write your code as a GIMP plug-in per the tutorial described here:
( http://gimp.org/docs/plug-in/sect-essentials.html )

however, you should register an 'init' procedure which invokes your  
plug-in (perhaps passing it command line parameters).

This will have the effect of your plug-in automatically being executed  
when GIMP is run; therefore do NOT put your autoexecuted plug-in into  
the standard GIMP plug-in folders (or you will break normal usage of  
GIMP). Instead, create a custom gimprc file (e.g.,  
$HOME/gimprc.pablo) which adds the path of your autoexecuted plug-in  
to the plug-in search path:
   (plug-in-path  
${gimp_dir}/plug-ins:$HOME/.gimp-2.6/plug-ins:$HOME/autoexec/plug-ins)

You then can invoke GIMP, specifying the alternate gimprc:
   gimp -i -g $HOME/gimprc.pablo

===

There is little difference between 2) and 4) in net effect, but I  
thought I would try to explain it anyway (I have never tried the  
fourth method). Usually the 'init' procedure is not used for  
individual plug-ins -- it is used to configure things for entire  
packages of multiple plug-ins (such as Python-fu or the GIMP Animation  
Package).



___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer