Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading