dropdown menu

Back To Home

Saturday, March 21, 2020

python-resize image

we can resize image using cv2 module.

Python code:
import cv2

img = cv2.imread('/home/pi/Desktop/download.jpeg') #read the image
width = int(1280 * 0.5) #width to resize
height = int(720 * 0.5) #height to resize
dim = (width, height)
resized = cv2.resize(img, dim, interpolation=cv2.INTER_AREA)  #using API of cv2 resize
cv2.imwrite('/home/pi/Desktop/download_resize.jpg',resized)  #then use cv2 to write out image

original image:


resized image:


No comments:

Post a Comment