Python Image.open() gives 'object has no attribute' error
<p>I am trying to use <code>requests.get()</code> to open/get a file for image processing but my code falls over when I try to do an <code>Image.open()</code> with the file I have just got.</p>

<p>My code is:</p>

<pre><code>conn = S3Connection(settings.AWS_ACCESS_KEY_ID, settings.AWS_SECRET_ACCESS_KEY)
bucket = conn.get_bucket(settings.AWS_STORAGE_BUCKET_NAME)

for key in bucket.list(prefix='media/userphotos'):
    file_name=key.name
    full_path_filename = 'https://' + settings.AWS_STORAGE_BUCKET_NAME + '.s3.amazonaws.com/' + file_name
    fd_img = requests.get(full_path_filename);
    img = Image.open(fd_img)
    img = resizeimage.resize_width(img, 800)
    new_filename = file_name
    new_filename.replace('userphotos', 'webversion')
    full_path_filename =  'https://' + settings.AWS_STORAGE_BUCKET_NAME + '.s3.amazonaws.com/' + new_filename
    img.save(full_path_filename, img.format)
    fd_img.close()
</code></pre>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>The traceback is: 

Traceback:

File "/Users/billnoble/Documents/YHistory-Server/yhistoryvenv/lib/python3.4/site-packages/PIL/Image.py" in open
  2275.         fp.seek(0)

During handling of the above exception ('Response' object has no attribute 'seek'), another exception occurred:

File "/Users/billnoble/Documents/YHistory-Server/yhistoryvenv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "/Users/billnoble/Documents/YHistory-Server/yhistoryvenv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/Users/billnoble/Documents/YHistory-Server/items/views.py" in xformpics
  67.         img = Image.open(fd_img)

File "/Users/billnoble/Documents/YHistory-Server/yhistoryvenv/lib/python3.4/site-packages/PIL/Image.py" in open
  2277.         fp = io.BytesIO(fp.read())

Exception Type: AttributeError at /xformpics
Exception Value: 'Response' object has no attribute 'read'</code></pre>
</div>
</div>
</p>

<p>It all works fine up to the <code>Image.open()</code>.</p>

<p>I have spent many hours googling this issue but cannot find a solution.</p>