python图片排列 横向和纵向同时

import PIL.Image as Image
import os


toImage = Image.new('RGB', (640 * 3, 480 * 3))  # 构造图片的宽和高,如果图片不能填充完全会
dir_root = "C:/Users/JIA/Desktop/PG2019论文素材/柱状图"
files = os.listdir(dir_root)
count = 0
begin_x = 0
begin_y = 0
for file_name in files:
    fname = os.path.join(dir_root, file_name)
    fromImage = Image.open(fname)
    # fromImage = fromImage.resize((850, 1100))
    toImage.paste(fromImage, (begin_x, begin_y))
    begin_x += 640
    if begin_x % 1920 == 0:
        begin_x = 0
        begin_y += 480

toImage.save('eee.jpg')
发布了141 篇原创文章 · 获赞 54 · 访问量 15万+

猜你喜欢

转载自blog.csdn.net/iamjingong/article/details/91490190
今日推荐