openCV python resize photo code example
Example 1: resize imshow opencv python
import cv2
cv2.namedWindow("output", cv2.WINDOW_NORMAL)
im = cv2.imread("earth.jpg")
imS = cv2.resize(im, (960, 540))
cv2.imshow("output", imS)
cv2.waitKey(0)
Example 2: opencv python shrink image
import cv2
src = cv2.imread('D:/cv2-resize-image-original.png', cv2.IMREAD_UNCHANGED)
scale_percent = 50
width = int(src.shape[1] * scale_percent / 100)
height = int(src.shape[0] * scale_percent / 100)
dsize = (width, height)
output = cv2.resize(src, dsize)
cv2.imwrite('D:/cv2-resize-image-50.png',output)