RSS/Atom feed Twitter
Site is read-only, email is disabled

python script for rectangle selection

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

7 of 7 messages available
Toggle history

Please log in to manage your subscriptions.

python script for rectangle selection Fab 02 Jan 18:50
  python script for rectangle selection Norman Silverstone 02 Jan 19:06
  python script for rectangle selection Chris Mohler 02 Jan 20:22
   python script for rectangle selection Fab 02 Jan 20:44
    python script for rectangle selection Chris Mohler 02 Jan 21:59
  python script for rectangle selection David Hodson 03 Jan 05:50
   python script for rectangle selection Fab 04 Jan 10:54
2010-01-02 18:50:51 UTC (about 15 years ago)
postings
3

python script for rectangle selection

Hi,

I am new to gimp's scripting and would like to automate the rectangle selection tool by defining the position and size using a script. Afterwards, I would like to extract the selection, 'paste as new image' and save the image as a png file without compression.

It would be nice, if you can give me some hints, how to achieve this. Maybe, something similar exists already!?

Thanks in advance! Fab

Norman Silverstone
2010-01-02 19:06:59 UTC (about 15 years ago)

python script for rectangle selection

I am new to gimp's scripting and would like to automate the rectangle selection tool by defining the position and size using a script. Afterwards, I would like to extract the selection, 'paste as new image' and save the image as a png file without compression.

It would be nice, if you can give me some hints, how to achieve this. Maybe, something similar exists already!?

I am sorry that I cannot produce a script but why not put the question to http://forum.meetthegimp.org/ there are some very knowledgeable and helpful script writers there.

Norman

Chris Mohler
2010-01-02 20:22:43 UTC (about 15 years ago)

python script for rectangle selection

On Sat, Jan 2, 2010 at 11:50 AM, Fab wrote:

I am new to gimp's scripting and would like to automate the rectangle selection tool by defining the position and size using a script. Afterwards, I would like to extract the selection, 'paste as new image' and save the image as a png file without compression.

It would be nice, if you can give me some hints, how to achieve this. Maybe, something similar exists already!?

Hi,

I've attached some code here - it's from a similar plug-in that I modified to (almost) do what you want. It will need some work for it to be useful, but it should be pretty easy to follow and also modify to suit your needs. I've only given it the barest amount of testing with gimp 2.6.6 on linux, but it should be cross-platform in theory (as long as Python+GIMP is correctly installed).

Note that the gimp.file_png_save() call is most likely using compression - check the procedure browser for the right parameters.

Also, I chose to duplicate/crop/save/destroy rather than select/copy/paste new/save/destroy - I just found that method simpler.

Hope this helps and good luck! Chris

2010-01-02 20:44:50 UTC (about 15 years ago)
postings
3

python script for rectangle selection

Hi to both,

thanks for your help and thanks for the script! I tried the attached python script
by using execfile("script.py") from the python-fu console. Unfortunately gimp (2.6.7 on ubuntu) crashed. Do you have a hint, what I am doing wrong!? Thanks!
Fab

On Sat, Jan 2, 2010 at 11:50 AM, Fab wrote:

I am new to gimp's scripting and would like to automate the rectangle selection tool by defining the position and size using a script. Afterwards, I would like to extract the selection, 'paste as new image'

and

save the image as a png file without compression.

It would be nice, if you can give me some hints, how to achieve this.

Maybe,

something similar exists already!?

Hi,

I've attached some code here - it's from a similar plug-in that I modified to (almost) do what you want. It will need some work for it to be useful, but it should be pretty easy to follow and also modify to suit your needs. I've only given it the barest amount of testing with gimp 2.6.6 on linux, but it should be cross-platform in theory (as long as Python+GIMP is correctly installed).

Note that the gimp.file_png_save() call is most likely using compression - check the procedure browser for the right parameters.

Also, I chose to duplicate/crop/save/destroy rather than select/copy/paste new/save/destroy - I just found that method simpler.

Hope this helps and good luck! Chris

Chris Mohler
2010-01-02 21:59:48 UTC (about 15 years ago)

python script for rectangle selection

On Sat, Jan 2, 2010 at 1:44 PM, Fab wrote:

Hi to both,

thanks for your help and thanks for the script! I tried the attached python script
by using execfile("script.py") from the python-fu console. Unfortunately gimp (2.6.7 on ubuntu) crashed. Do you have a hint, what I am doing wrong!?

Yes - that was originally written as a plug-in (place in ~/.gimp-2.x/plug-ins, chmod +x, it registers as 'File->Export Area').

I think this code should work in the console - either via execfile or typing/pasting it in.

Chris

David Hodson
2010-01-03 05:50:05 UTC (about 15 years ago)

python script for rectangle selection

On Sat, 2010-01-02 at 18:50 +0100, Fab wrote:

Hi,

I am new to gimp's scripting and would like to automate the rectangle selection tool by defining the position and size using a script. Afterwards, I would like to extract the selection, 'paste as new image' and save the image as a png file without compression.

You should be able to do this using David's Batch Processor. It will let you define a fixed region to crop from an image and save as png, then apply that to multiple images. No scripting necessary. Google DBP.

-- David

2010-01-04 10:54:56 UTC (about 15 years ago)
postings
3

python script for rectangle selection

Hi,

it works using the GUI now. I forgot to change the mode to executable. Now, I will try to run it from the console...

Fab

On Sat, 2010-01-02 at 18:50 +0100, Fab wrote:

Hi,

I am new to gimp's scripting and would like to automate the rectangle selection tool by defining the position and size using a script. Afterwards, I would like to extract the selection, 'paste as new image'

and

save the image as a png file without compression.

You should be able to do this using David's Batch Processor. It will let you define a fixed region to crop from an image and save as png, then apply that to multiple images. No scripting necessary. Google DBP.

-- David