Resize Multiple Images using OpenCV-Python Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 2 Likes Like Report In this article, we are going to write a python script using the OpenCV library to Resize Multiple Images and save them as an image file. Resizing the image refers to the growth of the images. Measurement works best in the use of multiple images and in machine learning applications. It helps to reduce the number of pixels from an image and that has several benefits e.g. It can reduce neural network training time as the number of pixels in the image greatly increases the number of input nodes which also improves the model difficulty. Approach: Firstly, load the required libraries into a Python file (argparse, OpenCV, etc.).We are using argparse() function to get the path of the directory of images on which we need to perform the resizing.Use for loop to iterate every image in the directory.Load image in a variable using cv2.imread() function.Define a resizing scale and set the calculated height and width.Resize the image using cv2.resize() function.Place the output file inside the output folder using cv2.imwrite() function. All the images inside the Images folder will be resized and will be saved in an output folder. Below is the implementation: Python3 # Required Libraries import cv2 import numpy as np from os import listdir from os.path import isfile, join from pathlib import Path import argparse import numpy # Argument parsing variable declared ap = argparse.ArgumentParser() ap.add_argument("-i", "--image", required=True, help="Path to folder") args = vars(ap.parse_args()) # Find all the images in the provided images folder mypath = args["image"] onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] images = numpy.empty(len(onlyfiles), dtype=object) # Iterate through every image # and resize all the images. for n in range(0, len(onlyfiles)): path = join(mypath, onlyfiles[n]) images[n] = cv2.imread(join(mypath, onlyfiles[n]), cv2.IMREAD_UNCHANGED) # Load the image in img variable img = cv2.imread(path, 1) # Define a resizing Scale # To declare how much to resize resize_scaling = 50 resize_width = int(img.shape[1] * resize_scaling/100) resize_hieght = int(img.shape[0] * resize_scaling/100) resized_dimensions = (resize_width, resize_hieght) # Create resized image using the calculated dimensions resized_image = cv2.resize(img, resized_dimensions, interpolation=cv2.INTER_AREA) # Save the image in Output Folder cv2.imwrite( 'output/' + str(resize_width) + str(resize_hieght) + str(n) + '_resized.jpg', resized_image) print("Images resized Successfully") Open the terminal in the folder where this Python Script is saved and type the below command. python resize.py --image path/to/images/folder/ Output: Create Quiz Comment I idevesh Follow 2 Improve I idevesh Follow 2 Improve Article Tags : Python OpenCV Python-OpenCV Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 4 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 3 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 3 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 4 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 3 min read StatsModel Library - Tutorial 3 min read Learning Model Building in Scikit-learn 6 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 5 min read Build a REST API using Flask - Python 3 min read Building a Simple API with Django REST Framework 3 min read Python PracticePython Quiz 1 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like