Daniel
Daniel

Reputation: 4342

open image from the web with python image library

I am new to python and am working with python image library. I just want to be able to open an image from the web and get the histogram from this image. Unfortunately I get the error File "new.py", line 1 from PIL import Image import urllib and it does not work. Any idea how to get this working?

from PIL
import Image
import urllib

im = Image.open(urllib.urlopen("http://fmforums.com/forum/uploads/profile/photo-thumb-57725.jpg"))
im = im.convert("P")

print im.histogram()

Upvotes: 0

Views: 169

Answers (1)

BrtH
BrtH

Reputation: 2664

The error is in the first two lines of your program.

from PIL
import Image

should be

from PIL import Image

For more information about importing in python, see here.

Upvotes: 2

Related Questions