【发布时间】:2021-03-16 03:03:52
【问题描述】:
我试图从一个包含 9 个 RGB 图像的图像列表中创建一个拼贴画。我收到 ValueError:无法确定区域大小;使用 4 件箱。 下面是功能。我做错了什么?
def create_collage(width, height, imageList):
cols = 3
rows = 3
thumbnail_width = width//cols
thumbnail_height = height//rows
size = thumbnail_width, thumbnail_height
new_im = Image.new('RGB', (width, height))
ims = []
for image in imageList:
th = image.thumbnail(size)
ims.append(th)
i = 0
x = 0
y = 0
for col in range(cols):
for row in range(rows):
print(i, x, y)
new_im.paste(ims[i], (x, y))
i += 1
y += thumbnail_height
x += thumbnail_width
y = 0
new_im.save("Collage.png")
【问题讨论】:
标签: image image-processing python-imaging-library