|
@@ -58,9 +58,12 @@ class CustomerTemplateService:
|
|
|
case _:
|
|
case _:
|
|
|
pillowImage = self.save_base64_image(dataUrl,save_name)
|
|
pillowImage = self.save_base64_image(dataUrl,save_name)
|
|
|
concat_images_array.append(pillowImage)
|
|
concat_images_array.append(pillowImage)
|
|
|
|
|
+ long_image = self.concat_images_vertically(concat_images_array)
|
|
|
|
|
+ save_name = f"{save_path}/详情页-{template_name}.jpg"
|
|
|
|
|
+ long_image.save(save_name,format="JPEG")
|
|
|
print("模板生成成功")
|
|
print("模板生成成功")
|
|
|
|
|
|
|
|
- def concat_images_vertically(image_array, custom_width=None):
|
|
|
|
|
|
|
+ def concat_images_vertically(self,image_array, custom_width=None):
|
|
|
"""
|
|
"""
|
|
|
按照顺序将图片数组拼接成长图,并统一图片宽度
|
|
按照顺序将图片数组拼接成长图,并统一图片宽度
|
|
|
|
|
|
|
@@ -84,7 +87,7 @@ class CustomerTemplateService:
|
|
|
# 调整图片宽度并保持宽高比
|
|
# 调整图片宽度并保持宽高比
|
|
|
width_ratio = base_width / img.width
|
|
width_ratio = base_width / img.width
|
|
|
new_height = int(img.height * width_ratio)
|
|
new_height = int(img.height * width_ratio)
|
|
|
- resized_img = img.resize((base_width, new_height), Image.ANTIALIAS)
|
|
|
|
|
|
|
+ resized_img = img.resize((base_width, new_height), Image.Resampling.LANCZOS)
|
|
|
resized_images.append(resized_img)
|
|
resized_images.append(resized_img)
|
|
|
total_height += new_height
|
|
total_height += new_height
|
|
|
|
|
|