Python: Resize the Image Size
作者:XD / 发表: 2021年7月7日 13:23 / 更新: 2021年7月7日 13:23 / 编程笔记 / 阅读量:2265
Resize the image size with Python OpenCV.
import cv2
path = 'test.jpg'
img = cv2.imread(path, 1)
img_size = img.shape
height = img_size[0]
width = img_size[1]
resize_height = int(height * 0.5)
resize_width = int(width * 0.5)
new_image = cv2.resize(img, (resize_width, resize_height))
resize_file = 'resize_' + path
cv2.imwrite(resize_file, new_image)