1import cv2
2
3src = cv2.imread('D:/cv2-resize-image-original.png', cv2.IMREAD_UNCHANGED)
4
5#percent by which the image is resized
6scale_percent = 50
7
8#calculate the 50 percent of original dimensions
9width = int(src.shape[1] * scale_percent / 100)
10height = int(src.shape[0] * scale_percent / 100)
11
12# dsize
13dsize = (width, height)
14
15# resize image
16output = cv2.resize(src, dsize)
17
18cv2.imwrite('D:/cv2-resize-image-50.png',output)