rambo 1 месяц назад
Родитель
Сommit
4e11f8e0e8

+ 2 - 0
python/detail_template_test_xinnuo.json

@@ -7,6 +7,8 @@
                 "文件夹名称": "AC51016112",
                 "编号": "AC51016112",
                 "颜色名称": "枪色",
+                "模特图": "C:/Development/project/output/2025-12-05/详情图-测试/模特图.jpg",
+                "场景图": "C:/Development/project/output/2025-12-05/详情图-测试/场景图.jpg",
                 "pics": {
                     "俯视-抠图": "C:/Users/15001/Desktop/2025-06-11/A333/阴影图处理/A333(1)_俯视_抠图.png",
                     "俯视-阴影": "C:/Users/15001/Desktop/2025-06-11/A333/阴影图处理/A333(1)_俯视_阴影.png",

+ 5 - 2
python/service/customer_template_service.py

@@ -58,9 +58,12 @@ class CustomerTemplateService:
                 case _:
                     pillowImage = self.save_base64_image(dataUrl,save_name)
                     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("模板生成成功")
     
-    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
             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)
             total_height += new_height
 

+ 4 - 7
python/temp.py

@@ -14,10 +14,7 @@ from service.online_request.module_online_data import OnlineDataRequest,AIGCData
 
 from service.customer_template_service import CustomerTemplateService
 
-# service = CustomerTemplateService()
-# config_data = json.load(open("detail_template_test_xinnuo.json", mode="r", encoding="utf-8"))
-# canvas_json = json.load(open("canvas_json.json", mode="r", encoding="utf-8"))
-# service.generateTemplate(config_data,canvas_json,'test-template',r"C:/Development/project/output/2025-12-05/详情图-测试")
-pilImage = Image.open("C:/Users/15001/Documents/xwechat_files/lyb383409060_36ab/msg/file/2025-12/2025-12-16/123/原始图_已抠图/123(1).png")
-# pilImage = pilImage.convert("RGB")
-pilImage.save("test_image.png",format="PNG",dpi=(350,350))
+service = CustomerTemplateService()
+config_data = json.load(open("detail_template_test_xinnuo.json", mode="r", encoding="utf-8"))
+canvas_json = json.load(open("canvas_json.json", mode="r", encoding="utf-8"))
+service.generateTemplate(config_data,canvas_json,'test-template',r"C:/Development/project/output/2025-12-05/详情图-测试")