title: Is it possible to create encoded base64 URL from Image object?
body: <p>I am looking to create base64 inline encoded data of images for display in a table using canvases. Python generates and creates the web page dynamically. As it stands python uses the Image module to create thumbnails. After all of the thumbnails are created Python then generates base64 data of each thumbnail and puts the b64 data into hidden spans on the user's webpage. A user then clicks check marks by each thumbnail relative to their interest. They then create a pdf file containing their selected images by clicking a generate pdf button. The JavaScript using jsPDF generates the hidden span b64 data to create the image files in the pdf file and then ultimately the pdf file.</p>
  
  <p>I am looking to hopefully shave down Python script execution time and minimize some disk I/O operations by generating the base64 thumbnail data in memory while the script executes.</p>
  
  <p>Here is an example of what I would like to accomplish.</p>
  
  <pre><code>import os, sys
  import Image
  size = 128, 128
      im = Image.open("/original/image/1.jpeg")
      im.thumbnail(size)
      thumb = base64.b64encode(im)
  </code></pre>
  
  <p>This doesn't work sadly, get a TypeErorr -</p>
  
  <pre><code>TypeError: must be string or buffer, not instance
  </code></pre>
  
  <p>Any thoughts on how to accomplish this?</p>