convert a gtk pixbul to a pil image


/ 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 pixbuf2Image(pb):
  5. width,height = pb.get_width(),pb.get_height()
  6. return Image.fromstring("RGB",(width,height),pb.get_pixels() )
  7.  
  8. pb = gtk.gdk.pixbuf_new_from_file( "p20050424_160333.jpg" )
  9. im = pixbuf2Image(pb)
  10. im.save("welldone.jpg", "JPEG",quality=80)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.