title: PIL image.open() not working for my .png
body: <p>I use PIL to open image for extracting several bits and writing them to string. It supposed to be, that this code will filter except ones, that have (R&lt;=1 &amp;&amp; G&lt;=1 &amp;&amp; B&lt;=1) and took last bit of each color. The matter is that it doesn't work.</p>
  
  <pre><code>from PIL import Image
  def extract_bits(color, bitmask):
      bitmask_len = len(bin(bitmask)[2:])
      extracted_bits = bin(color &amp; bitmask)[2:]
      extracted_bits = '0' * (bitmask_len - len(extracted_bits)) + extracted_bits
  
      return extracted_bits
  
  if __name__ == '__main__':
      img = Image.open('IMG_0707png')
      pixels = list(img.getdata())
  
      bits = ''
      for i in range(0, len(pixels), 1):
          r = pixels[i][0]
          g = pixels[i][1]
          b = pixels[i][2]
  
          if not (r &lt;= 1 and g &lt;= 1 and b &lt;= 1): continue
  
          bits += extract_bits(r, 0x1)
          bits += extract_bits(g, 0x1)
          bits += extract_bits(b, 0x1)
  
      bits += '0' * (8 - len(bits) % 8)
  
      text = ''
      for i in range(0, len(bits), 8):
          text += chr(int(bits[i:i+8], 2))
      print text
  </code></pre>
  
  <p>I looked around this problem, and found solution that doesn't work in my case.
  <code>img = Image.open(open('IMG_0707.png', 'rb'))</code>
  In both cases I get </p>
  
  <pre><code>File "&lt;stdin&gt;, line 1, in &lt;module&gt;"
  File "&lt;string&gt;" line11, im &lt;module&gt;
  File "c:\python27\lib\site-packages\PIL\Image.py", line 1980, in open
  raise IOError("cannot identify image file")
  IOError: cannot identify image file
  </code></pre>
  
  <p>Also I tried to specify exact path with no luck.</p>
  
  <pre><code>img = Image.open(open("IMG_0707.png", 'rb'))
  img = Image.open(open("c:\python27\IMG_0707.png", 'rb'))
  img = Image.open(open("c:/python27/IMG_0707.png", 'rb'))
  </code></pre>
  
  <p>And so on. I would be grateful for any help.
  <a href="http://bit.ly/14qCm2X" rel="nofollow">Image, im trying to open</a></p>