Pillow keeps throwing cannot identify image file on Window in Python2.7.6
Question: I'm using Python2.7.6 and Pillow 2.3.0 on 32 bits Windows. And I do **not**
have PIL installed on my machine.

My problem is when I do following I get _"cannot identify image file"_ error.

    
    
    >>> from PIL import Image
    >>> file = open(r"C:\\a.jpg", 'r')
    >>> image = Image.open(file)
     Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\Python27\lib\site-packages\pillow-2.3.0-py2.7-win32.egg\PIL\Image.py", line 2025, in open
      IOError: cannot identify image file
    

But this works if I don't _"Open"_ the file before opening it with
`Image.Open`:

    
    
    >>> image2 = Image.open(r"C:\\a.jpg", 'r')
    

NOTE: I cannot omit the _"Open"_ statement.

Does anyone know what may be causing this strange behavior?

Thanks, in advance!


Answer: Don't do `image = Image.open(file)` , you already opened the file.

Try `image = Image.open("C:\\a.jpg")`

Here is the Image module: <http://effbot.org/imagingbook/image.htm>

**EDIT:**

**Use 'rb' instea of 'r'** when opening the file

