Roy Smith
unread,Oct 23, 2012, 2:06:59 PM10/23/12You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
I have a url from which I can get an image. I want to use PIL to
manipulate that image. Getting the image is easy:
>>> import requests
>>> r = requests.get(url)
There's a bunch of factory functions for Image, but none of them seem
to take anything that requests is willing to give you. Image.new()
requires that you pass it the image size. Image.open() takes a file
object, but
>>> Image.open(r.raw)
doesn't work because r.raw gives you a socket which doesn't support
seek(). I end up doing:
>>> r = requests.get(url)
>>> data = cStringIO.StringIO(r.content)
>>> image = Image.open(data)
which works, but it's gross. Is there something I'm missing here?