尝试利用Python3将剪贴板内的多张图片拼接成一张图片并保存至当前路径

以前用C语言写过一个类似的,现在想尝试利用Python3将剪贴板内复制的任意张jpg格式的图片拼接成一张图片,图片做成2列的模式,并保存至程序当前所在路径,有提供代码的最好了,谢谢!

讨论数量: 1
Jason990420

You can use PIL library for it, pseudo code here.

from PIL import Image

# Create new image to combine all images
im = Image.new(mode, size, color)

for file in files:
    # Open file as image
    image = Image.open(file)
    # Convert image to same format
    new_image = image.convert(mode=None, matrix=None, dither=None, palette=0, colors=256)
    # paste to same image with different poistion
    im.paste(new_image, box=None, mask=None)

# Save image to file
im.save(path, format=None, **params)
1周前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!