How to Save an Image in Python

Spread the love

In our previous post, we learned how to load an image in python , In this post you will learn how to save an image in python.

Save an Image in Python –

To save an image in OpenCV, we use imwrite method. If you have not installed OpenCV then read this post.

First load an image

# load an image
image = cv2.imread('maldives.jpg', cv2.IMREAD_COLOR)

# convert from BGR to RGB
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# show image

Now to save this image, you have to write

# save image
cv2.imwrite("maldives_new.jpg", image)

output - 

Rating: 1 out of 5.

Leave a Reply