Write Multiple images into a folder using python cv2

Write Multiple images into a folder using python cv2

Hello Friends,

In this post I will guide you how to write multiple images into a folder using python cv2. Images are read which you can find in my previous post on Read Multiple images from a folder using python cv2. If you face any problem in installing opencv with windows, Please visit my blog on it by clicking here.

Please follow this code as well follow the previous post on Read Multiple images from a folder using python cv2 to get synchronized with reading and writing images in python opencv

# import the library opencv
import cv2
# globbing utility.
import glob
# select the path
path = "A:\images\input_images\*.*"
for bb,file in enumerate (glob.glob(path)):
image_read = cv2.imread(file)
# conversion numpy array into rgb image to show
c = cv2.cvtColor(image_read, cv2.COLOR_BGR2RGB)
# writing the images in a folder output_images
cv2.imwrite('A:\images\output_images\messigray{}.png'.format(bb), c)
cv2.imshow('Color image', c)
# wait for 1 second
k = cv2.waitKey(1000)
# destroy the window
cv2.destroyAllWindows()

Final screenshot of some of the images written is as below

Write Images using Python OpenCV

Originally published at http://ersanpreet.wordpress.com on August 15, 2018.

Passionate developer. Read more at https://ersanpreet.wordpress.com/