Posted By

manatlan on 09/10/09


Tagged

image python PIL gtk


Versions (?)

Convert pil image to gtk pixbuf


 / Published in: Python
 

  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  

You need to login to post a comment.