IOError: cannot identify image file <cStringIO.StringI object at 0x0000000005796E00>
See original GitHub issuei got this problem when i use the ImagesPipeline to download some image(but some image can be download)…such as this image url:
this image can`t be download.
i think it is because the image type is JFIF,and the ImagesPipeline is not support . i dont know how to Solve this problem, please help me
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Python PIL: IOError: cannot identify image file - Stack Overflow
when I open the file using ... This is not returning an image. ... StringIO(response.read()) image = Image.open(img_file).
Read more >cannot identify image file <cStringIO.StringI object at ... - Odoo
Hello All,. Here is the issues that I am facing cannot identify image file <cStringIO.StringI object at some memory location>.
Read more >cannot identify image file <_io.BytesIO object at ... - Medium
실행 코드. “cannot identify image file <_io.BytesIO object at 0x7f901ee4ef68>” is published by psubin_smile.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi folks, this is marked as “not reproducible”, and it’s a bit stale, so I’m inclined to close it. However, if anyone finds a clearly reproducible example, please come back to us and discuss/reopen.
Something quick to consider: If you want images and you don’t need them resized/converted/thumbnailed, you can use the filespipeline to download them also. In fact, it should be faster and more efficient. This should be your first recourse if PIL/low - unsupported images become a problem.
Finally @ZhouYangL - I haven’t attempted to replicate your shell session, especially as it uses an image that looks prone to changing, and it’s been a few months. But I suspect your issue likes in the statement
browser.page_source.encode('utf-8')
, which is being called on what seems to be binary image content. I am guessing that you are using Python 2, because this kind of transform would be very unlikely to occur in Python 3? I suggest that the page contents are probably correct image binary as-is, and should not be encoded into a text-encoding such as UTF8.Thanks everyone!
I got the @redapple , @mr-huangyang , @MaGuiSen , @dydjiangtao , @gasbakid please help me. I used
scrapy shell url
, it not questionurl='https://img.alicdn.com/bao/uploaded/i2/133560252265971710/TB2ZRMHsFXXXXXZXFXXXXXXXXXX_!!0-rate.jpg'
from PIL import Image
from cStringIO import StringIO as BytesIO
orig_image = Image.open(BytesIO(response.body))
but when I use selenuim and scrapy , I get the same question:
from selenium.webdriver import Chrome
from scrapy.http import HtmlResponse
browser = Chrome()
browser.get('https://img.alicdn.com/bao/uploaded/i2/133560252265971710/TB2ZRMHsFXXXXXZXFXXXXXXXXXX_!!0-rate.jpg')
r=HtmlResponse('https://img.alicdn.com/bao/uploaded/i2/133560252265971710/TB2ZRMHsFXXXXXZXFXXXXXXXXXX_!!0-rate.jpg', body=browser.page_source.encode('utf-8'), encoding='utf-8')
orig_image = Image.open(BytesIO(r.body))
then it have debugs
orig_image = Image.open(BytesIO(r.body))
/usr/local/lib/python2.7/site-packages/PIL/Image.pyc in open(fp, mode) 2570 fp.close() 2571 raise IOError("cannot identify image file %r" -> 2572 % (filename if filename else fp)) 2573 2574 #
IOError: cannot identify image file <cStringIO.StringI object at 0x102d0ef10>