Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion imutils/convenience.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,20 @@ def rotate_bound(image, angle):
# perform the actual rotation and return the image
return cv2.warpAffine(image, M, (nW, nH))

def resize(image, width=None, height=None, inter=cv2.INTER_AREA):
def resize(image, width: int=None, height: int=None, inter=cv2.INTER_AREA):
"""
Resizes an image while retaining its aspect ratio.

Args:
image: The image to resize
width (int, optional): The width of the resized image in pixels.
height (int, optional): The height of the resized image in pixels. Ignored if a width is given.
inter (int, optional): Interpolation mode. Defaults to cv2.INTER_AREA.

Returns:
the resized image.
"""

# initialize the dimensions of the image to be resized and
# grab the image size
dim = None
Expand Down