Resize an Image Using Python OpenCV

In this turorial, we will learn how to resize an image using python opencv.

1. Import library

import cv2

2. Read an image

img = cv2.imread('C:/Users/N/Desktop/test.jpg')

3. Resize an image by widht and height

resized = cv2.resize(img, (200,200))

This code will resize an image to width = 200, height = 200

4. Resize an image by scale

resized2 = cv2.resize(img, None, fx = 2.0, fy = 2.0)

5. Show resized images

cv2.imshow('Resized img 1', resized)
cv2.imshow('Resized img 2', resized2)
 
cv2.waitKey(0)
cv2.destroyAllWindows()