Convert pil image to gtk pixbuf


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import gtk
  2. import Image
  3.  
  4. def image2pixbuf(im):
  5. file1 = StringIO.StringIO()
  6. im.save(file1, "ppm")
  7. contents = file1.getvalue()
  8. file1.close()
  9. loader = gtk.gdk.PixbufLoader("pnm")
  10. loader.write(contents, len(contents))
  11. pixbuf = loader.get_pixbuf()
  12. loader.close()
  13. return pixbuf

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.