Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31950
| From | roy@panix.com (Roy Smith) |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | PIL and requests don't get along |
| Date | 2012-10-23 14:06 -0400 |
| Organization | PANIX -- Public Access Networks Corp. |
| Message-ID | <k66mc3$ed3$1@panix2.panix.com> (permalink) |
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?
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
PIL and requests don't get along roy@panix.com (Roy Smith) - 2012-10-23 14:06 -0400
Re: PIL and requests don't get along Alex Clark <aclark@aclark.net> - 2012-10-23 14:28 -0400
Re: PIL and requests don't get along Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2012-10-24 11:25 +0530
Re: PIL and requests don't get along Roy Smith <roy@panix.com> - 2012-10-24 09:35 -0400
csiph-web