{"id":46,"date":"2008-08-13T22:57:14","date_gmt":"2008-08-13T20:57:14","guid":{"rendered":"http:\/\/lisas.de\/~alex\/?p=46"},"modified":"2008-08-13T22:57:14","modified_gmt":"2008-08-13T20:57:14","slug":"pickeling-pixbuf-pixel-arrays","status":"publish","type":"post","link":"https:\/\/lisas.de\/~alex\/?p=46","title":{"rendered":"Pickeling Pixbuf Pixel Arrays"},"content":{"rendered":"<p>After lots of googling, I finally figured how to <a title=\"pickle\" href=\"http:\/\/docs.python.org\/lib\/module-pickle.html\">pickle<\/a> a <a title=\"Pixbuf\" href=\"http:\/\/www.pygtk.org\/docs\/pygtk\/class-gdkpixbuf.html\">gtk.gdk.Pixbuf<\/a>&#8216;s pixel array. I was looking for a way to pickle a Pixbuf&#8217;s image data into a file easily. The original C API provides a dedicated interface for that, unfortunately the <a title=\"GTK+ for Python\" href=\"http:\/\/www.pygtk.org\/\">pygtk<\/a> developers seem to <a title=\"GNOME Bug\" href=\"http:\/\/bugzilla.gnome.org\/show_bug.cgi?id=309469\">believe that there is no need to support it<\/a> with the <a title=\"Python\" href=\"http:\/\/python.org\/\">Python<\/a> binding. So I tried to get access to the image data through the Pixbuf&#8217;s <code>pixel_array<\/code> property. Unfortunately this will yield an unpickleable standard Python <code>array<\/code> instance if you import <code>gtk<\/code> only. If you also import <a title=\"Python Numeric\" href=\"http:\/\/people.csail.mit.edu\/jrennie\/python\/numeric\/\">Numeric<\/a> (assuming you have it available) a call to <code>get_pixel_array()<\/code> will yield a Numeric <code>array<\/code> instance instead and Numeric arrays are very well pickleable.<\/p>\n<p>Hopefully this will speed up other people&#8217;s googling.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After lots of googling, I finally figured how to pickle a gtk.gdk.Pixbuf&#8216;s pixel array. I was looking for a way to pickle a Pixbuf&#8217;s image data into a file easily. The original C API provides a dedicated interface for that, unfortunately the pygtk developers seem to believe that there is no need to support it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-46","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/lisas.de\/~alex\/index.php?rest_route=\/wp\/v2\/posts\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lisas.de\/~alex\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lisas.de\/~alex\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lisas.de\/~alex\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lisas.de\/~alex\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=46"}],"version-history":[{"count":0,"href":"https:\/\/lisas.de\/~alex\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions"}],"wp:attachment":[{"href":"https:\/\/lisas.de\/~alex\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lisas.de\/~alex\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lisas.de\/~alex\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}