How to crop a region selected with mouse click, using Python Image Library? -
How to crop a region selected with mouse click, using Python Image Library? -
is there way select part in image mouse click , crop these part using python pil ? how can it?
thanks
the pil library provides no gui code --what asking application gui. i'd suggest using tkinter + pil, there no way trivial - have handle mouse clicks, create rectangle object tracking it, have way "reset" rectangle, , on.
unfortunatelly canvas tkinter widget used draw things on poorly documented - have read trough here: http://www.pythonware.com/library/tkinter/introduction/canvas.htm
bellow there illustration code reads image file disk , draws on tkinter window. can see, here object juggling right.
import tkinter import image, imagetk, imagedraw image_file = "svg.png" w = tkinter.tk() img = image.open(image_file) width, height = img.size ca = tkinter.canvas(w, width=width, height=height) ca.pack() photoimg = imagetk.photoimage("rgb", img.size) photoimg.paste(img) ca.create_image(width//2,height//2, image=photoimg) tkinter.mainloop()
python image image-processing python-imaging-library
Comments
Post a Comment