python 怎么通过 PIL 获得图片尺寸
先贴一下我的代码fromPILimportImagepic_path='logo_white_ee663702.png'im=Image.open(pic_path)(x...
先贴一下我的代码
from PIL import Image
pic_path = 'logo_white_ee663702.png'
im = Image.open(pic_path)
(x, y) = im.size()
print "size: ", x, y
然后报错了 TypeError: 'tuple' object is not callable
请问下怎么才能获得尺寸呢 谢谢~ 展开
from PIL import Image
pic_path = 'logo_white_ee663702.png'
im = Image.open(pic_path)
(x, y) = im.size()
print "size: ", x, y
然后报错了 TypeError: 'tuple' object is not callable
请问下怎么才能获得尺寸呢 谢谢~ 展开
1个回答
展开全部
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询