Nanda
Nanda

Reputation: 393

How to extract elements of a list into a folder in Python

I have a list of image objects. I want to build a folder comprising the images of this list, so that I can download the folder. Is there a way to do this?

Upvotes: 0

Views: 156

Answers (1)

Tharun K
Tharun K

Reputation: 1180

The PIL Image object has a save function that you can make use of.

Simply loop over each Image object and call the save function and provide it with the path of the image.

Example:

for i, img in enumerate(list_of_imgs):
    img.save(f"{dir}/{i}.jpg")

Upvotes: 1

Related Questions