在 Python 3.x 中运行粘贴脚本时,我不断收到此错误:TypeError: integer argument expected, got float
from PIL import Image
img=Image.open('C:\Mine.jpg','r')
img_w,img_h=img.size
background = Image.new('RGBA', (1440,900), (255, 255, 255, 255))
bg_w,bg_h=background.size
offset=((bg_w-img_w)/2,(bg_h-img_h)/2)
background.paste(img,offset)
background.save('C:\new.jpg')
错误信息:
Traceback (most recent call last):
File "C:\Users\*****\workspace\Canvas Imager\src\Imager.py", line 7, in <module>
background.paste(img,offset)
File "C:\Python33\lib\site-packages\PIL\Image.py", line 1127, in paste
self.im.paste(im, box)
TypeError: integer argument expected, got float
我看到假设有一个整数,但最终得到一个浮点数。我该怎么做才能使它成为 int 呢?