Coders Packet

Image Resizer And Cropper With OpenCV In Python

By Prachi Namdeo

In this project, resizing and cropping of images is done with the help of OpenCV in Python. Here, we use the cv2 library.

First of all, we need to install the OpenCV-python package. With the help of the following command, we can install it.

cmd:- pip install opencv-python

then, we have to import its library in our code as "import cv2"

OpenCV-Python is a library of Python bindings designed to solve computer vision problems. cv2.imread() method loads an image from the specified file.

To resize the image we have to save it in the image directory and we have to specify its path in the cv2.imread() method.

As we used in our code as :- cv2.imread('image/STOP.jpg')

In the "Resize and Crop" directory we have created two separated files: the first file is "" which is used to resize our given image. And another file is "" which is used to crop the image.

Here, we can resize and crop the given image by using OpenCV.

Download Complete Code


No comments yet