def pil_image_to_pixbuf(self, image_fn, angle):
"""use Python Image Library (PIL) to load an image, rotate it, and return as a pixbuf)
"""
pixbuf = None
if os.path.isfile(image_fn):
pil_image = PIL.Image.open(image_fn)
if angle is not 0:
pil_image = pil_image.rotate(angle,PIL.Image.BICUBIC,1)
fd = StringIO.StringIO()
pil_image.save(fd, "png")
contents = fd.getvalue()
fd.close()
loader = gtk.gdk.PixbufLoader("png")
loader.write(contents, len(contents))
pixbuf = loader.get_pixbuf()
loader.close()
#done
return pixbuf
评论列表
文章目录