Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Gtk.Image オブジェクトがあり、そのデータを base64 でエンコードされた文字列に変換したい ( imgurで使用するため)。どうすればそれを達成できますか?
gdk.pixbuf を介して実行する必要がありますが、これが最も簡単なようです。
import cStringIO import base64 pixBuf = gtkImage.get_pixbuf() fH = cStringIO.StringIO() pixBuf.save_to_callback(fH.write, "png") encodedBuffer = base64.b64encode(fH.getvalue()) #base64 encoded png