Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble with vector input for polygon selection
#1
I'm writing a plugin to call python-fu-heal-selection with inputs of the file and the points defining the polygon selection, but cannot get the polygon selection to work.  I have tried using the square polygon select and it works fine, but the generic polygon selection does not accept my input; what's wrong with my script?

Code:
(define
    (heal-select points point_count)
    
    (let*
        (
            (image         (car (gimp-file-load RUN-NONINTERACTIVE "tmp.jpg" "tmp.jpg")))
            (active-layer     (car (gimp-image-get-active-layer image)))            
        )                                            
        
        ;(gimp-image-select-rectangle     image CHANNEL-OP-ADD 122 67 138 81)    
        (set! active-layer (car (gimp-image-get-active-layer image)))    
        (define path-points (list->vector points))
        (gimp-image-select-polygon     image CHANNEL-OP-ADD point_count path-points)
        (python-fu-heal-selection     RUN-NONINTERACTIVE     
                                        image
                                        active-layer
                                        3
                                        0
                                        1)                                            
        (display points)
        (gimp-file-save RUN-NONINTERACTIVE image active-layer  "tmp2.jpg" "tmp2.jpg")
        (gimp-image-delete image)
    
    )
)

With the command line input:
Code:
gimp -i -b "(heal-select '(122. 67. 138. 67. 138. 81. 122. 81. 122. 67.) 5)" -b "(gimp-quit 0)"

I have tried removing '(define path-points (list->vector points))' and passed it the points as #(1 2 3  4) and still get an error message hinting at the fact that the polygon isn't closed or is empty.
Reply
#2
Warning: I starkly refuse to use 1950-era Scheme when I can use 1990-era Python for my Gimp scripts. But there are plenty of common things, so:

It appears that the doc (at least on the Python side...) is somewhat ambiguous. The 'length" parameter is really the plain length of the list of coordinates (which is also how all the other PDB calls work...), so if you have a polygon with 5 points, it should say "10". Note that you don't need to specify more than N pairs if the polygon has N summits, because Gimp will auto-close the polygon (so in your case, (122. 67. 138. 67. 138. 81. 122. 81.) 8) should work).
Reply
#3
Jesus, such a simple fix. I assumed it was 5 (x,y) pairs...
Reply


Forum Jump: