Over a million developers have joined DZone.

Convert A PIL Image To A GTK Pixbuf

DZone's Guide to

Convert A PIL Image To A GTK Pixbuf

· ·
Free Resource
free adaptation of http://slugathon.python-hosting.com/changeset/205

import gtk
import Image

def image2pixbuf(im):  
    file1 = StringIO.StringIO()  
    im.save(file1, "ppm")  
    contents = file1.getvalue()  
    loader = gtk.gdk.PixbufLoader("pnm")  
    loader.write(contents, len(contents))  
    pixbuf = loader.get_pixbuf()  
    return pixbuf  

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}