File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -55,12 +55,16 @@ def annotate(
5555 drawer = ImageDraw .Draw (canvas )
5656 drawer .polygon (self .bounds , fill = fill , outline = outline , width = width )
5757
58- def warp (self , canvas : Image .Image ) -> Image .Image : # pragma: no cover
58+ def warp (
59+ self , canvas : Image .Image , width : int = 240 , height : int = 80
60+ ) -> Image .Image : # pragma: no cover
5961 """
6062 Warps the image with perspective based on the bounding polygon.
6163
6264 Args:
6365 canvas (PIL.Image.Image): The image to be warped.
66+ width (int): The width of the output warped image. Defaults to 240.
67+ height (int): The height of the output warped image. Defaults to 80.
6468
6569 Returns:
6670 PIL.Image.Image: The warped image.
@@ -69,14 +73,12 @@ def warp(self, canvas: Image.Image) -> Image.Image: # pragma: no cover
6973 startpoints = self .bounds ,
7074 endpoints = [
7175 (0 , 0 ),
72- (canvas . width , 0 ),
73- (canvas . width , canvas . height ),
74- (0 , canvas . height ),
76+ (width , 0 ),
77+ (width , height ),
78+ (0 , height ),
7579 ],
7680 )
77- return canvas .transform (
78- (canvas .width , canvas .height ), Image .Transform .PERSPECTIVE , coeffs
79- )
81+ return canvas .transform ((width , height ), Image .Transform .PERSPECTIVE , coeffs )
8082
8183
8284Q = np .array (
You can’t perform that action at this time.
0 commit comments