Re: [Gimp-developer] script-fu problem in 2.6

2008-12-16 Thread saulgoode
Quoting Sven Neumann :

> Perhaps we need to add gimp-layear-has-mask then. Until then you could
> use gimp-plugin-set-pdb-error-handler to take over the error handling in
> order to suppress the warning.

I haven't been following this discussion that closely; however, I  
would point out that the PDB function 'gimp-layer-get-mask' will  
return "-1" if the layer does not have a mask.

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


Re: [Gimp-developer] script-fu problem in 2.6

2008-12-16 Thread Luis A. Florit
* El 17/12/08 a las  0:08, Sven Neumann chamullaba:

> Hi,
>
> On Tue, 2008-12-16 at 16:21 -0200, Luis A. Florit wrote:
>
> > I have a script-fu that worked fine in 2.4 and it's broken in 2.6.
> > It had a conditional to apply the layer's mask if it exists. This is
> > what it read:
> >
> >   (cond
> >   ((gimp-layer-get-mask SharpenLayer)(gimp-layer-remove-mask 
> > SharpenLayer 0))
> >   )
> >
> > Now it is broken.
>
> How exactly is it broken? It really doesn't help to say that
> something is broken if you don't explain in more detail what happens
> and what you expect to happen. This might be a bug that can be fixed
> easily, but we need a useful error description and perhaps a simple
> test script in order to find out.

Sorry, you're right (although I was as clear as script-fu itself...)
GIMP just opens the typical pop-up window saying that there was an
error in the procedure, without saying which kind error was it).
I don't have 2.6 installed here, sorry for not being more precise.
I expect no error, of course.

> Perhaps we need to add gimp-layear-has-mask then.

Or at least gimp-layer-remove-mask to do nothing if no mask exists.
Strange that the script-fu routine worked in 2.4: the routine
gimp-layer-get-mask returns the mask, it is not boolean, so it
shouldn't really work as a conditional...

> Until then you could use gimp-plugin-set-pdb-error-handler to take
> over the error handling in order to suppress the warning.

But then the script will not work in 2.4 (could not find that
procedure in 2.4).

Thanks,

L.

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


Re: [Gimp-developer] script-fu problem in 2.6

2008-12-16 Thread Sven Neumann
Hi,

On Tue, 2008-12-16 at 16:21 -0200, Luis A. Florit wrote:

> I have a script-fu that worked fine in 2.4 and it's broken in 2.6.
> It had a conditional to apply the layer's mask if it exists. This is
> what it read:
> 
>   (cond
>   ((gimp-layer-get-mask SharpenLayer)(gimp-layer-remove-mask SharpenLayer 
> 0))
>   )
> 
> Now it is broken.

How exactly is it broken? It really doesn't help to say that something
is broken if you don't explain in more detail what happens and what you
expect to happen. This might be a bug that can be fixed easily, but we
need a useful error description and perhaps a simple test script in
order to find out.


Sven


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


Re: [Gimp-developer] script-fu problem in 2.6

2008-12-16 Thread Sven Neumann
Hi,

On Tue, 2008-12-16 at 16:21 -0200, Luis A. Florit wrote:

> How do I tell script-fu 2.6 to apply a layer mask (if it exists)?
> I was unable to find something like a boolean gimp-layear-has-mask,
> and gimp-layer-remove-mask returns an error if the mask does not exist.

Perhaps we need to add gimp-layear-has-mask then. Until then you could
use gimp-plugin-set-pdb-error-handler to take over the error handling in
order to suppress the warning.


Sven


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


[Gimp-developer] script-fu problem in 2.6

2008-12-16 Thread Luis A. Florit
Hi,

I have a script-fu that worked fine in 2.4 and it's broken in 2.6.
It had a conditional to apply the layer's mask if it exists. This is
what it read:

  (cond
  ((gimp-layer-get-mask SharpenLayer)(gimp-layer-remove-mask SharpenLayer 
0))
  )

Now it is broken.

How do I tell script-fu 2.6 to apply a layer mask (if it exists)?
I was unable to find something like a boolean gimp-layear-has-mask,
and gimp-layer-remove-mask returns an error if the mask does not exist.

Thanks!!

L.

___
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 saulgoode
Quoting 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 ?

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

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