def image_size(source):
"""
Return the width and size of the specified image.
:param source: source image file, in any format that gtk recongizes
:type source: unicode
:rtype: tuple(int, int)
:returns: a tuple consisting of the width and height
"""
from gi.repository import GdkPixbuf
from gi.repository import GObject
try:
img = GdkPixbuf.Pixbuf.new_from_file(source)
width = img.get_width()
height = img.get_height()
except GObject.GError:
width = 0
height = 0
return (width, height)
#-------------------------------------------------------------------------
#
# image_actual_size
#
#-------------------------------------------------------------------------
评论列表
文章目录