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