Skip to content

Commit 15afd50

Browse files
committed
add argument width and height
1 parent 900b7f2 commit 15afd50

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

wpodnet/backend.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff 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 = 208, height: int = 60
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 208.
67+
height (int): The height of the output warped image. Defaults to 60.
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

8284
Q = np.array(

0 commit comments

Comments
 (0)