DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Convert A GTK Pixbuf To A PIL Image

09.07.2005
| 6323 views |
  • submit to reddit
        
import gtk
import Image

def pixbuf2Image(pb):
   width,height = pb.get_width(),pb.get_height()
   return Image.fromstring("RGB",(width,height),pb.get_pixels() )

pb = gtk.gdk.pixbuf_new_from_file( "p20050424_160333.jpg" )
im = pixbuf2Image(pb)
im.save("welldone.jpg", "JPEG",quality=80)