枕头调整大小图像不起作用 - 模块没有属性 "resize"
Pillow resize image not working - module has no attribute "resize"
我正在尝试使用 Pillow 导入 2 张图像并调整其中一张的大小以适合另一张。当我使用 Image.resize
时出现错误
AttributeError: module 'PIL.Image' has no attribute 'resize'
这是我的代码:我做错了什么?
from PIL import Image
background = Image.open("/Users/user1/Downloads/2016-10-12.jpg")
foreground = Image.open("/Users/user1/Desktop/nadir.png")
bgSize = background.size
print(bgSize)
foreground = Image.resize((background.size), resample=0)
Image.alpha_composite(foreground, background)
resize()
方法是实例方法而不是 class 方法。代码应该是
background.resize()
而不是 Image.resize(background.size), resample=0)
我正在尝试使用 Pillow 导入 2 张图像并调整其中一张的大小以适合另一张。当我使用 Image.resize
时出现错误
AttributeError: module 'PIL.Image' has no attribute 'resize'
这是我的代码:我做错了什么?
from PIL import Image
background = Image.open("/Users/user1/Downloads/2016-10-12.jpg")
foreground = Image.open("/Users/user1/Desktop/nadir.png")
bgSize = background.size
print(bgSize)
foreground = Image.resize((background.size), resample=0)
Image.alpha_composite(foreground, background)
resize()
方法是实例方法而不是 class 方法。代码应该是
background.resize()
而不是 Image.resize(background.size), resample=0)