只能将元组(不是 "int")连接到元组

can only concateanate tuple (not "int") to tuple

有人可以为我修复此代码吗?这是用较小的图像填充正方形的基本代码。

import random
import uuid
from PIL import Image

run_id = uuid.uuid1()

print(f'Processing run_id: {run_id}')

img1 = Image.open('1.png')

bg = Image.new('RGB', (1600, 1600))

rectangle_width = 160
rectangle_height = 160

for i in range(10):
    for j in range(10):
        rectangle_x = i*160
        rectangle_y = j*160
    
        bg.paste(img1, [
            (rectangle_x, rectangle_y),
            (rectangle_x + rectangle_width, rectangle_y + rectangle_height)], img1) 

bg.show() 

我收到一个错误

File "c:\Users\manis\Desktop\Pixel Ores\sample 4.py", line 16, in <module>
bg.paste(img1, [
File "C:\Users\manis\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\Image.py", 
line 1563, in paste
box += (box[0] + size[0], box[1] + size[1])
TypeError: can only concatenate tuple (not "int") to tuple

................................................ ..................................................... ...

要将图像粘贴到的框必须是 4 元组,而不是 2 个 2 元组的列表:

bg.paste(
    img1,
    (rectangle_x, rectangle_y, rectangle_x + rectangle_width, rectangle_y + rectangle_height),
    img1
)

根据 documentation:

The box argument is either a 2-tuple giving the upper left corner, a 4-tuple defining the left, upper, right, and lower pixel coordinate, or None (same as (0, 0)).