title: Can someone help me with my PIL function?
body: <pre><code>def pad_image(f, width=500, height=None):
      if height==None:
          height = width
      image = Image.new("RGB", (800, 600),  (0, 0, 0, 0))
      image.paste(StringIO(f), (0,0, 50, 50))
      res = StringIO()
      image.save(res, 'JPEG')
      res.seek(0)
      return res
  </code></pre>
  
  <p>I am trying to paste my image, <code>f</code>, in a 500x500 white canvas. (in the middle).</p>
  
  <p>This is my function so far, but I'm having lots of trouble.  I'm having so many problems, and I haven't even touched the height/width part.</p>
  
  <pre><code>Traceback (most recent call last):
    File "resizer.py", line 23, in &lt;module&gt;
      thumbnail = tools.create_thumbnail(pic,300)
    File "../lib/tools.py", line 84, in create_thumbnail
      thumbnail_file = pad_image(thumbnail_file.read())
    File "../lib/tools.py", line 92, in pad_image
      image.paste(f, (0,0, 50, 50))
    File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 1085, in paste
      im = ImageColor.getcolor(im, self.mode)
    File "/usr/lib/python2.6/dist-packages/PIL/ImageColor.py", line 101, in getcolor
      color = getrgb(color)
    File "/usr/lib/python2.6/dist-packages/PIL/ImageColor.py", line 97, in getrgb
      raise ValueError("unknown color specifier: %r" % color)
  ValueError: unknown color specifier: '\xff\xd8\xff\
  </code></pre>