|
@@ -2,7 +2,7 @@ import os
|
|
|
|
|
|
import PIL.Image as Image
|
|
import PIL.Image as Image
|
|
from PIL import ImageDraw
|
|
from PIL import ImageDraw
|
|
-
|
|
|
|
|
|
+import logging
|
|
|
|
|
|
def resize_by_width(infile, image_size):
|
|
def resize_by_width(infile, image_size):
|
|
"""按照宽度进行所需比例缩放"""
|
|
"""按照宽度进行所需比例缩放"""
|
|
@@ -40,12 +40,15 @@ def get_new_img_xy(infile, image_size):
|
|
|
|
|
|
# 定义图像拼接函数
|
|
# 定义图像拼接函数
|
|
def image_compose(image_colnum, image_size, image_rownum, image_names, image_save_path, x_new, y_new):
|
|
def image_compose(image_colnum, image_size, image_rownum, image_names, image_save_path, x_new, y_new):
|
|
|
|
+ logger = logging.getLogger('info')
|
|
|
|
+ logger.info('into---image_compose')
|
|
to_image = Image.new('RGB', (image_colnum * x_new, image_rownum * y_new)) # 创建一个新图
|
|
to_image = Image.new('RGB', (image_colnum * x_new, image_rownum * y_new)) # 创建一个新图
|
|
# 循环遍历,把每张图片按顺序粘贴到对应位置上
|
|
# 循环遍历,把每张图片按顺序粘贴到对应位置上
|
|
total_num = 0
|
|
total_num = 0
|
|
for y in range(1, image_rownum + 1):
|
|
for y in range(1, image_rownum + 1):
|
|
for x in range(1, image_colnum + 1):
|
|
for x in range(1, image_colnum + 1):
|
|
from_image = resize_by_width(image_names[image_colnum * (y - 1) + x - 1], image_size)
|
|
from_image = resize_by_width(image_names[image_colnum * (y - 1) + x - 1], image_size)
|
|
|
|
+ logger.info(image_names[image_colnum * (y - 1) + x - 1])
|
|
# from_image = Image.open(image_names[image_colnum * (y - 1) + x - 1]).resize((image_size,image_size ), Image.ANTIALIAS)
|
|
# from_image = Image.open(image_names[image_colnum * (y - 1) + x - 1]).resize((image_size,image_size ), Image.ANTIALIAS)
|
|
to_image.paste(from_image, ((x - 1) * x_new, (y - 1) * y_new))
|
|
to_image.paste(from_image, ((x - 1) * x_new, (y - 1) * y_new))
|
|
total_num += 1
|
|
total_num += 1
|
|
@@ -68,8 +71,12 @@ def get_image_list_fullpath(dir_path):
|
|
|
|
|
|
|
|
|
|
def merge_images(image_dir_path,image_size,image_colnum):
|
|
def merge_images(image_dir_path,image_size,image_colnum):
|
|
|
|
+ logger = logging.getLogger('info')
|
|
# 获取图片集地址下的所有图片名称
|
|
# 获取图片集地址下的所有图片名称
|
|
image_fullpath_list = get_image_list_fullpath(image_dir_path)
|
|
image_fullpath_list = get_image_list_fullpath(image_dir_path)
|
|
|
|
+ logger.info('-----------into merge_images check image_fullpath_list')
|
|
|
|
+ logger.info(image_fullpath_list)
|
|
|
|
+ # exit(image_fullpath_list)
|
|
print("image_fullpath_list", len(image_fullpath_list), image_fullpath_list)
|
|
print("image_fullpath_list", len(image_fullpath_list), image_fullpath_list)
|
|
|
|
|
|
image_save_path = r'{}.jpg'.format(image_dir_path) # 图片转换后的地址
|
|
image_save_path = r'{}.jpg'.format(image_dir_path) # 图片转换后的地址
|