一、将原图粘贴到一张正方形的背景上
def trans_square(image):
rOpen the image using PIL.
image = image.convert('RGB')
w, h = image.size
background = Image.new('RGB', size=(max(w, h), max(w, h)), color=(127, 127, 127)) # 创建背景图,颜色值为127
length = int(abs(w - h) // 2) # 一侧需要填充的长度
box = (length, 0) if w <