[Tutor] how do i open picture files without knowing the file name?

Michael C mysecretrobotfactory at gmail.com
Tue May 16 14:49:28 EDT 2017


I am running this code so I can do some image manipulation with them.
The thing is, I have a lot of pictures to go through, so I can't type the
file names
one by one in the code. However, the order of the files to be processed
doesn't
matter, so getting them in a random fashion is alright!

How do I make the python code open picture files? thanks!








## need to open random png. Any png.

from PIL import Image


## need to load picture so I can process them. Any pictures is fine as
## I need to process every picture in the folder
im = Image.open('1.png')

## do my things...


More information about the Tutor mailing list