imforge.crop module¶
-
imforge.crop.
crop
(image, polygon, fillcolor=None, cut_out=False, clip=False)¶ Crop image according to given (convex) polygon.
- Parameters
image (PIL.Image.Image) – the (pillow) image to crop
int]] polygon (list[tuple[int,) – the list of points coordinates of the polygon to crop
fillcolor – the color to use for filling area outside of polygon
cut_out (bool) – if
False
(the default), the fillcolor is only used for filling areas outside of original image when doing crop. IlTrue
, then all areas outside of polygon are filled with fillcolor.clip (bool) – if
False
(the default), the cropped image will include the whole polygon, even if some of its coordinates are outside of the original image, which can lead to a large image with areas filled with fillcolor on edges of cropped image. IfTrue
, the polygon is first clipped to the original image box, thus leading to the minimal cropped image containing all the visible parts of polygon in original image.
- Returns
the cropped image
- Return type