Forums

The Image module

Hello

I need to crop an image on Python anywhere, which means I need the Image module.

Could you include it please.

Thanks

Robert

To answer my own post... I see I can get it by doing

from PIL import Image

Please ignore me...

Actually, you've hit an interesting problem there. PIL is a funny module, with a slightly schizophrenic attitude to how you should import things from it. If you look at their handbook, the tutorial pages say that you should to this:

import Image
im = Image.open("lena.ppm")

...but the reference pages say that you should do this:

from PIL import Image
im = Image.open("bride.jpg")

This has led to a lot of confusion for a lot of people, and there are multiple packages of PIL that use different import patterns.

The from PIL import Image pattern seems to be the most generally-popular one -- and it seems cleaner because it makes it clear which package's Image class you want to use. So we use a PIL install that works that way.

That was freaky. I was reading the links in giles post above to see where they go. Being that I'm getting so accustomed to reading pythonanywhere.com at first I read pythonware as pythonanywhere...☺

The tricks our minds will play on us if we're not careful...