title: PIL Image getpixel TypeError: 'int' object is not iterable
body: <p>I want to use the <code>getpixel((w,h))</code> method of <code>PIL.Image</code> but we processing image this give a </p>
  
  <p><code>TypeError: 'int' object is not iterable</code></p>
  
  <p>Error, it seems that method don't return a three elements tuple, have tried with both png file and jpg file same result, what happend?</p>
  
  <pre><code>#!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  from PIL import Image
  
  def makeIndex():
      pic = Image.open('lines.jpg')
      width = pic.width
      height = pic.height
      for w in range(0, width):
          for h in range(0, height):
              r,g,b= pic.getpixel((w,h))
              print (r,g,b)
  
  
  
  if __name__ == "__main__":
      makeIndex()
  
  # vim:ai:et:sts=4:sw=4:
  </code></pre>
  
  <h2>EDIT</h2>
  
  <p>as mentioned by the comment this time I chose another png file to do the test and do a <code>convert('RGB')</code> before processing</p>
  
  <pre><code>    pic = Image.open('stencil.png').convert('RGB')
      width = pic.width
      height = pic.height
      for w in range(0, width):
          for h in range(0, height):
              r,g,b= pic.getpixel((w,h))
              print (w,h), (r,g,b)
  </code></pre>
  
  <p>And this give a result of </p>
  
  <pre><code>(106, 988) (141, 60, 146)
  (106, 989) (141, 60, 146)
  (106, 990) (141, 60, 146)
  (106, 991) (141, 60, 146)
  (106, 992) (130, 36, 36)
  (106, 993) (130, 36, 36)
  (106, 994) (130, 36, 36)
  (106, 995) (130, 36, 36)
  (106, 996) (130, 36, 36)
  (106, 997) (130, 36, 36)
  (106, 998) (130, 36, 36)
  (106, 999) (130, 36, 36)
  </code></pre>
  
  <p>And each has different r,g,b value</p>
  
  <p>So what does this <code>layer</code> things really mean?</p>
  
  <p><a href="https://i.stack.imgur.com/FrGGq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FrGGq.png" alt="enter image description here"></a></p>