is it possible to read an image using Python and pyGTK and change the displayed size (i.e width=xxx height=xxx pixels)?
是否可以使用Python和pyGTK读取图像并更改显示的大小(即width = xxx height = xxx pixels)?
Sorry, about this question. It probably is very simple, but I haven't found an answer yet.
对不起,关于这个问题。这可能很简单,但我还没有找到答案。
1 个解决方案
#1
width = xxx
height = xxx
im = gtk.Image()
pixbuf = gtk.gdk.pixbuf_new_from_file("my.jpg") # Your image file
scaled_buf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)
im.set_from_pixbuf(scaled_buf)
im.show()
For more informations about the last argument of scale_simple
, see interp_type.
有关scale_simple的最后一个参数的更多信息,请参阅interp_type。
Reference : PyGTK FAQ
参考:PyGTK FAQ
#1
width = xxx
height = xxx
im = gtk.Image()
pixbuf = gtk.gdk.pixbuf_new_from_file("my.jpg") # Your image file
scaled_buf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)
im.set_from_pixbuf(scaled_buf)
im.show()
For more informations about the last argument of scale_simple
, see interp_type.
有关scale_simple的最后一个参数的更多信息,请参阅interp_type。
Reference : PyGTK FAQ
参考:PyGTK FAQ