I have the need to make a polygonal selection on an image hundreds of times. To help, I have been trying to use the python console to create a script that will do this in a calculated fashion (same size area, hundreds of different start points). I am using GIMP 2.8.18 on a Windows 10 machine.
The problem is that the function pdb.gimp_image_select_polygon does not seem to function.
Here is the bare bones of what I am trying to do in the python console:
theImage = gimp.image_list()[0]
OP_ADD = 0
POINT_COUNT = 5
x = 0
y = 0
points = [0.0 for i in range(0,10)]
points[0] = 64.0 + (128.0 * x)
points[1] = 64.0 * y
points[2] = 128.0 * x
points[3] = 32.0 + (64.0 * y)
points[4] = 64.0 + (128.0 * x)
points[5] = 64.0 + (64.0 * y)
points[6] = 128.0 + (128.0 * x)
points[7] = 32.0 + (64.0 * y)
points[8] = 64.0 + (128.0 * x)
points[9] = 64.0 * y
pdb.gimp_image_select_polygon(theImage, OP_ADD, POINT_COUNT, points)
When this runs, nothing happens. OTOH, if I use another selection function, I get a selection:
pdb.gimp_image_select_rectangle(theImage, 0, 64 ,0 ,128 ,32)
I get no traceback errors using gimp_image_select_polygon, so I know I have the correct number of parameters and the correct types of parameters. I've tried various things and am unable to find much help online.
Does anyone see a problem with my code, or is the python engine in GIMP totally fubar?
The length argument is the number of coordinates, not the number of points (so, typically, the double)
OP_REPLACE
isn't defined in my version.
For a 100x100 square at (100,100):
p=[100,100,100,200,200,200,200,100]
pdb.gimp_image_select_polygon(image, CHANNEL_OP_REPLACE,len(p),p)