Thursday, October 23, 2025
HomeLanguagesPython OpenCV – resizeWindow() Function

Python OpenCV – resizeWindow() Function

resizeWindow() method in Python OpenCV is used to resize window displaying images/videos to a specific size. The specified window size is for images excluding toolbars. This only works for created windows having flags other than CV_WINDOW_AUTOSIZE.

Syntax: cv2.resizeWindow(window_name, width, height)

Parameters:

  • window_name: Name of the window that will display image/video
  • width: New window width (integer type)   
  • height: New window height (integer type)

Return Value: It doesn’t return anything

Image used for below examples:

Example 1:

Python3




# Python program to explain cv2.resizeWindow() method
  
# Importing cv2
import cv2
  
# Path
path = 'C:/Users/art/OneDrive/Desktop/Lazyroar.png'
  
# Reading an image in default mode
image = cv2.imread(path)
  
# Naming a window
cv2.namedWindow("Resized_Window", cv2.WINDOW_NORMAL)
  
# Using resizeWindow()
cv2.resizeWindow("Resized_Window", 300, 700)
  
# Displaying the image
cv2.imshow("Resized_Window", image)
cv2.waitKey(0)


Output:

Example 2:

Python3




# Python program to explain cv2.resizeWindow() method
  
# Importing cv2
import cv2
  
# Path
path = 'C:/Users/art/OneDrive/Desktop/Lazyroar.png'
  
# Reading an image in grayscale mode
image = cv2.imread(path, 0)
  
# Naming a window
cv2.namedWindow("Resize", cv2.WINDOW_NORMAL)
  
  
# Using resizeWindow()
cv2.resizeWindow("Resize", 700, 200)
  
# Displaying the image
cv2.imshow("Resize", image)
cv2.waitKey(0)


Output:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS