from PIL import Image
pic_path = 'logo_white_ee663702.png'
im = Image.open(pic_path)
# 这样就可以了
x, y = im.size
print "size: ", x, y
以下为 PIL Image.py 源码
class Image:
format = None
format_description = None
def __init__(self):
# FIXME: take "new" parameters / other image?
# FIXME: turn mode and size into delegating properties?
self.im = None
self.mode = ""
self.size = (0, 0)
self.palette = None
self.info = {}
self.category = NORMAL
self.readonly = 0
# 可以看到,初始化时有属性 size