<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: pixbuf code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 20:20:05 GMT</pubDate>
    <description>DZone Snippets: pixbuf code</description>
    <item>
      <title>convert a PIL image to a GTK pixbuf</title>
      <link>http://snippets.dzone.com/posts/show/655</link>
      <description>free adaptation of http://slugathon.python-hosting.com/changeset/205&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;import gtk&lt;br /&gt;import Image&lt;br /&gt;&lt;br /&gt;def image2pixbuf(im):  &lt;br /&gt;    file1 = StringIO.StringIO()  &lt;br /&gt;    im.save(file1, "ppm")  &lt;br /&gt;    contents = file1.getvalue()  &lt;br /&gt;    file1.close()  &lt;br /&gt;    loader = gtk.gdk.PixbufLoader("pnm")  &lt;br /&gt;    loader.write(contents, len(contents))  &lt;br /&gt;    pixbuf = loader.get_pixbuf()  &lt;br /&gt;    loader.close()  &lt;br /&gt;    return pixbuf  &lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 08 Sep 2005 01:59:05 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/655</guid>
      <author>manatlan (manatlan)</author>
    </item>
    <item>
      <title>convert a GTK pixbuf to a PIL image</title>
      <link>http://snippets.dzone.com/posts/show/641</link>
      <description>&lt;code&gt;&lt;br /&gt;import gtk&lt;br /&gt;import Image&lt;br /&gt;&lt;br /&gt;def pixbuf2Image(pb):&lt;br /&gt;   width,height = pb.get_width(),pb.get_height()&lt;br /&gt;   return Image.fromstring("RGB",(width,height),pb.get_pixels() )&lt;br /&gt;&lt;br /&gt;pb = gtk.gdk.pixbuf_new_from_file( "p20050424_160333.jpg" )&lt;br /&gt;im = pixbuf2Image(pb)&lt;br /&gt;im.save("welldone.jpg", "JPEG",quality=80)&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 07 Sep 2005 19:11:04 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/641</guid>
      <author>manatlan (manatlan)</author>
    </item>
  </channel>
</rss>
