[Gimp-user] Copy text layers as text or python script to mass generate text layers

2017-09-26 Thread programmer_ceds
>I found the docs for gimp python; now:
>
>1) How to get "print" statments? I started filters->python fu->console
>but apparently a "print" does not write to the console?
>
>2) How can I refresh the script? So far I restart gimp but that is 
>getting tedious.
>
>3) Is there an online site with hints on how to debug a gimp python
>script?
>
>For reference, here is the script. It apparently runs but I get no new
>layer and no progress/console output. I did not expect it to work
>first
>time so now I'd like some pointers on how to debug it.
>
>
>from gimpfu import *
>
>def mass_text(img) :
> print "Does this go to console?"
>
> pdb.gimp.progress_init("Mass text insert ...")
>
> font = 'Arial Bold'
>
> pdb.gimp.set_foreground( 1.0, 0.0, 0.0 )
>
># Create a new text layer (-1 for the layer means create a new
>layer)
>layer = pdb.gimp_text_fontname(img, None, 0, 0, "This is my
>text", 10,
>True, 24, PIXELS, font)
> img.add_layer(layer, 0)
>
>
>register(
> "python_fu_mass_text",
> "Mass Text",
> "Mass create text layers",
> "",
> "",
> "",
> "Mass Text Layer insert...",
> "*",
> [
> ],
> [],
> mass_text, menu="/Tools/MassText")
>
>main()
1. To display information in a Python script you can use something like the
following example:

pdb.gimp_message('The times are ' + str(sixteenth_time) + " " +
str(eighth_time) + " " + str(quarter_time)+ " " + str(half_time))

("\n" will give you a newline(note the double quotes in this case))

2. If I remember correctly (its a while since I debugged a Python script) you
just edit and save the script using a text editor and GIMP will then use the
updated version when you next run the script (might be best not to save the
script whilst part way through actually running the script). (For Script-Fu you
also don't need to restart GIMP just use "Filters/Script-Fu/Refresh Scripts"
then wait for a few seconds until the refresh is complete)

-- 
programmer_ceds (via www.gimpusers.com/forums)
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list


Re: [Gimp-user] Copy text layers as text or python script to mass generate text layers

2017-09-26 Thread Ofnuts

On 09/26/17 03:58, The Tick wrote:

On 9/25/2017 8:36 PM, Scott Jacobs via gimp-user-list wrote:
Maybe I am missing something, but why do you not just drag-n-drop the 
desired layer to the new image?
I just File->New 'd two images, created a text layer in one, and 
drag-n-drop 'd it into the other.
The first image's layer was intact, and the second image now had a 
new layer that was a duplicate of


the first image's layer - was definitely a text layer, as I was able 
to then text-edit it.


That never occurred to me -- I'll try it asap. 



Yes, you can drag/drop layers across images. You can also make an image 
with only the required layers, save to xCF, and loading it using 
"File>Open as layers" in the target image.

___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list


Re: [Gimp-user] Copy text layers as text or python script to mass generate text layers

2017-09-26 Thread Ofnuts

On 09/25/17 18:37, The Tick wrote:


I found the docs for gimp python; now:

1) How to get "print" statments? I started filters->python fu->console 
but apparently a "print" does not write to the console?
It does for me... if you enter the "print" on the console. "Print" from 
a script started form a menu goes to the standard output, whicn on Linux 
and OSX, is the terminal from which your invoked Gimp. For Windows, 
things are a bit more complicated, see here: 
https://www.gimp-forum.net/Thread-Debugging-python-fu-scripts-in-Windows


2) How can I refresh the script? So far I restart gimp but that is 
getting tedious.
You don't need to, as long as you don't change the registration data. 
The code is reloaded from the file on each execution; so your latest chnages

to the code will be taken in account.


3) Is there an online site with hints on how to debug a gimp python 
script?


https://www.gimp-forum.net/Thread-Debugging-python-fu-scripts-in-Windows



For reference, here is the script. It apparently runs but I get no new 
layer and no progress/console output. I did not expect it to work 
first time so now I'd like some pointers on how to debug it.



from gimpfu import *

def mass_text(img) :
    print "Does this go to console?"

    pdb.gimp.progress_init("Mass text insert ...")

    font = 'Arial Bold'

    pdb.gimp.set_foreground( 1.0, 0.0, 0.0 )

    # Create a new text layer (-1 for the layer means create a new layer)
    layer = pdb.gimp_text_fontname(img, None, 0, 0, "This is my text", 
10,

   True, 24, PIXELS, font)
    img.add_layer(layer, 0)


register(
    "python_fu_mass_text",
    "Mass Text",
    "Mass create text layers",
    "",
    "",
    "",
    "Mass Text Layer insert...",
    "*",
    [
    ],
    [],
    mass_text, menu="/Tools/MassText")

main()


Try:
    pdb.gimp_context_set_foreground((1.,0,0,0))

Also, the " img.add_layer(layer, 0)" isn't necessary, the layer created 
in  gimp_text_fontname() is added to the image automatically.

___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list


Re: [Gimp-user] Copy text layers as text or python script to mass generate text layers

2017-09-25 Thread The Tick

On 9/25/2017 8:36 PM, Scott Jacobs via gimp-user-list wrote:

Maybe I am missing something, but why do you not just drag-n-drop the desired 
layer to the new image?
I just File->New 'd two images, created a text layer in one, and drag-n-drop 'd 
it into the other.
The first image's layer was intact, and the second image now had a new layer 
that was a duplicate of

the first image's layer - was definitely a text layer, as I was able to then 
text-edit it.


That never occurred to me -- I'll try it asap.
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list


[Gimp-user] Copy text layers as text or python script to mass generate text layers

2017-09-25 Thread Scott Jacobs via gimp-user-list
>I want to merge two images 
I am first assuming that you wish to create a third image that is the merging 
of the two original images,
NOT that you wish to alter one of the images to add the other image's layers. 
(rather dangerous, in case of
mistakes; with a third image, one still has the original two intact images with 
which to start over).


> I found that an edit->copy does not copy a text layer -- it makes it an image 
> layer.

Maybe I am missing something, but why do you not just drag-n-drop the desired 
layer to the new image?
I just File->New 'd two images, created a text layer in one, and drag-n-drop 'd 
it into the other.
The first image's layer was intact, and the second image now had a new layer 
that was a duplicate of

the first image's layer - was definitely a text layer, as I was able to then 
text-edit it.


Perhaps there are so many layers that you feel you need to have a script to 
automate it.
I have not done scripting in GIMP, but I suppose there is some command to take 
a layer from
one image and copy it to another, which one could then just place in a command 
loop
to iterate over all the text layers...


Others would have to address that point.
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list


Re: [Gimp-user] Copy text layers as text or python script to mass generate text layers

2017-09-25 Thread The Tick

On 9/25/2017 10:20 AM, The Tick wrote:

This is gimp 2.8.22 on windows

I want to merge two images and both have quite a few text layers. I
found that an edit->copy does not copy a text layer -- it makes it an
image layer. I really do now want that since I will definitely have to
modify some of the text in the future as I continue expanding the image.

1) Am I missing something? Is there a way to copy a text layer between
images?
2) If not, perhaps I could write a very simple, one-time script to mass
create the text layers (I'd have to move them to the correct locations
but that is simpler than click-enter text-click and move for each of the
layers.

I found the reference to script-fu but I have never wrapped my head
around scheme/lisp and I don't want to start now. Where are the docs for
the python interface? I am assuming there is some interface to create a
text layer via scripting.


I found the docs for gimp python; now:

1) How to get "print" statments? I started filters->python fu->console 
but apparently a "print" does not write to the console?


2) How can I refresh the script? So far I restart gimp but that is 
getting tedious.


3) Is there an online site with hints on how to debug a gimp python script?

For reference, here is the script. It apparently runs but I get no new 
layer and no progress/console output. I did not expect it to work first 
time so now I'd like some pointers on how to debug it.



from gimpfu import *

def mass_text(img) :
print "Does this go to console?"

pdb.gimp.progress_init("Mass text insert ...")

font = 'Arial Bold'

pdb.gimp.set_foreground( 1.0, 0.0, 0.0 )

# Create a new text layer (-1 for the layer means create a new layer)
layer = pdb.gimp_text_fontname(img, None, 0, 0, "This is my text", 10,
   True, 24, PIXELS, font)
img.add_layer(layer, 0)


register(
"python_fu_mass_text",
"Mass Text",
"Mass create text layers",
"",
"",
"",
"Mass Text Layer insert...",
"*",
[
],
[],
mass_text, menu="/Tools/MassText")

main()





___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list


[Gimp-user] Copy text layers as text or python script to mass generate text layers

2017-09-25 Thread The Tick

This is gimp 2.8.22 on windows

I want to merge two images and both have quite a few text layers. I 
found that an edit->copy does not copy a text layer -- it makes it an 
image layer. I really do now want that since I will definitely have to 
modify some of the text in the future as I continue expanding the image.


1) Am I missing something? Is there a way to copy a text layer between 
images?
2) If not, perhaps I could write a very simple, one-time script to mass 
create the text layers (I'd have to move them to the correct locations 
but that is simpler than click-enter text-click and move for each of the 
layers.


I found the reference to script-fu but I have never wrapped my head 
around scheme/lisp and I don't want to start now. Where are the docs for 
the python interface? I am assuming there is some interface to create a 
text layer via scripting.

___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list