Question

i am trying to do something with the PIL Image library in django, but i experience some problems.

I do like this:

import Image

And then I do like this

images = map(Image.open, glob.glob(os.path.join(dirpath, '*.thumb.jpg')))

But when i try to run this i get an error and it leeds me to think that its not imported correctly, anybody know?

type object 'Image' has no attribute 'open'

Was it helpful?

Solution

The error above happens because your file is called Image.py and you're trying to import yourself. As Manual pointed out, you should import Image from the PIL module, but you'd also need to rename your file so it's not called Image.py.

OTHER TIPS

Your example works fine in my machine. I don't know why you're getting that error. PIL documentation say you have to import the library in this way:

from PIL import Image

You should try that way. As I said, for me works in both ways.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top