【发布时间】:2021-12-20 06:47:19
【问题描述】:
这是我的代码。
from PIL import Image
imgwidth = 800
img = Image.open('img/2.jpeg')
concat = (imgwidth/img.size[0])
height = float(img.size[1])*float(concat)
img = img.resize((imgwidth,height), Image.ANTIALIAS)
img.save('output.jpg')
我从博客中找到了这个例子。我已经运行了这段代码并得到了以下错误,我是 python 新手,不了解实际问题。
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PIL/Image.py", line 1929, in resize
return self._new(self.im.resize(size, resample, box))
TypeError: integer argument expected, got float
【问题讨论】:
-
试试
height = int(...)而不是height = float(...) -
谢谢.. 我明白这个问题。类型转换有问题。
标签: python python-3.x image-processing python-imaging-library