cv2.imwrite() is an OpenCV function used to save an image to storage in any supported format such as JPG, PNG, or BMP. It saves the provided image to the given filename, and the format is determined automatically by the file extension.
Note: For this article, we will use sample images "flower.jpg" and "eyes.jpg", download it and make sure to keep the image in same folder as your python script.
Example: This example loads an image and saves it with a new filename in the same directory.
import cv2
img = cv2.imread("flower.jpg")
cv2.imwrite("saved_image.jpg", img)
Output