Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I load an image using Python Pillow?

Tags:

python

pillow

I load an image this way:

from PIL import Image
im = Image.open('test.png')

gives me the following error:

IOError: [Errno 2] No such file or directory: 'test.png'

I have saved the image 'test.png' on the desktop.

So where should I save the image?

like image 739
KeKe Avatar asked Jul 28 '15 01:07

KeKe


1 Answers

You need to give the directory where the file is located. So if you put in desktop it should go something like this:

Image.open('C:\Users\$(your_user_name)\Desktop\test.png')

or move the file "test.png" to folder where your script is.

like image 79
pranavrao1 Avatar answered Sep 30 '22 16:09

pranavrao1