[Gimp-user] 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 -- Fab (via www.gimpusers.com) ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] 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 ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] python script for rectangle selection
On Sat, Jan 2, 2010 at 1:44 PM, Fab for...@gimpusers.com 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 import os from gimpfu import * # size and position of rectangle areaWidth = 200 areaHeight = 200 areaPosX = 20 areaPosY = 20 # path to save PNG path = os.path.join(os.path.expanduser('~'),'Desktop') # operate on first image img = gimp.image_list()[0] filename = img.name + -sm.png fullpath = os.path.join(path, filename); tmp = img.duplicate() tmp.flatten() tmp.crop(areaWidth, areaHeight, areaPosX, areaPosY) pdb.file_png_save(tmp, tmp.layers[0], fullpath, filename, 0, 9, 1, 1, 1, 1, 1) #pdb.gimp_image_delete(tmp) ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] 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 ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user