title: Image resize and get data in a buffer using python
body: <p>I want to resize the input image to a fixed size. Then I want to entire content of the resized image file in a buffer for further use like, appending it with other buffer(data).</p>
  
  <p>Currently I am doing it using the following python function,</p>
  
  <pre><code>def get_resize_img(img_file):
      img = Image.open(img_file)
      img = img.resize((640,960), Image.NEAREST)
      img.save("tmp_out.jpg")
      fp = open("tmp_out.jpg", "rb")
      data = fp.read()
      fp.close()
      print "img sz:", len(data)
      return data
  </code></pre>
  
  <p>Is there any better way to achieve this without writing into a dummy file (tmp_out.jpg) and reading back from it.</p>
  
  <p>-Mohan</p>