Python | OpenCV program to read and save an Image Last Updated : 04 Jan, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-time computer vision. This is cross-platform library, it provides functions that are used in multiple languages. Coming to image processing, OpenCV enables us to perform multiple operations on image, but in order to do that we need to read an image file as input, then we can perform the desired operation and we can save it. Let's see a simple operation to read the image file using OpenCV library and then save it. Functions used : -> imread(Location_of_image, integer): The second parameter is an integer for changing the color of image. -1 To read image Unchanged and 0 To read image in gray scale. -> imwrite(Name_after_save, variable_containing_read_image) ->waitKey(0): After execution will keep the window open till a key is pressed -> destroyAllWindow(): It will close all the windows that were opened during the program run. Below is the Python implementation: Python3 # Python Program To Read And Save image import numpy as np import cv2 # This will give error if you don't have a cv2 module img = cv2.imread("G:\demo.jpg", -1) # img is object of cv2 and stores the image read demo.jpg cv2.imwrite("outputimage.jpg", img) # The image is saved in folder where program is stored cv2.waitKey(0) cv2.destroyAllWindow() Input : Output : Comment More infoAdvertise with us Next Article Watermarking images with OpenCV and Python S shivamkukreti Follow Improve Article Tags : Python Practice Tags : python Similar Reads Reading an image in OpenCV using Python Prerequisite: Basics of OpenCVIn this article, we'll try to open an image by using OpenCV (Open Source Computer Vision) library.  Following types of files are supported in OpenCV library:Windows bitmaps - *.bmp, *.dibJPEG files - *.jpeg, *.jpgPortable Network Graphics - *.png WebP - *.webp Sun raste 6 min read Python | Program to extract frames using OpenCV OpenCV comes with many powerful video editing functions. In the current scenario, techniques such as image scanning and face recognition can be accomplished using OpenCV. OpenCV library can be used to perform multiple operations on videos. Letâs try to do something interesting using CV2. Take a vide 2 min read Watermarking images with OpenCV and Python In this article, we are going to see how to make watermarking images using OpenCV in Python. Watermark is intentionally left Text/Logo onto the image. Watermarks are generally used by artists to protect the copyright of the image. Using watermarks we can ensure that the owner of the image is the per 4 min read Convert OpenCV image to PIL image in Python OpenCV is a huge open-source library for computer vision, machine learning, and image processing. OpenCV supports a wide variety of programming languages like Python, C++, Java, etc. It can process images and videos to identify objects, faces, or even the handwriting of a human. When it is integrate 3 min read How to Read a JPEG or PNG Image in PyTorch In this article, we are going to discuss how to Read a JPEG or PNG Image using PyTorch in Python. image_read() method In PyTorch, the image_read() method is used to read an image as input and return a tensor of size [C, H, W], where C represents a number of channels and H, W represents height and wi 2 min read Python OpenCV - Getting and Setting Pixels In this article, we will discuss Getting and Setting Pixels through OpenCV in Python. Image is made up of pixels. A pixel will be denoted as an array. The 3 integers represent the intensity of red, green, blue in the same order. Eg. [0,0,0] in RGB mode represent black color. There are other modes a 3 min read Like