Selaa lähdekoodia

Merge branch 'dev-python'

rambo 9 kuukautta sitten
vanhempi
commit
3105c3a188
32 muutettua tiedostoa jossa 6527 lisäystä ja 1 poistoa
  1. 1 1
      python/.gitignore
  2. 0 0
      python/custom_plugins/__init__.py
  3. 0 0
      python/custom_plugins/plugins/__init__.py
  4. 0 0
      python/custom_plugins/plugins/detail_template/__init__.py
  5. 0 0
      python/custom_plugins/plugins/detail_template/hongqingting/__init__.py
  6. 198 0
      python/custom_plugins/plugins/detail_template/hongqingting/detail_hongqingting1.py
  7. 0 0
      python/custom_plugins/plugins/detail_template/huilima/__init__.py
  8. 245 0
      python/custom_plugins/plugins/detail_template/huilima/detail_huilima1.py
  9. 262 0
      python/custom_plugins/plugins/detail_template/huilima/detail_huilima2.py
  10. 357 0
      python/custom_plugins/plugins/detail_template/huilima/detail_huilima3.py
  11. 304 0
      python/custom_plugins/plugins/detail_template/huilima/detail_huilima4.py
  12. 0 0
      python/custom_plugins/plugins/detail_template/xiaosushuoxie/__init__.py
  13. 337 0
      python/custom_plugins/plugins/detail_template/xiaosushuoxie/detail_xiaosushuoxie1.py
  14. 626 0
      python/custom_plugins/plugins/detail_template/xiaosushuoxie/detail_xiaosushuoxie2.py
  15. 482 0
      python/custom_plugins/plugins/detail_template/xiaosushuoxie/detail_xiaosushuoxie3.py
  16. 459 0
      python/custom_plugins/plugins/detail_template/xiaosushuoxie/detail_xiaosushuoxie4.py
  17. 603 0
      python/custom_plugins/plugins/detail_template/xiaosushuoxie/detail_xiaosushuoxie5.py
  18. 576 0
      python/custom_plugins/plugins/detail_template/xiaosushuoxie/detail_xiaosushuoxie6.py
  19. 0 0
      python/custom_plugins/plugins/generate_and_upload/__init__.py
  20. 151 0
      python/custom_plugins/plugins/generate_and_upload/main_run.py
  21. 0 0
      python/custom_plugins/plugins/micropython_update/__init__.py
  22. 418 0
      python/custom_plugins/plugins/micropython_update/ampy_plugin.py
  23. 0 0
      python/custom_plugins/plugins/micropython_update/other_micropython_code/__init__.py
  24. 23 0
      python/custom_plugins/plugins/micropython_update/other_micropython_code/create_all_folders.py
  25. 50 0
      python/custom_plugins/plugins/micropython_update/other_micropython_code/delete_all_temp.py
  26. 56 0
      python/custom_plugins/plugins/micropython_update/other_micropython_code/get_remote_has256.py
  27. 24 0
      python/custom_plugins/plugins/micropython_update/other_micropython_code/restart.py
  28. 101 0
      python/custom_plugins/plugins/micropython_update/other_micropython_code/update_from_temp.py
  29. 0 0
      python/custom_plugins/plugins_mode/__init__.py
  30. 638 0
      python/custom_plugins/plugins_mode/detail_generate_base.py
  31. 593 0
      python/custom_plugins/plugins_mode/pic_deal.py
  32. 23 0
      python/custom_plugins/plugins_mode/plugins_base_func.py

+ 1 - 1
python/.gitignore

@@ -3,7 +3,7 @@ venv/
 *.log
 *.log.*
 resources/
-custom_plugins/
+# custom_plugins/
 *.db
 *.pdf
 output/*

+ 0 - 0
python/custom_plugins/__init__.py


+ 0 - 0
python/custom_plugins/plugins/__init__.py


+ 0 - 0
python/custom_plugins/plugins/detail_template/__init__.py


+ 0 - 0
python/custom_plugins/plugins/detail_template/hongqingting/__init__.py


+ 198 - 0
python/custom_plugins/plugins/detail_template/hongqingting/detail_hongqingting1.py

@@ -0,0 +1,198 @@
+"""
+步骤:
+1、整理需要处理的款号图-输出款号图文件夹
+2、整理所有相关的图片作为素材图
+3、按要求进行拼接
+"""
+import os
+from PIL import ImageFont
+import sys
+import settings
+
+# from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
+# from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
+is_test_plugins = False
+try:
+    is_test_plugins = settings.is_test_plugins
+except:
+    is_test_plugins = False
+
+if is_test_plugins:
+    from custom_plugins.plugins_mode.detail_generate_base import DetailBase
+    from custom_plugins.plugins_mode.pic_deal import PictureProcessing
+else:
+    from plugins_mode.detail_generate_base import DetailBase
+    from plugins_mode.pic_deal import PictureProcessing
+
+plugins_name = "详情模板"
+company_name_list = ["红蜻蜓",]
+template_name = "hongqingt-1"
+
+
+class DetailPicGet(DetailBase):
+    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
+    root = r"{}\resources\detail_temp\hongqingting\1".format(os.getcwd())
+
+    def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False, excel_data=None,
+                 assigned_page_list=None):
+
+        super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows, excel_data=excel_data,
+                         assigned_page_list=assigned_page_list)
+        self.template_name = template_name
+        self.root = r"{}\resources\detail_temp\hongqingting\1".format(os.getcwd())
+        print("run hongqingt-1 ")
+        self.base_bg_color = (228, 196, 147)
+        bg_color = (246, 246, 246)
+        self.image_init(bg_color)
+
+        self.deal_pic_func_list = [
+            self.deal_pic_1,
+            self.deal_pic_2,
+            self.deal_pic_3,
+            self.deal_pic_4,
+            self.deal_pic_5,
+        ]
+        self.run_all()
+
+    def deal_pic_1(self):
+        bg_color = (246, 246, 246)
+        """   制作主图  """
+        goods_art_no_list = list(self.data.keys())
+
+        pp_1 = self.data[goods_art_no_list[0]]["pic_is_deal"]["侧视"]
+        pp_image = pp_1.resize(mode="relative",
+                               base="by_im",
+                               value=0,
+                               base_im=PictureProcessing("RGB", (550, 340), (248, 248, 248)),
+                               percentage=0)
+
+        pp_image = PictureProcessing("RGB", (550, 340), bg_color).paste_img(
+            mode="pixel", top_img=pp_image, base="center"
+        )
+
+        bg_img = PictureProcessing(r"{}\image (1).jpg".format(self.root)).paste_img(
+            mode="pixel", top_img=pp_image, base="nw", value=(26, 263))
+        # bg_img.show()
+
+        #   ---------- 第二张图粘贴
+        pp_2 = self.data[goods_art_no_list[0]]["pic_is_deal"]["俯视"]
+        pp_image = pp_2.resize(mode="relative",
+                               base="by_im",
+                               value=0,
+                               base_im=PictureProcessing("RGB", (550, 340), (248, 248, 248)),
+                               percentage=0)
+        pp_image = PictureProcessing("RGB", (550, 340), bg_color).paste_img(
+            mode="pixel", top_img=pp_image, base="center"
+        )
+        bg_img = bg_img.paste_img(
+            mode="pixel", top_img=pp_image, base="nw", value=(26, 626))
+
+        # -------粘贴文字-------
+        font = ImageFont.truetype(r'resources\ttf\simhei.ttf', 30)
+        text_list = [("商品款号", self.goods_no_value["款号"], 700, 297),
+                     ("商品面料", self.goods_no_value["商品面料"], 700, 380),
+                     ("商品内里", self.goods_no_value["商品内里"], 700, 469),
+                     ("商品鞋底", self.goods_no_value["商品鞋底"], 700, 549),
+                     ("后帮高", self.goods_no_value["后帮高"], 700, 667),
+                     ("前掌宽", self.goods_no_value["前掌宽"], 700, 751),
+                     ("鞋跟高", self.goods_no_value["鞋跟高"], 700, 828), ]
+        for i in text_list:
+            bg_img = bg_img.add_text(mode="pixel",
+                                     value=(i[2], i[3]),
+                                     font=font,
+                                     text="{}:{}".format(i[0], i[1]),
+                                     align="center",
+                                     spacing=10,
+                                     fill=(17, 16, 16))
+        return bg_img
+
+    def deal_pic_2(self):
+        # 设计师说展示图
+        # 设计师说
+        if "FAB说明" not in self.goods_no_value:
+            return
+        text = self.goods_no_value["FAB说明"]  # FAB说明
+        if not text:
+            return
+        pp_1 = PictureProcessing(r"{}\image (2).jpg".format(self.root))
+
+        text = text.replace(r"\n", "\n")
+        _ = text.split("\n")
+        text_img = PictureProcessing("RGB", (1200, len(_) * 100 + 30), (255, 255, 255))
+        font = ImageFont.truetype(r'resources\ttf\simhei.ttf', 30)
+
+        text_img = text_img.add_text(mode="pixel",
+                                     value=(600, 50),
+                                     font=font,
+                                     text=text,
+                                     anchor="ma",
+                                     align="center",
+                                     spacing=50,
+                                     fill=(83, 83, 83))
+        new_image = PictureProcessing("RGB", (1200, pp_1.height + text_img.height), (255, 255, 255))
+        new_image = new_image.paste_img(mode="pixel", top_img=pp_1, value=(0, 0))
+        new_image = new_image.paste_img(mode="pixel", top_img=text_img, value=(0, pp_1.height))
+        return new_image
+
+    def deal_pic_3(self):
+        # 制作角度展示图
+        bg_color = (246, 246, 246)
+        detailed_images = []
+        pp_1 = PictureProcessing(r"{}\image (3).jpg".format(self.root))
+        detailed_images.append(pp_1)
+        goods_art_no_list = list(self.data.keys())
+        for index, goods_art_no in enumerate(goods_art_no_list):
+            if index == 0:
+                name_list = ["侧视", "俯视", "后跟", "鞋底"]
+            else:
+                name_list = ["侧视", "俯视", ]
+
+            for _name in name_list:
+                # 处理图片,需要粘贴到背景等处理
+                if _name not in self.data[goods_art_no]["pic_is_deal"]:
+                    continue
+
+                _pp = self.data[goods_art_no]["pic_is_deal"][_name]
+                _pp = _pp.resize(mode="pixel", base="width", value=649 if _name == "后跟" else 1058, )
+                bg_img = PictureProcessing("RGBA", (1200, int(_pp.height + 50)), bg_color)
+                bg_img = bg_img.paste_img(mode="pixel", top_img=_pp, base="center")
+
+                detailed_images.append(bg_img)
+                # 添加分割线
+                detailed_images.append(PictureProcessing("RGB", (1200, 50), (255, 255, 255)))
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_4(self):
+        # 制作详细图
+        bg_color = (246, 246, 246)
+        detailed_images = []
+        pp_1 = PictureProcessing(r"{}\image (4).jpg".format(self.root))
+        detailed_images.append(pp_1)
+        name_list = ["俯视", "内里", "后跟", "鞋底"]
+        goods_art_no = list(self.data.keys())[0]
+
+        view_dict = {"俯视": (0, 0, 1100, 1200),
+                     "内里": (-1, -100, 1100, 1200),
+                     "后跟": (0, -100, 1100, 1200),
+                     "鞋底": (0, -100, 1100, 1200),
+                     }
+
+        for _name in name_list:
+            # 处理图片,需要粘贴到背景等处理
+            if _name not in self.data[goods_art_no]["pic_is_deal"]:
+                continue
+            _pp = self.data[goods_art_no]["pic_is_deal"][_name]
+            _pp = _pp.resize(mode="pixel", base="width", value=1300 if _name == "后跟" else 2200, )
+            _pp = _pp.crop_img(mode="pixel", base="sw", value=view_dict[_name], color_fill=bg_color)
+            _pp = _pp.radius(mode="relative", circular_pos=(1, 0, 0, 1), value=100)
+            bg_pp = PictureProcessing("RGB", (1200, 1316), (255, 255, 255))
+            bg_pp.paste_img(mode="pixel", top_img=_pp, base="ec", value=(0, 0))
+            detailed_images.append(bg_pp)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_5(self):
+        # 其他图片添加
+        pp_1 = PictureProcessing(r"{}\image (5).jpg".format(self.root))
+        return pp_1

+ 0 - 0
python/custom_plugins/plugins/detail_template/huilima/__init__.py


+ 245 - 0
python/custom_plugins/plugins/detail_template/huilima/detail_huilima1.py

@@ -0,0 +1,245 @@
+"""
+步骤:
+1、整理需要处理的款号图-输出款号图文件夹
+2、整理所有相关的图片作为素材图
+3、按要求进行拼接
+"""
+import os
+from PIL import ImageFont
+import sys
+import settings
+
+# from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
+# from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
+is_test_plugins = False
+try:
+    is_test_plugins = settings.is_test_plugins
+except:
+    is_test_plugins = False
+
+if is_test_plugins:
+    from custom_plugins.plugins_mode.detail_generate_base import DetailBase
+    from custom_plugins.plugins_mode.pic_deal import PictureProcessing
+else:
+    from plugins_mode.detail_generate_base import DetailBase
+    from plugins_mode.pic_deal import PictureProcessing
+
+plugins_name = "详情模板"
+company_name_list = ["惠利玛", ]
+template_name = "huilima-1"
+
+
+class A(object):
+    def __init__(self):
+        print("AAAAAAAAAAAAAAAA")
+
+
+class DetailPicGet(DetailBase):
+    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
+    root = r"{}\resources\detail_temp\huilima\1".format(os.getcwd())
+    a = A()
+
+    def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False, excel_data=None,
+                 assigned_page_list=None, **kwargs):
+
+        super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows, excel_data=excel_data,
+                         assigned_page_list=assigned_page_list)
+
+        self.template_name = template_name
+        self.root = r"{}\resources\detail_temp\huilima\1".format(os.getcwd())
+        print("run huilima-1 ")
+        self.base_bg_color = (228, 196, 147)
+        self.deal_pic_func_list = [
+            self.deal_pic_1,
+            self.deal_pic_2,
+            self.deal_pic_3,
+            self.deal_pic_4,
+            self.deal_pic_5,
+        ]
+        bg_color = (246, 246, 246)
+        self.image_init(bg_color)
+        if test:
+            self.run_test()
+        else:
+            self.run_all()
+
+    def run_test(self):
+        detailed_images = []
+        detailed_images.append(self.deal_pic_1())
+        detailed_images.append(self.deal_pic_2())
+        detailed_images.append(self.deal_pic_3())
+        detailed_images.append(self.deal_pic_4())
+        detailed_images.append(self.deal_pic_5())
+        img = self.add_pic(detailed_images)
+        # img.save(r"{}/{}.jpg".format(self.out_put_dir, self.goods_no, format="JPEG"))
+        if img:
+            img.show()
+
+    def deal_pic_1(self):
+        bg_color = (246, 246, 246)
+        """   制作主图  """
+        detailed_images = []
+        pp_0 = PictureProcessing(r"{}\image (1).jpg".format(self.root))
+        detailed_images.append(pp_0)
+
+        goods_art_no_list = list(self.data.keys())
+
+        pp_1 = self.data[goods_art_no_list[0]]["pic_is_deal"]["俯视"]
+        pp_image = pp_1.resize(mode="relative",
+                               base="by_im",
+                               base_im=PictureProcessing("RGB", (604, 418), (248, 248, 248)))
+
+        pp_image = PictureProcessing("RGB", (604, 418), bg_color).paste_img(
+            mode="pixel", top_img=pp_image, base="center"
+        )
+
+        bg_img = PictureProcessing("RGB", (1200, 918), (255, 255, 255)).paste_img(
+            mode="pixel", top_img=pp_image, base="nw", value=(26, 26))
+
+        # bg_img.show()
+
+        #   ---------- 第二张图粘贴
+        pp_2 = self.data[goods_art_no_list[0]]["pic_is_deal"]["侧视"]
+        pp_image = pp_2.resize(mode="relative",
+                               base="by_im",
+                               base_im=PictureProcessing("RGB", (604, 418), (248, 248, 248)), )
+
+        pp_image = PictureProcessing("RGB", (604, 418), bg_color).paste_img(
+            mode="pixel", top_img=pp_image, base="center"
+        )
+
+        bg_img = bg_img.paste_img(
+            mode="pixel", top_img=pp_image, base="nw", value=(26, 26 + 26 + 418))
+
+        # -------粘贴文字-------
+        font = ImageFont.truetype(r'resources\ttf\simhei.ttf', 30)
+        text_list = [("商品款号", self.goods_no_value["款号"], 700, 297),
+                     ("商品面料", self.goods_no_value["商品面料"], 700, 380),
+                     ("商品内里", self.goods_no_value["商品内里"], 700, 469),
+                     ("商品鞋底", self.goods_no_value["商品鞋底"], 700, 549), ]
+
+        for i in text_list:
+            bg_img = bg_img.add_text(mode="pixel",
+                                     value=(i[2], i[3]),
+                                     font=font,
+                                     text="{}:{}".format(i[0], i[1]),
+                                     align="center",
+                                     spacing=10,
+                                     fill=(17, 16, 16))
+        detailed_images.append(bg_img)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_2(self):
+        # 尺码表
+        pp_1 = PictureProcessing(r"{}\image (2).jpg".format(self.root))
+        return pp_1
+
+    def deal_pic_3(self):
+        # 细节图展示
+        bg_color = (246, 246, 246)
+
+        detailed_images = []
+        goods_art_no_list = list(self.data.keys())
+        view_dict = {"俯视": {"crop_img_value": (-77, 401, 1086, 752),
+                            "crop_img_base": "sw",
+                            "paste_img_value": (0, 0),
+                            "paste_img_base": "center",
+                            },
+                     "侧视": {"crop_img_value": (0, 0, 1086, 752),
+                            "crop_img_base": "sw",
+                            "paste_img_value": (0, 0),
+                            "paste_img_base": "center",
+                            },
+                     }
+        for index, goods_art_no in enumerate(goods_art_no_list):
+            if index == 0:
+                name_list = ["俯视", "侧视", "鞋底", "内里"]
+            else:
+                name_list = ["俯视", "侧视", ]
+
+            # 第一个颜色
+            if "俯视" in name_list:
+                _pp = self.image_one_pic(goods_art_no, "俯视", bg_color=bg_color)
+                if _pp is None:
+                    continue
+
+                bg_img = PictureProcessing("RGBA", (1200, 848), (255, 255, 255))
+                _pp = (_pp.resize(value=1900)
+                       .crop_img(mode="pixel", base="sw", value=(-77, 0, 1086, 752), color_fill=bg_color)
+                       .radius(circular_pos=(1, 1, 1, 1), mode="relative", value=100)
+                       .paste_img_invert(mode="pixel", top_img=bg_img, base="center")
+                       )
+                detailed_images.append(_pp)
+
+            if "侧视" in name_list:
+                _pp = self.image_one_pic(goods_art_no, "侧视", bg_color=bg_color)
+                if _pp is None:
+                    continue
+
+                bg_img = PictureProcessing("RGBA", (1200, 848), (255, 255, 255))
+                _pp = (_pp.resize(value=1733)
+                       .crop_img(mode="pixel", base="wc", value=(715, 0, 1086, 752), color_fill=bg_color)
+                       .radius(circular_pos=(1, 1, 1, 1), mode="relative", value=100)
+                       .paste_img_invert(mode="pixel", top_img=bg_img, base="center")
+                       )
+                detailed_images.append(_pp)
+
+            if "鞋底" in name_list:
+                _pp = self.image_one_pic(goods_art_no, "鞋底", bg_color=bg_color)
+                if _pp is None:
+                    continue
+
+                bg_img = PictureProcessing("RGBA", (1200, 848), (255, 255, 255))
+                _pp = (_pp.resize(value=1733)
+                       .crop_img(mode="pixel", base="wc", value=(715, 0, 1086, 752), color_fill=bg_color)
+                       .radius(circular_pos=(1, 1, 1, 1), mode="relative", value=100)
+                       .paste_img_invert(mode="pixel", top_img=bg_img, base="center")
+                       )
+                detailed_images.append(_pp)
+
+            if "内里" in name_list:
+                _pp = self.image_one_pic(goods_art_no, "内里", bg_color=bg_color)
+                if _pp is None:
+                    continue
+
+                bg_img = PictureProcessing("RGBA", (1200, 848), (255, 255, 255))
+                _pp = (_pp.resize(value=1663)
+                       .crop_img(mode="pixel", base="wc", value=(-40, 0, 1086, 752), color_fill=bg_color)
+                       .radius(circular_pos=(1, 1, 1, 1), mode="relative", value=100)
+                       .paste_img_invert(mode="pixel", top_img=bg_img, base="center")
+                       )
+                detailed_images.append(_pp)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_4(self):
+        # 制作角度展示图
+        bg_color = (246, 246, 246)
+
+        detailed_images = []
+
+        goods_art_no_list = list(self.data.keys())
+        for index, goods_art_no in enumerate(goods_art_no_list):
+            if index == 0:
+                name_list = ["俯视", "侧视", "后跟", "鞋底"]
+            else:
+                name_list = ["俯视", ]
+
+            for _name in name_list:
+                # 处理图片,需要粘贴到背景等处理
+                if _name not in self.data[goods_art_no]["pic_is_deal"]:
+                    continue
+                _pp = self.data[goods_art_no]["pic_is_deal"][_name]
+                _pp = _pp.resize(mode="pixel", base="width", value=600 if _name == "后跟" else 1058, )
+
+                bg_pp = PictureProcessing("RGB", (1200, int(_pp.height + 50)), bg_color)
+                bg_pp = bg_pp.paste_img(mode="pixel", top_img=_pp, base="cc", value=(0, 0))
+                detailed_images.append(bg_pp)
+                # 分割线
+                _p = PictureProcessing("RGB", (1200, 50), (255, 255, 255))
+                detailed_images.append(_p)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_5(self):
+        return PictureProcessing(r"{}\image (3).jpg".format(self.root))

+ 262 - 0
python/custom_plugins/plugins/detail_template/huilima/detail_huilima2.py

@@ -0,0 +1,262 @@
+"""
+步骤:
+1、整理需要处理的款号图-输出款号图文件夹
+2、整理所有相关的图片作为素材图
+3、按要求进行拼接
+"""
+import os
+from PIL import ImageFont
+import sys
+import settings
+
+# from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
+# from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
+is_test_plugins = False
+try:
+    is_test_plugins = settings.is_test_plugins
+except:
+    is_test_plugins = False
+
+if is_test_plugins:
+    from custom_plugins.plugins_mode.detail_generate_base import DetailBase
+    from custom_plugins.plugins_mode.pic_deal import PictureProcessing
+else:
+    from plugins_mode.detail_generate_base import DetailBase
+    from plugins_mode.pic_deal import PictureProcessing
+
+plugins_name = "详情模板"
+company_name_list = ["全部"]
+template_name = "huilima-2"
+
+# 皮鞋模板
+
+class DetailPicGet(DetailBase):
+    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
+    root = r"{}\resources\detail_temp\huilima\2".format(os.getcwd())
+
+    def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False, excel_data=None,
+                 assigned_page_list=None, **kwargs):
+
+        super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows, excel_data=excel_data,
+                         assigned_page_list=assigned_page_list)
+
+        self.template_name = template_name
+        self.root = r"{}\resources\detail_temp\huilima\2".format(os.getcwd())
+        print("run huilima-2 ")
+        self.base_bg_color = (255, 255, 255)
+        self.deal_pic_func_list = [
+            self.deal_pic_1,
+            self.deal_pic_2,
+            self.deal_pic_3,
+            self.deal_pic_4,
+            self.deal_pic_5,
+            self.deal_pic_6,
+        ]
+        if test:
+            self.run_test()
+        else:
+            self.run_all()
+
+    def run_test(self):
+        detailed_images = []
+        detailed_images.append(self.deal_pic_1())
+        detailed_images.append(self.deal_pic_2())
+        detailed_images.append(self.deal_pic_3())
+        detailed_images.append(self.deal_pic_4())
+        detailed_images.append(self.deal_pic_5())
+        detailed_images.append(self.deal_pic_6())
+        img = self.add_pic(detailed_images)
+        if img:
+            self.create_folder(r"{}/{}".format(self.out_put_dir, template_name))
+            img.save(r"{}/{}/{}.jpg".format(self.out_put_dir, template_name, self.goods_no, format="JPEG"))
+            img.show()
+
+    # 斜视图展示
+    def deal_pic_1(self):
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\1.jpg".format(self.root))
+        detailed_images.append(pp_bg)
+        goods_art_no_list = list(self.data.keys())
+        # ----粘贴俯视图
+        pp_jpg = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
+                                                color_name="俯视",
+                                                bg_color=self.base_bg_color)
+        pp_jpg = pp_jpg.resize(value=1098)
+        pp_jpg = pp_jpg.paste_img_invert(
+            top_img=PictureProcessing("RGB", (1600, pp_jpg.height + 100), self.base_bg_color),
+            base="cc")
+        detailed_images.append(pp_jpg)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 展示设计理念
+    def deal_pic_2(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\3.jpg".format(self.root)))
+        detailed_images.append(PictureProcessing(r"{}\4.jpg".format(self.root)))
+        detailed_images.append(PictureProcessing(r"{}\5.jpg".format(self.root)))
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 角度展示
+    def deal_pic_3(self):
+        detailed_images = []
+        goods_art_no_list = list(self.data.keys())
+        # =====添加侧视图
+        pp_jpg = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
+                                                color_name="侧视",
+                                                bg_color=self.base_bg_color)
+        pp_jpg = pp_jpg.resize(value=1098)
+        pp_jpg = pp_jpg.paste_img_invert(
+            top_img=PictureProcessing("RGB", (1600, pp_jpg.height + 100), self.base_bg_color),
+            base="cc")
+        detailed_images.append(pp_jpg)
+
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Regular.ttf", 48)  # 颜色名称
+        # =====添加鞋面描述
+        pp_bg_2 = PictureProcessing(r"{}\7.jpg".format(self.root))
+        text = self.get_text_value("提示1主标题")
+        if text:
+            _pp = PictureProcessing().get_text_image_advanced(
+                font=font_1,
+                text=text,
+                fill=(122, 122, 122),
+                return_mode="min_image",
+            )
+            pp_bg_2 = pp_bg_2.paste_img(top_img=_pp, value=(143, 166), base="ne")
+        detailed_images.append(pp_bg_2)
+
+        pp_jpg = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
+                                                color_name="俯视",
+                                                bg_color=self.base_bg_color)
+        pp_jpg = pp_jpg.transpose(mode="left_right")
+        pp_jpg = pp_jpg.resize(value=2210)
+        pp_jpg = pp_jpg.paste_img_invert(
+            top_img=PictureProcessing("RGB", (1600, pp_jpg.height + 200), self.base_bg_color),
+            base="en",
+            value=(149, 0)
+        )
+        detailed_images.append(pp_jpg)
+        # =====添加内里图
+        pp_bg_3 = PictureProcessing(r"{}\8.jpg".format(self.root))
+        text = self.get_text_value("提示2主标题")
+        if text:
+            _pp = PictureProcessing().get_text_image_advanced(
+                font=font_1,
+                text=text,
+                fill=(122, 122, 122),
+                return_mode="min_image",
+            )
+            pp_bg_3 = pp_bg_3.paste_img(top_img=_pp, value=(143, 166), base="nw")
+        detailed_images.append(pp_bg_3)
+
+        pp_jpg = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
+                                                color_name="内里",
+                                                bg_color=self.base_bg_color)
+        pp_jpg = pp_jpg.resize(value=2130)
+        pp_jpg = pp_jpg.paste_img_invert(
+            top_img=PictureProcessing("RGB", (1600, pp_jpg.height + 100), self.base_bg_color),
+            base="wc",
+            value=(294, 0)
+        )
+        detailed_images.append(pp_jpg)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 展示产品信息和颜色图
+    def deal_pic_4(self):
+        detailed_images = []
+        goods_art_no_list = list(self.data.keys())
+        #  添加基础信息
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Regular.ttf", 46)  # 颜色名称
+        text_list = [
+            {"text": "产品名称", "pos": (294, 531)},
+            {"text": "产地", "pos": (1235, 531)},
+            {"text": "鞋面材质", "pos": (429, 623)},
+            {"text": "鞋底材质", "pos": (1235, 623)},
+            {"text": "设计理念", "pos": (294, 721)},
+        ]
+        pp_bg_1 = PictureProcessing(r"{}\9.jpg".format(self.root))
+        for text_data in text_list:
+            text = self.get_text_value(text_data["text"])
+            if text:
+                _pp = PictureProcessing().get_text_image_advanced(
+                    font=font_1,
+                    text=text,
+                    fill=(136, 136, 136),
+                    return_mode="min_image",
+                )
+                pp_bg_1 = pp_bg_1.paste_img(top_img=_pp, value=text_data["pos"])
+
+        detailed_images.append(pp_bg_1)
+        # =======添加各个颜色====多余高度需要剪裁
+        pp_bg_2 = PictureProcessing(r"{}\8.jpg".format(self.root))
+
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 34)  # 颜色名称
+        color_pic_list_1 = []
+        for goods_art_no_dict in self.goods_no_value["货号资料"]:
+            color_name = goods_art_no_dict["颜色名称"]
+            goods_art_no = goods_art_no_dict["货号"]
+            pp_jpg = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no,
+                                                    color_name="侧视",
+                                                    bg_color=self.base_bg_color)
+            pp_jpg = pp_jpg.resize(value=390)
+
+            pp_jpg = pp_jpg.paste_img_invert(
+                top_img=PictureProcessing("RGBA", (pp_jpg.width, pp_jpg.height + 70), (255, 255, 255, 0)),
+                base="nw"
+            )
+            text_image = pp_bg_2.get_text_image_advanced(font=font_2,
+                                                         text="{} / COLOR".format(color_name),
+                                                         fill=(0, 0, 0),
+                                                         return_mode="min_image")
+
+            pp_jpg = pp_jpg.paste_img(top_img=text_image, base="sc", value=(0, 10))
+            color_pic_list_1.append(pp_jpg)
+
+        # 颜色列表进行等分展示
+        all_color_pp = PictureProcessing().horizontal_distribution(color_pic_list_1, bg_width=1114,
+                                                                   line_spacing=10,
+                                                                   number_per_row=2)
+
+        all_color_pp = all_color_pp.paste_img_invert(
+            top_img=PictureProcessing("RGB", (1600, all_color_pp.height + 100), self.base_bg_color),
+            base="cc",
+            value=(0, 0))
+        detailed_images.append(all_color_pp)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 产品细节展示
+    def deal_pic_5(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\12.jpg".format(self.root)))
+
+        goods_art_no_list = list(self.data.keys())
+        view_list = ["侧视", "俯视", "后跟"]
+
+        for goods_art_no_dict in self.goods_no_value["货号资料"]:
+            color_name = goods_art_no_dict["颜色名称"]
+            goods_art_no = goods_art_no_dict["货号"]
+            for index, view_name in enumerate(view_list):
+                pp_jpg = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no,
+                                                        color_name=view_name,
+                                                        bg_color=self.base_bg_color)
+                if view_name == "后跟":
+                    pp_jpg = pp_jpg.resize(value=600)
+                else:
+                    pp_jpg = pp_jpg.resize(value=1202)
+                pp_jpg = pp_jpg.paste_img_invert(
+                    top_img=PictureProcessing("RGB", (1600, pp_jpg.height + 100), self.base_bg_color),
+                    base="cc",
+                    value=(0, 0))
+                detailed_images.append(pp_jpg)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 添加注意事项
+    def deal_pic_6(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\15.jpg".format(self.root)))
+        detailed_images.append(PictureProcessing(r"{}\16.jpg".format(self.root)))
+        detailed_images.append(PictureProcessing(r"{}\17.jpg".format(self.root)))
+        detailed_images.append(PictureProcessing(r"{}\18.jpg".format(self.root)))
+        return PictureProcessing(im=self.add_pic(detailed_images))

+ 357 - 0
python/custom_plugins/plugins/detail_template/huilima/detail_huilima3.py

@@ -0,0 +1,357 @@
+"""
+步骤:
+1、整理需要处理的款号图-输出款号图文件夹
+2、整理所有相关的图片作为素材图
+3、按要求进行拼接
+"""
+import os
+from PIL import ImageFont
+import sys
+import settings
+
+# from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
+# from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
+is_test_plugins = False
+try:
+    is_test_plugins = settings.is_test_plugins
+except:
+    is_test_plugins = False
+
+if is_test_plugins:
+    from custom_plugins.plugins_mode.detail_generate_base import DetailBase
+    from custom_plugins.plugins_mode.pic_deal import PictureProcessing
+else:
+    from plugins_mode.detail_generate_base import DetailBase
+    from plugins_mode.pic_deal import PictureProcessing
+
+plugins_name = "详情模板"
+company_name_list = ["全部"]
+template_name = "huilima-3"
+
+
+# 运动鞋详情页
+
+class DetailPicGet(DetailBase):
+    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
+    root = r"{}\resources\detail_temp\huilima\3".format(os.getcwd())
+
+    def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False, excel_data=None,
+                 assigned_page_list=None, **kwargs):
+
+        super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows, excel_data=excel_data,
+                         assigned_page_list=assigned_page_list)
+
+        self.template_name = template_name
+        self.root = r"{}\resources\detail_temp\huilima\3".format(os.getcwd())
+        print("run huilima-3 ")
+        self.base_bg_color = (255, 255, 255)
+        self.deal_pic_func_list = [
+            self.deal_pic_1,
+            self.deal_pic_2,
+            self.deal_pic_3,
+            self.deal_pic_4,
+            self.deal_pic_5,
+        ]
+        if test:
+            self.run_test()
+        else:
+            self.run_all()
+
+    def run_test(self):
+        detailed_images = []
+        detailed_images.append(self.deal_pic_1())
+        detailed_images.append(self.deal_pic_2())
+        detailed_images.append(self.deal_pic_3())
+        detailed_images.append(self.deal_pic_4())
+        detailed_images.append(self.deal_pic_5())
+        img = self.add_pic(detailed_images)
+        if img:
+            self.create_folder(r"{}/{}".format(self.out_put_dir, template_name))
+            img.save(r"{}/{}/{}.jpg".format(self.out_put_dir, template_name, self.goods_no, format="JPEG"))
+            img.show()
+
+    # 使用动态拼接的方式进行实现
+    def deal_pic_1_other(self):
+        pp_bg = PictureProcessing(r"{}\2.jpg".format(self.root))
+        goods_art_no_list = list(self.data.keys())
+        # 粘贴多色图,步骤
+        # 创建一个白色底大画布,循环粘贴鞋子,先粘贴所有的阴影图,再粘贴透明图,记录最大边。
+        # 剪裁再粘贴到背景上
+
+        pp_jpg_1_list = []
+        pp_png_1_list = []
+        for goods_art_no_dict in self.goods_no_value["货号资料"]:
+            color_name = goods_art_no_dict["颜色名称"]
+            goods_art_no = goods_art_no_dict["货号"]
+            pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
+                                                    goods_art_no=goods_art_no,
+                                                    name="俯视",
+                                                    )
+            pp_jpg_1_list.append(pp_jpg_1)
+            pp_png_1_list.append(pp_png_1)
+
+        x, y = 0, 0
+        pp_bg_jpg = PictureProcessing("RGB", (1600, 1600), (255, 255, 255))
+        if len(pp_jpg_1_list) == 1:
+            _resize_value = 1100
+        else:
+            _resize_value = 900
+
+        for index, pp_jpg in enumerate(pp_jpg_1_list):
+            pp_jpg = pp_jpg.resize(value=_resize_value + 100 * index)
+            pp_bg_jpg = pp_bg_jpg.to_overlay_pic_advance(top_img=pp_jpg,
+                                                         value=(x, y))
+            x += 180
+            y += 60
+
+        x, y = 0, 0
+        pp_bg_png = PictureProcessing("RGBA", (1600, 1600), (255, 255, 255, 0))
+        for index, pp_png in enumerate(pp_png_1_list):
+            pp_png = pp_png.resize(value=_resize_value + 100 * index)
+            pp_bg_png = pp_bg_png.paste_img(top_img=pp_png,
+                                            value=(x, y))
+            x += 180
+            y += 60
+
+        min_bbox = pp_bg_png.getbbox()
+        min_bbox = PictureProcessing().expand_bbox(min_bbox)
+        pp_bg_jpg = pp_bg_jpg.crop(bbox=min_bbox)
+        pp_bg_png = pp_bg_png.crop(bbox=min_bbox)
+
+        pp_bg = pp_bg.to_overlay_pic_advance(top_img=pp_bg_jpg, top_png_img=pp_bg_png, base="cc")
+        return pp_bg
+
+    # 斜视图展示  多色进行拼接
+    def deal_pic_1(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\1.jpg".format(self.root)))
+        goods_art_no_list = list(self.data.keys())
+        # 粘贴多色图,步骤
+        # 创建一个白色底大画布,循环粘贴鞋子,先粘贴所有的阴影图,再粘贴透明图,记录最大边。
+        # 剪裁再粘贴到背景上
+        pp_jpg, pp_png = self.image_one_pic(return_orign=True,
+                                            goods_art_no=goods_art_no_list[0],
+                                            name="组合",
+                                            )
+        if pp_jpg:
+            pp_bg = PictureProcessing(r"{}\2.jpg".format(self.root))
+            pp_jpg = pp_jpg.resize(value=1312)
+            pp_png = pp_png.resize(value=1312)
+            pp_bg = pp_bg.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="cc")
+        else:
+            pp_bg = self.deal_pic_1_other()
+
+        detailed_images.append(pp_bg)
+        pp_bg_2 = PictureProcessing(r"{}\3.jpg".format(self.root))
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Regular.ttf", 60)  # 颜色名称
+        text = self.get_text_value("标题")
+        if text:
+            _pp = PictureProcessing().get_text_image_advanced(
+                font=font_1,
+                text=text,
+                fill=(255, 255, 255),
+                return_mode="min_image",
+            )
+            pp_bg_2 = pp_bg_2.paste_img(top_img=_pp, value=(0, 362), base="nc")
+        detailed_images.append(pp_bg_2)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 展示基础信息
+    def deal_pic_2(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\4.jpg".format(self.root)))
+        pp_bg_1 = PictureProcessing(r"{}\5.jpg".format(self.root))
+        # 粘贴侧视图
+        goods_art_no_list = list(self.data.keys())
+        pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
+                                                goods_art_no=goods_art_no_list[0],
+                                                name="侧视",
+                                                )
+        pp_jpg_1 = pp_jpg_1.resize(value=1312)
+        pp_png_1 = pp_png_1.resize(value=1312)
+        pp_bg_1 = pp_bg_1.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1, base="cc")
+        # pp_bg_1.show()
+        detailed_images.append(pp_bg_1)
+
+        # 介绍卖点
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 60)  # 颜色名称
+        text_list = [
+            {"text": "卖点1标题", "pos": (0, 58)},
+            {"text": "卖点2标题", "pos": (0, 283)},
+            {"text": "卖点3标题", "pos": (0, 505)},
+        ]
+        pp_bg_2 = PictureProcessing(r"{}\6.jpg".format(self.root))
+        for text_data in text_list:
+            text = self.get_text_value(text_data["text"])
+            if text:
+                _pp = PictureProcessing().get_text_image_advanced(
+                    font=font_1,
+                    text=text,
+                    fill=(0, 0, 0),
+                    return_mode="min_image",
+                )
+                pp_bg_2 = pp_bg_2.paste_img(top_img=_pp, value=text_data["pos"], base="nc")
+        detailed_images.append(pp_bg_2)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 细节展示
+    def deal_pic_3(self):
+        detailed_images = []
+        goods_art_no_list = list(self.data.keys())
+        # 展示鞋面材质  粘贴内里顶视图
+        detailed_images.append(PictureProcessing(r"{}\7.jpg".format(self.root)))
+        _, pp_png_1 = self.image_one_pic(return_orign=True,
+                                         goods_art_no=goods_art_no_list[0],
+                                         name="内里",
+                                         )
+        pp_png_1: PictureProcessing
+        pp_png_1 = pp_png_1.resize(value=2254)
+        pp_png_1 = pp_png_1.transpose(mode="left_right")
+        pp_png_1 = pp_png_1.rotate_advance(doge=-30)
+
+        pp_bg_1 = PictureProcessing(r"{}\8.jpg".format(self.root))
+        pp_bg_1 = pp_bg_1.paste_img(top_img=pp_png_1, value=(50, 50))
+        detailed_images.append(pp_bg_1)
+        detailed_images.append(PictureProcessing(r"{}\9.jpg".format(self.root)))
+
+        # 展示后跟
+        _, pp_png_2 = self.image_one_pic(return_orign=True,
+                                         goods_art_no=goods_art_no_list[0],
+                                         name="侧视",
+                                         )
+        pp_png_2: PictureProcessing
+        pp_png_2 = pp_png_2.resize(value=2116)
+        # pp_png_1 = pp_png_1.transpose(mode="left_right")
+        pp_png_2 = pp_png_2.rotate_advance(doge=30)
+
+        pp_bg_2 = PictureProcessing(r"{}\10.jpg".format(self.root))
+        pp_bg_2 = pp_bg_2.paste_img(top_img=pp_png_2, value=(100, 80), base="ne")
+        detailed_images.append(pp_bg_2)
+        detailed_images.append(PictureProcessing(r"{}\11.jpg".format(self.root)))
+        # 展示鞋头
+        _, pp_png_3 = self.image_one_pic(return_orign=True,
+                                         goods_art_no=goods_art_no_list[0],
+                                         name="侧视",
+                                         )
+        pp_png_3: PictureProcessing
+        pp_png_3 = pp_png_3.resize(value=2116)
+        # pp_png_1 = pp_png_1.transpose(mode="left_right")
+        pp_png_3 = pp_png_3.rotate_advance(doge=30)
+
+        pp_bg_3 = PictureProcessing(r"{}\12.jpg".format(self.root))
+        pp_bg_3 = pp_bg_3.paste_img(top_img=pp_png_3, value=(294, 125), base="sw")
+        detailed_images.append(pp_bg_3)
+        detailed_images.append(PictureProcessing(r"{}\13.jpg".format(self.root)))
+
+        # 展示鞋垫
+        _, pp_png_4 = self.image_one_pic(return_orign=True,
+                                         goods_art_no=goods_art_no_list[0],
+                                         name="内里",
+                                         )
+        pp_png_4: PictureProcessing
+        pp_png_4 = pp_png_4.resize(value=2300)
+        pp_png_4 = pp_png_4.transpose(mode="left_right")
+        pp_png_4 = pp_png_4.rotate_advance(doge=30)
+
+        pp_bg_4 = PictureProcessing(r"{}\14.jpg".format(self.root))
+        pp_bg_4 = pp_bg_4.paste_img(top_img=pp_png_4, value=(220, 89), base="ne")
+        detailed_images.append(pp_bg_4)
+        detailed_images.append(PictureProcessing(r"{}\15.jpg".format(self.root)))
+
+        # raise 1
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 展示产品信息和颜色图
+    def deal_pic_4(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\16.jpg".format(self.root)))
+        goods_art_no_list = list(self.data.keys())
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Regular.ttf", 44)  # 颜色名称
+
+        view_data_list = ["俯视", "内里", "后跟", "鞋底"]
+
+        for goods_art_no_dict in self.goods_no_value["货号资料"]:
+            color_name = goods_art_no_dict["颜色名称"]
+            goods_art_no = goods_art_no_dict["货号"]
+            pp_bg_2 = PictureProcessing(r"{}\17.jpg".format(self.root))
+            # ==================
+            text_list = [
+                {"text": "商品货号", "pos": (83, 1137)},
+            ]
+            for text_data in text_list:
+                text = self.get_text_value(text_data["text"])
+                if text:
+                    _pp = PictureProcessing().get_text_image_advanced(
+                        font=font_1,
+                        text=text,
+                        fill=(136, 136, 136),
+                        return_mode="min_image",
+                    )
+                    pp_bg_2 = pp_bg_2.paste_img(top_img=_pp, value=text_data["pos"])
+
+            # ===================
+            for view_name in view_data_list:
+                pp_jpg, pp_png = self.image_one_pic(return_orign=True,
+                                                    goods_art_no=goods_art_no,
+                                                    name=view_name,
+                                                    )
+                pp_jpg: PictureProcessing
+                pp_png: PictureProcessing
+
+                if view_name == "俯视":
+                    resize_value = 723
+                    value = (418, 735)
+                if view_name == "内里":
+                    resize_value = 512
+                    value = (1243, 273)
+                if view_name == "后跟":
+                    pp_jpg = pp_jpg.resize(value=500)
+                    pp_png = pp_png.resize(value=500)
+                    pp_jpg, pp_png = self.copy_view(pp_jpg, pp_png)
+                    resize_value = 469
+                    value = (1243, 681)
+                if view_name == "鞋底":
+                    resize_value = 512
+                    value = (1243, 1111)
+
+                pp_jpg = pp_jpg.resize(value=resize_value)
+                pp_png = pp_png.resize(value=resize_value)
+                value = (value[0] - pp_jpg.width / 2, value[1] - pp_jpg.height / 2)
+                pp_bg_2 = pp_bg_2.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="nw", value=value)
+
+            detailed_images.append(pp_bg_2)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 添加注意事项
+    def deal_pic_5(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\19.jpg".format(self.root)))
+        detailed_images.append(PictureProcessing(r"{}\20.jpg".format(self.root)))
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def copy_view(self, pp_jpg: PictureProcessing, pp_png: PictureProcessing):
+        pp_bg_jpg = PictureProcessing("RGB", (1600, 1600), (255, 255, 255))
+        pp_bg_png = PictureProcessing("RGBA", (1600, 1600), (255, 255, 255, 0))
+
+        pp_jpg_1_list = [pp_jpg, pp_jpg]
+        pp_png_1_list = [pp_png, pp_png]
+
+        x, y = 0, 0
+        for index, pp_jpg in enumerate(pp_jpg_1_list):
+            pp_bg_jpg = pp_bg_jpg.to_overlay_pic_advance(top_img=pp_jpg,
+                                                         value=(x, y))
+            x += pp_jpg.width - 20
+
+        x, y = 0, 0
+        for index, pp_png in enumerate(pp_png_1_list):
+            pp_bg_png = pp_bg_png.paste_img(top_img=pp_png,
+                                            value=(x, y))
+            x += pp_jpg.width - 20
+
+        min_bbox = pp_bg_png.getbbox()
+        min_bbox = PictureProcessing().expand_bbox(min_bbox, value=50)
+        pp_bg_jpg = pp_bg_jpg.crop(bbox=min_bbox)
+        pp_bg_png = pp_bg_png.crop(bbox=min_bbox)
+        return pp_bg_jpg, pp_bg_png

+ 304 - 0
python/custom_plugins/plugins/detail_template/huilima/detail_huilima4.py

@@ -0,0 +1,304 @@
+"""
+步骤:
+1、整理需要处理的款号图-输出款号图文件夹
+2、整理所有相关的图片作为素材图
+3、按要求进行拼接
+"""
+import os
+from PIL import ImageFont
+import sys
+import settings
+
+# from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
+# from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
+is_test_plugins = False
+try:
+    is_test_plugins = settings.is_test_plugins
+except:
+    is_test_plugins = False
+
+if is_test_plugins:
+    from custom_plugins.plugins_mode.detail_generate_base import DetailBase
+    from custom_plugins.plugins_mode.pic_deal import PictureProcessing
+else:
+    from plugins_mode.detail_generate_base import DetailBase
+    from plugins_mode.pic_deal import PictureProcessing
+
+plugins_name = "详情模板"
+company_name_list = ["全部"]
+template_name = "huilima-4"
+
+
+# 乐福鞋 详情页
+
+class DetailPicGet(DetailBase):
+    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
+    root = r"{}\resources\detail_temp\huilima\4".format(os.getcwd())
+
+    def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False, excel_data=None,
+                 assigned_page_list=None, output_queue=None, **kwargs):
+
+        super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows, excel_data=excel_data,
+                         assigned_page_list=assigned_page_list, output_queue=output_queue)
+
+        self.template_name = template_name
+        self.root = r"{}\resources\detail_temp\huilima\4".format(os.getcwd())
+        print("run huilima-1 ")
+        self.base_bg_color = (255, 255, 255)
+        self.deal_pic_func_list = [
+            self.deal_pic_1,
+            self.deal_pic_2,
+            self.deal_pic_3,
+            self.deal_pic_4,
+            self.deal_pic_5,
+            self.deal_pic_6,
+        ]
+        if test:
+            self.run_test()
+        else:
+            self.run_all()
+
+    def run_test(self):
+        detailed_images = []
+        detailed_images.append(self.deal_pic_1())
+        detailed_images.append(self.deal_pic_2())
+        detailed_images.append(self.deal_pic_3())
+        detailed_images.append(self.deal_pic_4())
+        detailed_images.append(self.deal_pic_5())
+        detailed_images.append(self.deal_pic_6())
+        img = self.add_pic(detailed_images)
+        if img:
+            self.create_folder(r"{}/{}".format(self.out_put_dir, template_name))
+            img.save(r"{}/{}/{}.jpg".format(self.out_put_dir, template_name, self.goods_no, format="JPEG"))
+            img.show()
+
+    #
+    def deal_pic_1(self):
+        detailed_images = []
+        pp_bg_1 = PictureProcessing(r"{}\1.jpg".format(self.root))
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 120)
+        text_list = [
+            {"text": "标题", "pos": (89, 224)},
+            {"text": "副标题", "pos": (89, 345)},
+        ]
+        for text_data in text_list:
+            text = self.get_text_value(text_data["text"])
+            if text:
+                _pp = PictureProcessing().get_text_image_advanced(
+                    font=font_1,
+                    text=text,
+                    fill=(0, 0, 0),
+                    return_mode="min_image",
+                )
+                pp_bg_1 = pp_bg_1.paste_img(top_img=_pp, value=text_data["pos"], base="nw")
+        detailed_images.append(pp_bg_1)
+
+        # 粘贴组合图
+        goods_art_no_list = list(self.data.keys())
+        pp_jpg, pp_png = self.image_one_pic(return_orign=True,
+                                            goods_art_no=goods_art_no_list[0],
+                                            name="组合",
+                                            )
+        if not pp_jpg:
+            pp_jpg, pp_png = self.image_one_pic(return_orign=True,
+                                                goods_art_no=goods_art_no_list[0],
+                                                name="俯视",
+                                                )
+        pp_jpg: PictureProcessing
+        pp_png: PictureProcessing
+        pp_jpg = pp_jpg.resize(value=1405)
+        pp_png = pp_png.resize(value=1405)
+        pp_bg_2 = PictureProcessing(r"{}\2.jpg".format(self.root))
+        pp_bg_2 = pp_bg_2.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="cc")
+
+        detailed_images.append(pp_bg_2)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 展示基础信息
+    def deal_pic_2(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\3.jpg".format(self.root)))
+        # 粘贴侧视图
+        goods_art_no_list = list(self.data.keys())
+
+        pp_jpg = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
+                                                color_name="侧视",
+                                                bg_color=self.base_bg_color)
+        pp_jpg = pp_jpg.resize(value=1098)
+        pp_jpg = pp_jpg.paste_img_invert(
+            top_img=PictureProcessing("RGB", (1600, pp_jpg.height + 100), self.base_bg_color),
+            base="cc")
+        detailed_images.append(pp_jpg)
+        # 粘贴基础信息
+        pp_bg_2 = PictureProcessing(r"{}\5.jpg".format(self.root))
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Regular.ttf", 62)
+        text_list = [
+            {"text": "鞋面材质", "pos": (767, 176)},
+            {"text": "内里材质", "pos": (1213, 176)},
+            {"text": "鞋底材质", "pos": (767, 345)},
+            {"text": "鞋垫材质", "pos": (1213, 345)},
+            {"text": "跟高", "pos": (767, 616)},
+            {"text": "前底厚度", "pos": (1196, 616)},
+        ]
+        for text_data in text_list:
+            text = self.get_text_value(text_data["text"])
+            if text:
+                _pp = PictureProcessing().get_text_image_advanced(
+                    font=font_1,
+                    text=text,
+                    fill=(0, 0, 0),
+                    return_mode="min_image",
+                )
+                pp_bg_2 = pp_bg_2.paste_img(top_img=_pp, value=text_data["pos"], base="nw")
+        detailed_images.append(pp_bg_2)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 颜色展示
+    def deal_pic_3(self):
+        detailed_images = []
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 34)  # 颜色名称
+        color_pic_list_1 = []
+        for goods_art_no_dict in self.goods_no_value["货号资料"]:
+            color_name = goods_art_no_dict["颜色名称"]
+            goods_art_no = goods_art_no_dict["货号"]
+            pp_jpg = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no,
+                                                    color_name="侧视",
+                                                    bg_color=self.base_bg_color)
+            pp_jpg = pp_jpg.resize(value=390)
+
+            pp_jpg = pp_jpg.paste_img_invert(
+                top_img=PictureProcessing("RGBA", (pp_jpg.width, pp_jpg.height + 70), (255, 255, 255, 0)),
+                base="nw"
+            )
+            text_image = PictureProcessing().get_text_image_advanced(font=font_1,
+                                                                     text="{} / COLOR".format(color_name),
+                                                                     fill=(0, 0, 0),
+                                                                     return_mode="min_image")
+
+            pp_jpg = pp_jpg.paste_img(top_img=text_image, base="sc", value=(0, 10))
+            color_pic_list_1.append(pp_jpg)
+
+        # 颜色列表进行等分展示
+        all_color_pp = PictureProcessing().horizontal_distribution(color_pic_list_1, bg_width=1114,
+                                                                   line_spacing=10,
+                                                                   number_per_row=2)
+        all_color_pp = all_color_pp.paste_img_invert(
+            top_img=PictureProcessing("RGB", (1600, all_color_pp.height + 100), self.base_bg_color),
+            base="cc",
+            value=(0, 0))
+        detailed_images.append(all_color_pp)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 展示细节图
+    def deal_pic_4(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\8.jpg".format(self.root)))
+
+        goods_art_no_list = list(self.data.keys())
+        goods_art_no = goods_art_no_list[0]
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 85)  # 颜色名称
+
+        view_data_list = ["俯视", "俯视", "侧视"]
+        text_list = ["提示1主标题", "提示2主标题", "提示3主标题"]
+        bg_name_list = ["10.jpg", "12.jpg", "14.jpg"]
+        for index, view_name in enumerate(view_data_list):
+            pp_jpg = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no,
+                                                    color_name=view_name,
+                                                    bg_color=(246, 246, 246))
+            if index == 0:
+                resize_value = 3200
+                paste_base = "cc"
+                paste_value = (0, 200)
+            if index == 1:
+                resize_value = 3200
+                paste_base = "ne"
+                paste_value = (-100, 0)
+            if index == 2:
+                pp_jpg = pp_jpg.transpose(mode="left_right")
+                resize_value = 3513
+                paste_base = "sw"
+                paste_value = (0, 100)
+
+            pp_jpg = pp_jpg.resize(value=resize_value)
+            pp_jpg = pp_jpg.paste_img_invert(top_img=PictureProcessing("RGB", (1500, 1500), (246, 246, 246)),
+                                             base=paste_base,
+                                             value=paste_value
+                                             )
+            pp_jpg = pp_jpg.radius(value=100)
+            pp_jpg = pp_jpg.paste_img_invert(top_img=PictureProcessing("RGB", (1600, 1600), (255, 255, 255)),
+                                             base="cc"
+                                             )
+            detailed_images.append(pp_jpg)
+            # 添加文字
+            text = self.get_text_value(text_list[index])
+            if text:
+                pp_text_bg = PictureProcessing(r"{}\{}".format(self.root, bg_name_list[index]))
+                _pp = PictureProcessing().get_text_image_advanced(
+                    font=font_1,
+                    text=text,
+                    fill=(0, 0, 0),
+                    return_mode="min_image",
+                )
+                pp_text_bg = pp_text_bg.paste_img(top_img=_pp, value=(73, 0), base="wc")
+                detailed_images.append(pp_text_bg)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 场景图--产品展示
+    def deal_pic_5(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\15.jpg".format(self.root)))
+
+        goods_art_no_list = list(self.data.keys())
+        goods_art_no = goods_art_no_list[0]
+
+        _flag = True
+        pp_jpg = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no,
+                                                color_name="组合1",
+                                                bg_color=(255, 255, 255))
+        if pp_jpg:
+            pp_jpg = pp_jpg.paste_img_invert(
+                top_img=PictureProcessing("RGB", (1600, pp_jpg.height + 200), (255, 255, 255)),
+                base="cc",
+            )
+            detailed_images.append(pp_jpg)
+        else:
+            _flag = False
+
+        pp_jpg = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no,
+                                                color_name="组合2",
+                                                bg_color=(255, 255, 255))
+        if pp_jpg:
+            pp_jpg = pp_jpg.paste_img_invert(
+                top_img=PictureProcessing("RGB", (1600, pp_jpg.height + 200), (255, 255, 255)),
+                base="cc",
+            )
+            detailed_images.append(pp_jpg)
+        else:
+            _flag = False
+
+        if not _flag:
+            detailed_images = []
+            detailed_images.append(PictureProcessing(r"{}\15.jpg".format(self.root)))
+            for goods_art_no_dict in self.goods_no_value["货号资料"]:
+                color_name = goods_art_no_dict["颜色名称"]
+                goods_art_no = goods_art_no_dict["货号"]
+                pp_jpg = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no,
+                                                        color_name="侧视",
+                                                        bg_color=self.base_bg_color)
+                pp_jpg = pp_jpg.resize(value=1404)
+                pp_jpg = pp_jpg.paste_img_invert(
+                    top_img=PictureProcessing("RGB", (1600, pp_jpg.height + 200), (255, 255, 255)),
+                    base="cc",
+                )
+                detailed_images.append(pp_jpg)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 添加注意事项
+    def deal_pic_6(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\20.jpg".format(self.root)))
+        detailed_images.append(PictureProcessing(r"{}\21.jpg".format(self.root)))
+        return PictureProcessing(im=self.add_pic(detailed_images))

+ 0 - 0
python/custom_plugins/plugins/detail_template/xiaosushuoxie/__init__.py


+ 337 - 0
python/custom_plugins/plugins/detail_template/xiaosushuoxie/detail_xiaosushuoxie1.py

@@ -0,0 +1,337 @@
+"""
+步骤:
+1、整理需要处理的款号图-输出款号图文件夹
+2、整理所有相关的图片作为素材图
+3、按要求进行拼接
+"""
+import os
+from PIL import ImageFont
+# from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
+# from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
+from plugins_mode.detail_generate_base import DetailBase
+from plugins_mode.pic_deal import PictureProcessing
+
+
+plugins_name = "详情模板"
+company_name_list = ["小苏",]
+template_name = "xiaosushuoxie-1"
+
+
+class DetailPicGet(DetailBase):
+    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
+    root = r"{}\resources\detail_temp\xiaosushuoxie\1".format(os.getcwd())
+
+    def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False, excel_data=None,
+                 assigned_page_list=None):
+        super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows, excel_data=excel_data,
+                         assigned_page_list=assigned_page_list)
+        self.template_name = template_name
+        self.root = r"{}\resources\detail_temp\xiaosushuoxie\1".format(os.getcwd())
+        self.deal_pic_func_list = [
+            self.deal_pic_1,
+            self.deal_pic_2,
+            self.deal_pic_3,
+            self.deal_pic_4,
+            self.deal_pic_5,
+        ]
+
+        if test:
+            self.run_test()
+        else:
+            self.run_all()
+
+    def run_test(self):
+        detailed_images = []
+        detailed_images.append(self.deal_pic_1())
+        detailed_images.append(self.deal_pic_2())
+        detailed_images.append(self.deal_pic_3())
+        detailed_images.append(self.deal_pic_4())
+        detailed_images.append(self.deal_pic_5())
+        img = self.add_pic(detailed_images)
+        img.save(r"{}/{}.jpg".format(self.out_put_dir, self.goods_no, format="JPEG"))
+
+    def deal_pic_1(self):
+        bg_color = (239, 237, 238)
+        """   制作主图  """
+        detailed_images = []
+        # -------粘贴文字-------
+        font = ImageFont.truetype(r'resources\ttf\simhei.ttf', 30)
+        text_list = []
+        for _set in [("【品    牌】", "品牌"),
+                     ("【货    号】", "款号"),
+                     ("【鞋面材质】", "鞋面材质"),
+                     ("【系列风格】", "系列风格"),
+                     ("【内里材质】", "内里材质"),
+                     ("【尺    码】", "尺码"),
+                     ("【鞋底材质】", "鞋底材质"),
+                     ("【品牌编码】", "品牌编码"),
+                     ]:
+            title, key = _set
+            text = self.get_text_value(key)
+            if text:
+                text_list.append(
+                    (title, text)
+                )
+
+        # 文字排列
+        pp_bg = PictureProcessing(r"{}\bg-1.jpg".format(self.root))
+        x = 101
+        y = 98
+        for _set in text_list:
+            pp_bg = pp_bg.add_text(mode="pixel",
+                                   value=(x, y),
+                                   font=font,
+                                   text="{}:{}".format(_set[0], _set[1]),
+                                   align="left",
+                                   spacing=10,
+                                   fill=(17, 16, 16))
+            x += 588
+            if x > 700:
+                x = 101
+                y += 94
+
+        # ----------主图放置
+        y += 10
+        goods_art_no_list = list(self.data.keys())
+
+        pp_jpg, pp_png = self.image_one_pic(goods_art_no=goods_art_no_list[0], name="俯视", return_orign=True)
+        pp_jpg = pp_jpg.resize(value=1083)
+        pp_png = pp_png.resize(value=1083)
+        pp_bg = pp_bg.to_overlay_pic_advance(mode="pixel", top_img=pp_jpg, base="nc", value=(0, y), top_png_img=pp_png)
+
+        y += pp_jpg.height
+        y += 20
+
+        # ----------配图粘贴
+        if len(goods_art_no_list) > 1:
+            # 大于一个颜色做颜色图展示
+
+            pp_list_1, pp_list_2 = [], []
+            for goods_art_no in goods_art_no_list:
+                pp_jpg, pp_png = self.image_one_pic(goods_art_no=goods_art_no, name="侧视", return_orign=True)
+                pp_jpg = pp_jpg.resize(value=400)
+                pp_png = pp_png.resize(value=400)
+                pp_list_1.append(pp_jpg)
+                pp_list_2.append(pp_png)
+
+            _pp_jpg = PictureProcessing()
+            _pp_png = PictureProcessing()
+            _pp_jpg = _pp_jpg.horizontal_distribution(pp_list=pp_list_1, bg_width=1200, margins=(0, 0, 0, 0),
+                                                      line_spacing=0,
+                                                      number_per_row=3)
+            _pp_png = _pp_png.horizontal_distribution(pp_list=pp_list_2, bg_width=1200, margins=(0, 0, 0, 0),
+                                                      line_spacing=0,
+                                                      number_per_row=3)
+
+            pp_bg = pp_bg.to_overlay_pic_advance(mode="pixel", top_img=_pp_jpg, base="nc", value=(0, y),
+                                                 top_png_img=_pp_png)
+
+            y += _pp_jpg.height
+            y += 30
+
+        # ------多余的剪裁
+        if y < pp_bg.height:
+            # print("触发剪裁")
+            pp_bg = pp_bg.crop_img(value=(0, 0, pp_bg.width, y))
+
+        return pp_bg
+
+    def deal_pic_2(self):
+        """
+        细节解析
+
+        """
+        font_1 = ImageFont.truetype(r'resources\ttf\simhei.ttf', 30)
+        font_2 = ImageFont.truetype(r'resources\ttf\simhei.ttf', 15)
+        bg_color = (220, 220, 220)
+        detailed_images = []
+
+        goods_art_no_list = list(self.data.keys())
+        # ------侧视图-------------
+        pp_2 = self.image_one_pic(goods_art_no=goods_art_no_list[0], name="侧视", bg_color=bg_color)
+        pp_2 = pp_2.resize(mode="pixel", base="width", value=1327)
+        pp_2 = PictureProcessing("RGB", (550, 550), bg_color).paste_img(mode="pixel", top_img=pp_2,
+                                                                        base="wc", value=(-90, 0))
+        # 文字
+        pp_2 = pp_2.add_text(mode="pixel",
+                             value=(21, 24),
+                             font=font_1,
+                             text="优质质感鞋面",
+                             align="left",
+                             spacing=10,
+                             fill=(28, 28, 28))
+        pp_2 = pp_2.add_text(mode="pixel",
+                             value=(21, 76),
+                             font=font_2,
+                             text="颇具层次",
+                             align="left",
+                             spacing=10,
+                             fill=(78, 78, 78))
+        pp_2 = pp_2.add_text(mode="pixel",
+                             value=(21, 115),
+                             font=font_2,
+                             text="时尚质感出众",
+                             align="left",
+                             spacing=10,
+                             fill=(78, 78, 78))
+
+        # ------后跟-------------
+        pp_3 = self.image_one_pic(goods_art_no=goods_art_no_list[0], name="后跟", bg_color=bg_color)
+        pp_3 = pp_3.resize(mode="pixel", base="width", value=625)
+        pp_3 = PictureProcessing("RGB", (550, 550), bg_color).paste_img(mode="pixel", top_img=pp_3,
+                                                                        base="cc", value=(0, 0))
+        # 文字
+        pp_3 = pp_3.add_text(mode="pixel",
+                             value=(pp_3.width - 21, pp_3.height - 35 * 3),
+                             font=font_2,
+                             text="颇具层次",
+                             align="right",
+                             spacing=10,
+                             anchor="rs",
+                             fill=(78, 78, 78))
+
+        pp_3 = pp_3.add_text(mode="pixel",
+                             value=(pp_3.width - 21, pp_3.height - 35 * 2),
+                             font=font_2,
+                             text="时尚质感出众",
+                             align="right",
+                             anchor="rs",
+                             spacing=10,
+                             fill=(78, 78, 78))
+
+        pp_3 = pp_3.add_text(mode="pixel",
+                             value=(pp_3.width - 21, pp_3.height - 35),
+                             font=font_1,
+                             text="设计感十足",
+                             anchor="rs",
+                             align="right",
+                             spacing=10,
+                             fill=(28, 28, 28))
+
+        # ---------------鞋底图
+        pp_4 = self.image_one_pic(goods_art_no=goods_art_no_list[0], name="鞋底", bg_color=bg_color)
+        pp_4 = pp_4.resize(mode="pixel", base="width", value=1635)
+        pp_4 = PictureProcessing("RGB", (1134, 625), bg_color).paste_img(mode="pixel", top_img=pp_4,
+                                                                         base="wc", value=(198, 0))
+        # 文字
+        pp_4 = pp_4.add_text(mode="pixel",
+                             value=(21, 451),
+                             font=font_1,
+                             text="防滑耐磨鞋底",
+                             align="left",
+                             spacing=10,
+                             fill=(28, 28, 28))
+        pp_4 = pp_4.add_text(mode="pixel",
+                             value=(21, 510),
+                             font=font_2,
+                             text="优质材质",
+                             align="left",
+                             spacing=10,
+                             fill=(78, 78, 78))
+        pp_4 = pp_4.add_text(mode="pixel",
+                             value=(21, 549),
+                             font=font_2,
+                             text="防滑网纹设计坚固耐磨",
+                             align="left",
+                             spacing=10,
+                             fill=(78, 78, 78))
+
+        new_bg = PictureProcessing("RGB", (1200, 40 + pp_2.height + 40 + pp_4.height + 40), (239, 239, 239))
+        new_bg = new_bg.paste_img(mode="pixel", top_img=pp_2, base="nw", value=(33, 40))
+        new_bg = new_bg.paste_img(mode="pixel", top_img=pp_3, base="nw", value=(33 + 550 + 33, 40))
+        new_bg = new_bg.paste_img(mode="pixel", top_img=pp_4, base="nw", value=(33, 40 + pp_2.height + 40))
+        detailed_images.append(new_bg)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_3(self):
+        # 设计理念
+        bg = PictureProcessing(r"{}\1 (1).jpg".format(self.root))
+        font_1 = ImageFont.truetype(r'resources\ttf\simhei.ttf', 40)
+        # 粘贴文字
+        text = self.get_text_value("设计理念")
+        if not text:
+            text = "告别枯燥沉闷日常还原自然本身色彩\n融合工装、复古、运动元素随性出走感受自在的步伐"
+
+        bg = bg.add_text(mode="pixel",
+                         value=(164, 328),
+                         font=font_1,
+                         text=text,
+                         align="left",
+                         spacing=15,
+                         fill=(39, 39, 39))
+
+        return bg
+
+    def deal_pic_4(self):
+        """   各个颜色细节展示  """
+        bg_color = (255, 255, 255)
+        detailed_images = []
+        goods_art_no_list = list(self.data.keys())
+        font_1 = ImageFont.truetype(r'resources\ttf\simhei.ttf', 30)
+
+        for goods_art_no_dict in self.goods_no_value["货号资料"]:
+            color_name = goods_art_no_dict["颜色名称"]
+            goods_art_no = goods_art_no_dict["货号"]
+            # ------俯视图-------------
+            pp_1 = self.image_one_pic(goods_art_no=goods_art_no, name="俯视", bg_color=bg_color)
+            pp_1 = pp_1.resize(mode="pixel", base="width", value=956)
+            pp_1 = PictureProcessing("RGB", (1200, 40 + pp_1.height + 40), bg_color).paste_img(mode="pixel",
+                                                                                               top_img=pp_1,
+                                                                                               base="cc", value=(0, 0))
+            # 粘贴文字与logo
+            pp_1 = pp_1.add_text(mode="pixel",
+                                 value=(51, 26),
+                                 font=font_1,
+                                 text=color_name,
+                                 align="left",
+                                 spacing=10,
+                                 fill=(28, 28, 28))
+            pp_1 = pp_1.paste_img(mode="pixel", top_img=PictureProcessing(
+                r"{}\1 (4).jpg".format(self.root)), base="nw", value=(51, 72))
+
+            # ------后跟-------------
+            pp_2 = self.image_one_pic(goods_art_no=goods_art_no, name="后跟", bg_color=bg_color)
+            pp_2 = pp_2.resize(mode="pixel", base="width", value=345)
+            pp_2 = PictureProcessing("RGB", (537, 356), bg_color).paste_img(mode="pixel", top_img=pp_2,
+                                                                            base="cc", value=(0, 0))
+            # ------内里-------------
+            pp_3 = self.image_one_pic(goods_art_no=goods_art_no, name="内里", bg_color=bg_color)
+            pp_3 = pp_3.resize(mode="pixel", base="width", value=577)
+            pp_3 = PictureProcessing("RGB", (537, 356), bg_color).paste_img(mode="pixel", top_img=pp_3,
+                                                                            base="cc", value=(0, 0))
+            bg_pp = PictureProcessing("RGB", (1200, 20 + pp_1.height + 20 + pp_2.height + 20), bg_color)
+            # 粘贴俯视图
+            bg_pp = bg_pp.paste_img(mode="pixel", top_img=pp_1, base="nw", value=(0, 0))
+            # 粘贴后跟
+            bg_pp = bg_pp.paste_img(mode="pixel", top_img=pp_2, base="nw", value=(51, 20 + pp_1.height + 20))
+            # 粘贴内里
+            bg_pp = bg_pp.paste_img(mode="pixel", top_img=pp_3, base="nw", value=(588, 20 + pp_1.height + 20))
+
+            detailed_images.append(bg_pp)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_5(self):
+        # 其他图片
+        detailed_images = []
+        detailed_images.append(
+            PictureProcessing(r"{}\1 (2-1).jpg".format(self.root)))
+        detailed_images.append(
+            PictureProcessing(r"{}\1 (3).jpg".format(self.root)))
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+
+if __name__ == '__main__':
+    import json
+
+    with open(
+            r"D:\MyDocuments\PythonCode\MyPython\red_dragonfly\deal_pics\auto_capture_V2\auto_photo\qt_test\data3.txt",
+            "r", encoding="utf-8") as f:
+        data = json.loads(f.read())
+
+    for goods_no, value in data.items():
+        d = DetailPicGetXiaoSuShuoXie(goods_no, value,
+                                      out_put_dir=r"D:\MyDocuments\PythonCode\MyPython\red_dragonfly\deal_pics\auto_capture_V2\auto_photo\output\2024-11-19\软件-详情图生成")
+        raise 1

+ 626 - 0
python/custom_plugins/plugins/detail_template/xiaosushuoxie/detail_xiaosushuoxie2.py

@@ -0,0 +1,626 @@
+"""
+步骤:
+1、整理需要处理的款号图-输出款号图文件夹
+2、整理所有相关的图片作为素材图
+3、按要求进行拼接
+"""
+
+import os
+from PIL import ImageFont, Image, ImageDraw
+import settings
+try:
+    is_test_plugins = settings.is_test_plugins
+except:
+    is_test_plugins = False
+
+if is_test_plugins:
+    from custom_plugins.plugins_mode.detail_generate_base import DetailBase
+    from custom_plugins.plugins_mode.pic_deal import PictureProcessing
+else:
+    from plugins_mode.detail_generate_base import DetailBase
+    from plugins_mode.pic_deal import PictureProcessing
+
+
+plugins_name = "详情模板"
+company_name_list = ["小苏",]
+template_name = "xiaosushuoxie-2"
+
+
+class DetailPicGet(DetailBase):
+    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
+    root = r"{}\resources\detail_temp\xiaosushuoxie\2".format(os.getcwd())
+
+    def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False, excel_data=None,
+                 assigned_page_list=None):
+        super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows, excel_data=excel_data,
+                         assigned_page_list=assigned_page_list)
+        self.template_name = template_name
+        self.root = r"{}\resources\detail_temp\xiaosushuoxie\2".format(os.getcwd())
+        self.base_bg_color = (235, 234, 234)
+        self.deal_pic_func_list = [
+            self.deal_pic_1,
+            self.deal_pic_2,
+            self.deal_pic_3,
+            self.deal_pic_4,
+            self.deal_pic_5,
+            self.deal_pic_6,
+            self.deal_pic_7,
+        ]
+        if test:
+            self.run_test()
+        else:
+            self.run_all()
+
+    def run_test(self):
+        detailed_images = []
+        detailed_images.append(self.deal_pic_1())
+        detailed_images.append(self.deal_pic_2())
+        detailed_images.append(self.deal_pic_3())
+        detailed_images.append(self.deal_pic_4())
+        detailed_images.append(self.deal_pic_5())
+        detailed_images.append(self.deal_pic_6())
+        detailed_images.append(self.deal_pic_7())
+        img = self.add_pic(detailed_images)
+        img.save(r"{}/{}.jpg".format(self.out_put_dir, self.goods_no, format="JPEG"))
+
+    def deal_pic_1(self):
+        """   制作主图  """
+        detailed_images = []
+        # -------粘贴文字-------
+        pp_bg = PictureProcessing(r"{}\template_1.png".format(self.root))
+        detailed_images.append(pp_bg)
+
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 60)
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 35)
+        # font_2 = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 35)
+
+        t1_title = self.get_text_value("标题")
+        t1_sub_title = self.get_text_value("副标题")
+        # t1_sub_title = "副标题副标题副标题副标题副标题\n副标题副标题副标题副标题\n副标题副标题副标题"
+        base_bg_color = (236, 235, 235)
+        if t1_title:
+            t_title_pp = PictureProcessing("RGB", (1200, 500), base_bg_color)
+            t_title_pp = t_title_pp.get_text_image_advanced(
+                value=(50, 10),
+                font=font_1,
+                text=t1_title,
+                align="left",
+                spacing=10,
+                fill=(17, 16, 16),
+                return_mode="min_image_high",
+                margins=(0, 0, 0, 0)
+            )
+            detailed_images.append(t_title_pp)
+        if t1_sub_title:
+            t_title_2_pp = PictureProcessing("RGB", (1200, 500), base_bg_color)
+            t_title_2_pp = t_title_2_pp.get_text_image_advanced(
+                value=(50, 10),
+                font=font_2,
+                text=t1_sub_title,
+                align="left",
+                spacing=10,
+                fill=(32, 32, 32),
+                return_mode="min_image_high",
+                margins=(0, 0, 0, 0)
+            )
+            detailed_images.append(t_title_2_pp)
+
+        # 添加分割线
+        detailed_images.append(PictureProcessing("RGB", (pp_bg.width, 150), self.base_bg_color))
+
+        # ================添加图片
+        goods_art_no_list = list(self.data.keys())
+        _zuhe_pic_list = []
+        color_name_list = ["组合", "组合2", "组合3"]
+        for color_name in color_name_list:
+            pp_1 = self.get_overlay_pic_from_dict(
+                goods_art_no=goods_art_no_list[0],
+                color_name=color_name,
+                bg_color=self.base_bg_color,
+            )
+            if not pp_1:
+                continue
+            pp_1 = pp_1.resize(value=int(pp_bg.width / 1.45))
+            pp_1 = pp_1.paste_img_invert(
+                top_img=PictureProcessing("RGB", (pp_bg.width, pp_1.height + 30), self.base_bg_color),
+                base="cc")
+
+            _zuhe_pic_list.append(pp_1)
+
+        if not _zuhe_pic_list:
+            pp_1 = self.get_overlay_pic_from_dict(
+                goods_art_no=goods_art_no_list[0],
+                color_name="俯视",
+                bg_color=self.base_bg_color,
+            )
+            pp_1 = pp_1.resize(value=int(pp_bg.width / 1.45))
+            pp_1 = pp_1.paste_img_invert(
+                top_img=PictureProcessing("RGB", (pp_bg.width, pp_1.height + 30), self.base_bg_color),
+                base="cc")
+
+            _zuhe_pic_list.append(pp_1)
+
+        detailed_images.extend(_zuhe_pic_list)
+
+        # 添加分割线
+        detailed_images.append(PictureProcessing("RGB", (pp_bg.width, 150), self.base_bg_color))
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_2(self):
+        """
+        细节解析
+
+        """
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\template_2.png".format(self.root))
+        detailed_images.append(pp_bg)
+
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 60)
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 30)
+
+        t1_title = self.get_text_value("提示1主标题")
+        t1_sub_title = self.get_text_value("提示1副标题")
+        if t1_title:
+            t_title_pp = PictureProcessing("RGB", (1200, 500), (249, 249, 249))
+            t_title_pp = t_title_pp.get_text_image_advanced(
+                value=(1200 - 80, 45),
+                font=font_1,
+                text=t1_title,
+                align="right",
+                anchor="rs",
+                spacing=10,
+                fill=(17, 16, 16),
+                return_mode="min_image_high",
+                margins=(10, 10, 0, 0)
+            )
+            detailed_images.append(t_title_pp)
+        if t1_sub_title:
+            t_title_2_pp = PictureProcessing("RGB", (1200, 500), (249, 249, 249))
+            t_title_2_pp = t_title_2_pp.get_text_image_advanced(
+                value=(1200 - 80, 30),
+                font=font_2,
+                text=t1_sub_title,
+                align="right",
+                anchor="rs",
+                spacing=10,
+                fill=(55, 55, 55),
+                return_mode="min_image_high",
+                margins=(10, 10, 0, 0)
+            )
+            detailed_images.append(t_title_2_pp)
+
+        # ----------主图放置
+        goods_art_no_list = list(self.data.keys())
+        # ---------------鞋底图
+        bg_color = (249, 249, 249)
+        pp_jpg = self.get_overlay_pic_from_dict(
+            goods_art_no=goods_art_no_list[0],
+            color_name="鞋底",
+            bg_color=bg_color
+        )
+        pp_jpg = pp_jpg.paste_img_invert(top_img=PictureProcessing("RGB", (1200, pp_jpg.height + 100), bg_color),
+                                         base="nc",
+                                         value=(400, 00)
+                                         )
+        detailed_images.append(pp_jpg)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_3(self):
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\template_4.png".format(self.root))
+        detailed_images.append(pp_bg)
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 60)
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 30)
+
+        t1_title = self.get_text_value("提示2主标题")
+        t1_sub_title = self.get_text_value("提示2副标题")
+        bg_color = (252, 252, 252)
+        if t1_title:
+            t_title_pp = PictureProcessing("RGB", (1200, 500), bg_color)
+            t_title_pp = t_title_pp.get_text_image_advanced(
+                value=(80, 45),
+                font=font_1,
+                text=t1_title,
+                align="left",
+                anchor=None,
+                spacing=10,
+                fill=(17, 16, 16),
+                return_mode="min_image_high",
+                margins=(10, 10, 0, 0)
+            )
+            detailed_images.append(t_title_pp)
+        if t1_sub_title:
+            t_title_2_pp = PictureProcessing("RGB", (1200, 500), bg_color)
+            t_title_2_pp = t_title_2_pp.get_text_image_advanced(
+                value=(80, 30),
+                font=font_2,
+                text=t1_sub_title,
+                align="left",
+                anchor=None,
+                spacing=10,
+                fill=(55, 55, 55),
+                return_mode="min_image_high",
+                margins=(10, 10, 0, 0)
+            )
+            detailed_images.append(t_title_2_pp)
+
+        # ----------主图放置
+        goods_art_no_list = list(self.data.keys())
+        # ---------------鞋底图
+
+        pp_jpg = self.get_overlay_pic_from_dict(
+            goods_art_no=goods_art_no_list[0],
+            color_name="侧视",
+            bg_color=bg_color
+        )
+        pp_jpg = pp_jpg.resize(value=1686)
+        pp_jpg = pp_jpg.paste_img_invert(top_img=PictureProcessing("RGB", (1200, pp_jpg.height), bg_color),
+                                         base="ec",
+                                         value=(0, 0)
+                                         )
+        # pp_jpg = pp_jpg.resize(value=1000)
+        # pp_jpg = pp_jpg.paste_img_invert(top_img=PictureProcessing("RGB",(1200,pp_jpg.height+150),bg_color),
+        #                                  base="wc",
+        #                                  value=(0,0)
+        #                                  )
+        detailed_images.append(pp_jpg)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_4(self):
+        """各个颜色细节展示"""
+        bg_color = (235, 235, 235)
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\template_5.png".format(self.root))
+        detailed_images.append(pp_bg)
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 60)
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 30)
+
+        t1_title = self.get_text_value("提示3主标题")
+        t1_sub_title = self.get_text_value("提示3副标题")
+        if t1_title:
+            t_title_pp = PictureProcessing("RGB", (1200, 500), bg_color)
+            t_title_pp = t_title_pp.get_text_image_advanced(
+                value=(1200 - 80, 45),
+                font=font_1,
+                text=t1_title,
+                align="right",
+                anchor="rs",
+                spacing=10,
+                fill=(17, 16, 16),
+                return_mode="min_image_high",
+                margins=(10, 10, 0, 0)
+            )
+            detailed_images.append(t_title_pp)
+        if t1_sub_title:
+            t_title_2_pp = PictureProcessing("RGB", (1200, 500), bg_color)
+            t_title_2_pp = t_title_2_pp.get_text_image_advanced(
+                value=(1200 - 80, 30),
+                font=font_2,
+                text=t1_sub_title,
+                align="right",
+                anchor="rs",
+                spacing=10,
+                fill=(55, 55, 55),
+                return_mode="min_image_high",
+                margins=(10, 10, 0, 0)
+            )
+            detailed_images.append(t_title_2_pp)
+
+        goods_art_no_list = list(self.data.keys())
+        # ------侧视图-------------
+        pp_2 = self.image_one_pic(
+            goods_art_no=goods_art_no_list[0], name="侧视", bg_color=bg_color
+        )
+        pp_2 = pp_2.resize(mode="pixel", base="width", value=2327)
+        pp_2 = PictureProcessing("RGBA", (200, 300), bg_color).paste_img(
+            mode="pixel", top_img=pp_2, base="wc", value=(-900, 0)
+        )
+
+        # ------侧视-------------
+        pp_3 = self.image_one_pic(
+            goods_art_no=goods_art_no_list[0], name="侧视", bg_color=bg_color
+        )
+        pp_3 = pp_3.resize(mode="pixel", base="width", value=3000)
+        pp_3 = PictureProcessing("RGBA", (200, 300), bg_color).paste_img(
+            mode="pixel", top_img=pp_3, base="cc", value=(-500, 0)
+        )
+        # ---------------侧视图---------------旋转
+        _, pp_4 = self.image_one_pic(
+            goods_art_no=goods_art_no_list[0],
+            name="侧视",
+            bg_color=bg_color,
+            return_orign=True,
+        )
+        pp_4 = pp_4.resize(mode="pixel", base="width", value=1163)
+        pp_4_max = pp_4.width if pp_4.width > pp_4.height else pp_4.height
+        past_y = 0
+        top_img_bg = PictureProcessing("RGBA", (pp_bg.width, pp_2.height), bg_color)
+        top_img_bg = top_img_bg.paste_img(
+            mode="pixel", top_img=pp_2, base="wc", value=(50, past_y)
+        )
+        top_img_bg = top_img_bg.paste_img(
+            mode="pixel", top_img=pp_3, base="wc", value=(267, past_y)
+        )
+        new_pp4_bg = PictureProcessing(
+            "RGBA", (pp_4_max, pp_4_max + 100), (239, 239, 239, 0)
+        )
+        pp_4 = PictureProcessing("RGBA", (pp_4.width, pp_4.height), bg_color).paste_img(
+            mode="pixel", top_img=pp_4, base="nw", value=(0, 0)
+        )
+        new_pp4_bg.paste_img(mode="pixel", top_img=pp_4, base="wc", value=(0, 0))
+        new_pp4_bg = new_pp4_bg.rotate(30)
+        pp4_im = new_pp4_bg.get_im()
+        new_pp4_im = pp4_im.crop(pp4_im.getbbox())
+        new_pp5_bg = PictureProcessing(
+            "RGBA", (pp_bg.width, new_pp4_im.height - 200), bg_color
+        )
+        new_pp5_bg = new_pp5_bg.paste_img(
+            mode="pixel", top_img=new_pp4_bg, base="cc", value=(-50, 0)
+        )
+        new_empty_bg = PictureProcessing("RGBA", (pp_bg.width, 50), bg_color)
+        detailed_images.append(top_img_bg)
+        detailed_images.append(new_pp5_bg)
+        detailed_images.append(new_empty_bg)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_5(self):
+        bg_color = (255, 255, 255)
+        detailed_images = []
+
+        # =============文字=================
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\en\Black.otf", 65)
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 65)
+        t1_title = "INFORMATION"
+        t1_sub_title = "产品信息"
+        if t1_title:
+            t_title_pp = PictureProcessing("RGB", (1200, 500), bg_color)
+            t_title_pp = t_title_pp.get_text_image_advanced(
+                value=(600, 45),
+                font=font_1,
+                text=t1_title,
+                align="center",
+                anchor="mm",
+                spacing=10,
+                fill=(16, 16, 16),
+                return_mode="min_image_high",
+                margins=(10, 10, 0, 0)
+            )
+            detailed_images.append(t_title_pp)
+        if t1_sub_title:
+            t_title_2_pp = PictureProcessing("RGB", (1200, 500), bg_color)
+            t_title_2_pp = t_title_2_pp.get_text_image_advanced(
+                value=(600, 30),
+                font=font_2,
+                text=t1_sub_title,
+                align="center",
+                anchor="mm",
+                spacing=10,
+                fill=(16, 16, 16),
+                return_mode="min_image_high",
+                margins=(10, 10, 0, 0)
+            )
+            detailed_images.append(t_title_2_pp)
+
+        goods_art_no_list = list(self.data.keys())
+        product_img = self.get_overlay_pic_from_dict(
+            goods_art_no=goods_art_no_list[0],
+            color_name="俯视",
+            bg_color=bg_color
+        )
+        product_img = product_img.resize(value=1200 / 1.75)
+        product_img = product_img.paste_img_invert(
+            top_img=PictureProcessing("RGB", (1200, product_img.height), bg_color),
+            base="cc",
+        )
+
+        text_font = ImageFont.truetype(r"resources\ttf\puhui\Regular.otf", 30)
+        tips_font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 30)
+        h = 280 if product_img.height < 312 else 312
+        paramsList = [("帮高", (140, product_img.height - h)), ("跟高", (1200 - 140, product_img.height - h)),
+                      ("鞋宽", (1200 - 140, product_img.height - 87))]
+        tipsList = [("帮高", (140, product_img.height - h - 30)), ("跟高", (1200 - 140, product_img.height - h - 30)),
+                    ("鞋宽", (1200 - 140, product_img.height - 87 - 30))]
+
+        for index, item in enumerate(paramsList):
+            text = "{}".format(self.get_text_value(item[0]))
+            if not text:
+                continue
+
+            product_img = product_img.add_text(
+                mode="pixel",
+                value=item[1],
+                font=text_font,
+                anchor="mm",
+                text=text,
+                align="center",
+                spacing=10,
+                fill=(143, 143, 143),
+            )
+
+            product_img = product_img.add_text(
+                mode="pixel",
+                value=tipsList[index][1],
+                font=tips_font,
+                anchor="mm",
+                text="{}".format(tipsList[index][0]),
+                align="center",
+                spacing=15,
+                fill=(143, 143, 143),
+            )
+
+        detailed_images.append(product_img)
+
+        # ===========================================================================================================d
+        pp_bg = PictureProcessing(r"{}\template_6.png".format(self.root))
+        tableList = [
+            ("鞋面材质", (300, 72)),
+            ("内里材质", (760, 72)),
+            ("鞋垫材质", (300, 72 + 105)),
+            ("鞋底材质", (760, 72 + 105)),
+        ]
+        table_font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 30)
+        spacing = 15
+        text_arrays = []
+        for i, tableItem in enumerate(tableList):
+            item_text = self.get_text_value(tableItem[0])
+            if not item_text:
+                continue
+            text_arrays.append("{} : {}".format(tableItem[0], item_text))
+
+        for index, item in enumerate(text_arrays):
+            row = index // 2 + 1  # 计算行号(从1开始计数)
+            col = (index % 2) + 1  # 计算列号(从1开始计数)
+            if col == 1:
+                c_x = 102
+            else:
+                c_x = 635
+            if row == 1:
+                c_y = 40
+            else:
+                c_y = 40 + 105
+            pp_bg = pp_bg.add_text(
+                mode="pixel",
+                value=(c_x, c_y),
+                font=table_font,
+                text=item,
+                align="left",
+                spacing=spacing,
+                fill=(80, 80, 80),
+            )
+        detailed_images.append(pp_bg)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def searchNotEmptyItem(self, current_idx, tableList):
+        idx = current_idx - 1
+        if idx < 0:
+            idx = 0
+        value = self.get_text_value(tableList[idx][0])
+        if idx == 0:
+            return idx
+        if value == "":
+            return self.searchNotEmptyItem(idx, tableList)
+        else:
+            return idx + 1
+
+    def deal_pic_6(self):
+        bg_color = (255, 255, 255)
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\template_7.png".format(self.root))
+        detailed_images.append(pp_bg)
+
+        # ==========添加颜色===================
+        pp_list_1 = []
+        font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 25)
+        goods_art_no_list = list(self.data.keys())
+
+        all_color_name = []
+        for index, goods_art_no in enumerate(goods_art_no_list):
+            pp_jpg = self.get_overlay_pic_from_dict(
+                goods_art_no=goods_art_no,
+                color_name="侧视",
+                bg_color=bg_color,
+            )
+            if pp_jpg is None:
+                continue
+            pp_jpg = pp_jpg.resize(value=440)
+            color_name = self.goods_no_value["货号资料"][index]["颜色名称"]
+            all_color_name.append(color_name)
+            text_bg = PictureProcessing("RGB", (440, 200), bg_color)
+            text_bg = text_bg.get_text_image_advanced(
+                value=(220, 10),
+                font=font,
+                text="{}".format(color_name),
+                align="center",
+                anchor="mm",
+                spacing=5,
+                fill=(55, 55, 55),
+                return_mode="min_image_high",
+                margins=(10, 5, 0, 0)
+            )
+            # text_bg.show()
+            _bg = PictureProcessing("RGB", (440, pp_jpg.height + text_bg.height), bg_color)
+            _bg = _bg.paste_img(top_img=pp_jpg)
+            _bg = _bg.paste_img(top_img=text_bg, value=(0, pp_jpg.height))
+            pp_list_1.append(_bg)
+
+        rows = 2
+        shoes_bg = PictureProcessing().horizontal_distribution(
+            pp_list=pp_list_1,
+            bg_width=1200,
+            margins=(0, 0, 40, 40),
+            line_spacing=60,
+            number_per_row=rows,
+        )
+        detailed_images.append(shoes_bg)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def get_font_render_size(self, text, font):
+        canvas = Image.new("RGB", (2048, 2048))
+        draw = ImageDraw.Draw(canvas)
+        draw.text((0, 0), text, font=font, fill=(55, 55, 55))
+        bbox = canvas.getbbox()
+        # 宽高
+        size = (bbox[2] - bbox[0], bbox[3] - bbox[1])
+        return size
+
+    def deal_pic_7(self):
+        detailed_images = []
+
+        bg_color = (255, 255, 255)
+        goods_art_no_list = list(self.data.keys())
+        pp_bg = PictureProcessing(r"{}\template_8.png".format(self.root))
+        detailed_images.append(pp_bg)
+
+        color_name_1 = ["俯视", "侧视", "内里", "后跟", "鞋底"]
+        color_name_2 = ["俯视", "鞋底"]
+
+        color_name_1 = ["俯视", "侧视", "鞋底"]
+        color_name_2 = ["俯视", "内里", "后跟"]
+
+        for index, goods_art_no in enumerate(goods_art_no_list):
+            if index in [0, 2, 4, 6, 8]:
+                color_name = color_name_1
+            else:
+                color_name = color_name_2
+            for name in color_name:
+                pp_jpg = self.get_overlay_pic_from_dict(
+                    goods_art_no=goods_art_no,
+                    color_name=name,
+                    bg_color=bg_color
+                )
+                if pp_jpg:
+                    if name != "后跟":
+                        pp_jpg = pp_jpg.resize(value=int(pp_bg.width / 1.2))
+                    else:
+                        pp_jpg = pp_jpg.resize(value=int(pp_bg.width / 2.2))
+
+                    pp_jpg = pp_jpg.paste_img_invert(
+                        top_img=PictureProcessing("RGB", (pp_bg.width, pp_jpg.height + 30), bg_color),
+                        base="cc")
+                    detailed_images.append(pp_jpg)
+                    detailed_images.append(PictureProcessing("RGB", (pp_bg.width, 220), bg_color))
+
+        # return PictureProcessing(im=self.add_pic(detailed_images))
+        return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
+
+
+if __name__ == "__main__":
+    import json
+
+    with open(
+            r"D:\MyDocuments\PythonCode\MyPython\red_dragonfly\deal_pics\auto_capture_V2\auto_photo\qt_test\data3.txt",
+            "r",
+            encoding="utf-8",
+    ) as f:
+        data = json.loads(f.read())
+
+    for goods_no, value in data.items():
+        d = DetailPicGetXiaoSuShuoXie2(
+            goods_no,
+            value,
+            out_put_dir=r"D:\MyDocuments\PythonCode\MyPython\red_dragonfly\deal_pics\auto_capture_V2\auto_photo\output\2024-11-19\软件-详情图生成",
+        )
+        raise 1

+ 482 - 0
python/custom_plugins/plugins/detail_template/xiaosushuoxie/detail_xiaosushuoxie3.py

@@ -0,0 +1,482 @@
+"""
+步骤:
+1、整理需要处理的款号图-输出款号图文件夹
+2、整理所有相关的图片作为素材图
+3、按要求进行拼接
+"""
+import os
+import settings
+
+from PIL import ImageFont
+# from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
+# from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
+try:
+    is_test_plugins = settings.is_test_plugins
+except:
+    is_test_plugins = False
+
+if is_test_plugins:
+    from custom_plugins.plugins_mode.detail_generate_base import DetailBase
+    from custom_plugins.plugins_mode.pic_deal import PictureProcessing
+else:
+    from plugins_mode.detail_generate_base import DetailBase
+    from plugins_mode.pic_deal import PictureProcessing
+from PIL import Image, ImageDraw
+
+
+plugins_name = "详情模板"
+company_name_list = ["小苏"]
+template_name = "xiaosushuoxie-3"
+
+
+class DetailPicGet(DetailBase):
+    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
+    root = r"{}\resources\detail_temp\xiaosushuoxie\3".format(os.getcwd())
+
+    def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False,excel_data=None,assigned_page_list=None):
+        super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows,excel_data=excel_data,assigned_page_list=assigned_page_list)
+        self.root = r"{}\resources\detail_temp\xiaosushuoxie\3".format(os.getcwd())
+        self.template_name = template_name
+        self.base_bg_color = (236, 226, 211)
+        self.deal_pic_func_list = [
+            self.deal_pic_1,
+            self.deal_pic_2,
+            self.deal_pic_3,
+            self.deal_pic_4,
+            self.deal_pic_5,
+        ]
+
+        if test:
+            self.run_test()
+        else:
+            self.run_all()
+
+
+    def run_test(self):
+        detailed_images = []
+        detailed_images.append(self.deal_pic_1())
+        detailed_images.append(self.deal_pic_2())
+        detailed_images.append(self.deal_pic_3())
+        detailed_images.append(self.deal_pic_4())
+        detailed_images.append(self.deal_pic_5())
+        img = self.add_pic(detailed_images)
+        img.save(r"{}/{}.jpg".format(self.out_put_dir,self.goods_no, format="JPEG"))
+
+    def deal_pic_1(self):
+        """   制作主图  """
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\template_1.png".format(self.root))
+        detailed_images.append(pp_bg)
+        # -------粘贴文字-------
+        mainTitle = self.get_text_value("标题")
+        subTitle = self.get_text_value("副标题")
+
+        if mainTitle:
+            font = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 70)
+            text_1_bg = PictureProcessing("RGB", (1200, 500), self.base_bg_color)
+            text_1_bg = text_1_bg.get_text_image_advanced(
+                value=(600, 30),
+                font=font,
+                text=mainTitle,
+                align="center",
+                anchor="mm",
+                spacing=5,
+                fill=(17, 16, 16),
+                return_mode="min_image_high",
+                margins=(10, 10, 0, 0)
+            )
+            # text_1_bg.show()
+            detailed_images.append(text_1_bg)
+
+        if subTitle:
+            font = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 40)
+            text_2_bg = PictureProcessing("RGB", (1200, 500), self.base_bg_color)
+            text_2_bg = text_2_bg.get_text_image_advanced(
+                value=(600, 30),
+                font=font,
+                text=subTitle,
+                align="center",
+                anchor="mm",
+                spacing=5,
+                fill=(17, 16, 16),
+                return_mode="min_image_high",
+                margins=(10, 10, 0, 0)
+            )
+            detailed_images.append(text_2_bg)
+
+
+        # ====粘贴组合图以及其他图
+        goods_art_no_list = list(self.data.keys())
+        # 文字排列
+        _zuhe_pic_list = []
+        color_name_list = ["组合", "组合2", "组合3"]
+        for color_name in color_name_list:
+            pp_1 = self.get_overlay_pic_from_dict(
+                goods_art_no=goods_art_no_list[0],
+                color_name=color_name,
+                bg_color=self.base_bg_color,
+            )
+            if not pp_1:
+                continue
+            pp_1 = pp_1.resize(value=int(pp_bg.width / 1.45))
+            pp_1 = pp_1.paste_img_invert(
+                top_img=PictureProcessing("RGB", (pp_bg.width, pp_1.height + 30), self.base_bg_color),
+                base="cc")
+
+            _zuhe_pic_list.append(pp_1)
+
+        if not _zuhe_pic_list:
+            pp_1 = self.get_overlay_pic_from_dict(
+                goods_art_no=goods_art_no_list[0],
+                color_name="俯视",
+                bg_color=self.base_bg_color,
+            )
+            pp_1 = pp_1.resize(value=int(pp_bg.width / 1.45))
+            pp_1 = pp_1.paste_img_invert(top_img=PictureProcessing("RGB", (pp_bg.width, pp_1.height + 30), self.base_bg_color),
+                                         base="cc")
+
+            _zuhe_pic_list.append(pp_1)
+
+        detailed_images.extend(_zuhe_pic_list)
+        detailed_images.append(PictureProcessing(r"{}\template_1_1.png".format(self.root)))
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_2(self):
+        """
+        细节解析
+        """
+        # 文字排列
+        detailed_images = []
+        pp_bg = PictureProcessing(
+            r"{}\template_2.png".format(
+                self.root
+            )
+        )
+        detailed_images.append(pp_bg)
+
+
+        goods_art_no_list = list(self.data.keys())
+
+        pp_1 = self.get_overlay_pic_from_dict(
+            goods_art_no=goods_art_no_list[0],
+            color_name="侧视",
+            bg_color=self.base_bg_color,
+        )
+        pp_1= pp_1.resize(value=pp_bg.width / 1.4)
+        pp_1= pp_1.paste_img_invert(top_img=PictureProcessing("RGB", (pp_bg.width, pp_1.height + 40), self.base_bg_color),
+                                    base="cc"
+                                    )
+        detailed_images.append(pp_1)
+
+        pp_bg_bottom = PictureProcessing(r"{}\template_2_1.png".format(self.root))
+        detailed_images.append(pp_bg_bottom)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_3(self):
+        """   各个颜色细节展示  """
+        detailed_images = []
+        pp_bg = PictureProcessing(
+            r"{}\template_3.png".format(
+                self.root
+            )
+        )
+        detailed_images.append(pp_bg)
+
+
+        # ----------主图放置
+        y = 120
+        pp_list_1 = []
+        font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 25)
+        goods_art_no_list = list(self.data.keys())
+
+        all_color_name = []
+        for index, goods_art_no in enumerate(goods_art_no_list):
+            pp_jpg = self.get_overlay_pic_from_dict(
+                goods_art_no=goods_art_no,
+                color_name="侧视",
+                bg_color=self.base_bg_color,
+            )
+            if pp_jpg is None:
+                continue
+            pp_jpg = pp_jpg.resize(value=440)
+            color_name = self.goods_no_value["货号资料"][index]["颜色名称"]
+            all_color_name.append(color_name)
+            text_bg = PictureProcessing("RGB", (440, 200), (255, 255, 255))
+            text_bg = text_bg.get_text_image_advanced(
+                value=(220, 10),
+                font=font,
+                text="【{}】".format(color_name),
+                align="center",
+                anchor="mm",
+                spacing=5,
+                fill=(55, 55, 55),
+                return_mode="min_image_high",
+                margins=(10, 5, 0, 0)
+            )
+            # text_bg.show()
+            _bg = PictureProcessing("RGB", (440, pp_jpg.height+text_bg.height), (255, 255, 255))
+            _bg = _bg.paste_img(top_img=pp_jpg)
+            _bg = _bg.paste_img(top_img=text_bg,value=(0,pp_jpg.height))
+            pp_list_1.append(_bg)
+
+        rows = 2
+        shoes_bg = PictureProcessing().horizontal_distribution(
+            pp_list=pp_list_1,
+            bg_width=1200,
+            margins=(0, 0, 40, 40),
+            line_spacing=60,
+            number_per_row=rows,
+        )
+        detailed_images.append(shoes_bg)
+
+
+        font_bg = PictureProcessing(r"{}\template_3_1_new.png".format(self.root))
+        font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 30)
+        base_x = pp_bg.width - 229
+        base_y = 205
+
+        text_list = [
+            ("-{}".format("-".join(all_color_name)), (base_x, base_y)),
+            ("-{}".format(self.get_text_value("鞋面材质")), (base_x, base_y+70*1)),
+            ("-{}".format(self.get_text_value("内里材质")), (base_x, base_y+70*2)),
+            ("-{}".format(self.get_text_value("鞋底材质")), (base_x, base_y+70*3)),
+            ("-{}".format(self.get_text_value("鞋垫材质")), (base_x, base_y+70*4 )),
+            ("-{}".format(self.get_text_value("跟高")), (base_x, base_y+70*5)),
+            ("-{}".format(self.get_text_value("尺码")), (base_x, base_y+70*6)),
+        ]
+        for text_item in text_list:
+            position = text_item[1]
+            text_str = text_item[0]
+            xPos = position[0]
+            for char in reversed(text_str):
+                font_bg.add_text(
+                    mode="pixel",
+                    value=(xPos, position[1]),
+                    font=font,
+                    text=char,
+                    align="right",
+                    anchor="mm",
+                    spacing=10,
+                    fill=(30, 30, 30),
+                )
+                if not "\u4e00" <= char <= "\u9fff":
+                    xPos -= 20
+                else:
+                    xPos -= 35
+        # 其他图片
+        detailed_images.append(font_bg)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_4(self):
+        # =============设计理念================
+        detail_images = []
+        top_bg = PictureProcessing(r"{}\template_4.png".format(self.root))
+        detail_images.append(top_bg)
+
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 40)
+        # 粘贴文字
+        text = self.get_text_value("设计理念")
+        if not text:
+            text = "引领全新裸足脚感,开启自信步履亲肤\n优质鞋面材质赋予全新舒适脚感\n多元场景穿搭,满足你的不同STYLE"
+        _, text_height = self.get_font_render_size(text, font_1)
+        text_bg = PictureProcessing(
+            "RGB",
+            (
+                top_bg.width,
+                text_height + 350,
+            ),
+            (236, 227, 212),
+        )
+        goods_art_no_list = list(self.data.keys())
+        # y = 430
+
+        x = top_bg.width / 2
+        text_bg = text_bg.add_text(
+            mode="pixel",
+            value=(x, int(text_bg.height / 2) - 60),
+            font=font_1,
+            text=text,
+            align="center",
+            anchor="mm",
+            spacing=15,
+            fill=(97, 97, 98),
+        )
+        detail_images.append(text_bg)
+
+        # ==========3个提示信息=========
+        title_font = ImageFont.truetype(r"resources\ttf\puhui\Heavy.ttf", 60)
+        sub_title_font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 30)
+        desc_font = ImageFont.truetype(r"resources\ttf\puhui\Heavy.ttf", 35)
+        color_name_list = ["俯视", "内里", "侧视"]
+        # 添加分割线
+        detail_images.append(PictureProcessing("RGB", (top_bg.width, 100), (255, 255, 255)))
+
+        for index, color_name in enumerate(color_name_list):
+            # 添加分割线
+            detail_images.append(PictureProcessing("RGB", (top_bg.width, 20), (255, 255, 255)))
+
+            t_title = self.get_text_value("提示{}主标题".format(index + 1))
+            if t_title:
+                t_title_pp = PictureProcessing("RGB", (top_bg.width, 500), (255, 255, 255))
+                t_title_pp=t_title_pp.get_text_image_advanced(
+                    value=(int(top_bg.width / 2), 0),
+                    font=title_font,
+                    text=t_title,
+                    align="center",
+                    anchor="ma",
+                    spacing=10,
+                    fill=(55, 55, 55),
+                    return_mode="min_image_high",
+                    margins=(10, 10, 0, 0)
+                )
+                detail_images.append(t_title_pp)
+
+
+                t_sub_title = self.get_text_value("提示{}副标题".format(index + 1))
+                if t_sub_title:
+                    t_sub_title_pp = PictureProcessing("RGB", (top_bg.width, 500), (255, 255, 255))
+                    t_sub_title_pp = t_sub_title_pp.get_text_image_advanced(
+                        value=(int(top_bg.width / 2),0),
+                        font=sub_title_font,
+                        text=t_sub_title,
+                        align="center",
+                        anchor="ma",
+                        spacing=10,
+                        fill=(55, 55, 55),
+                        return_mode="min_image_high",
+                        margins=(10, 10, 0, 0)
+                    )
+                    detail_images.append(t_sub_title_pp)
+
+
+            # 添加图
+            pp_jpg = self.get_overlay_pic_from_dict(
+                goods_art_no=goods_art_no_list[0],
+                color_name=color_name,
+                bg_color=self.base_bg_color
+            )
+            t_desc = self.get_text_value("提示{}描述".format(index + 1))
+            if color_name == "俯视":
+                pp_jpg = pp_jpg.resize(value=1300)
+                pp_jpg = pp_jpg.paste_img_invert(
+                    top_img=PictureProcessing("RGB", (749, 1009 if pp_jpg.height>1009 else pp_jpg.height), (236, 227, 212)), base="ws",
+                    value=(-300, -50))
+                text_pos_value = (50, 50)
+                align = "left"
+                anchor = ""
+
+            if color_name == "内里":
+                pp_jpg = pp_jpg.resize(value=2000)
+                pp_jpg = pp_jpg.paste_img_invert(
+                    top_img=PictureProcessing("RGB", (749, pp_jpg.height + 150), (236, 227, 212)), base="wc",
+                    value=(-230, 0))
+                text_pos_value = (50, 50)
+                align = "left"
+                anchor = ""
+
+            if color_name == "侧视":
+                pp_jpg = pp_jpg.resize(value=1600)
+                pp_jpg = pp_jpg.paste_img_invert(
+                    top_img=PictureProcessing("RGB", (749, 1009 if pp_jpg.height>1009 else pp_jpg.height), (236, 227, 212)), base="se",
+                    value=(0, -30))
+                text_pos_value = (pp_jpg.width - 30, pp_jpg.height - 360)
+                align = "right"
+                anchor = "rs"
+
+            if t_desc:
+                pp_jpg = pp_jpg.add_text(
+                    mode="pixel",
+                    value=text_pos_value,
+                    font=desc_font,
+                    text=t_desc,
+                    align=align,
+                    anchor=anchor,
+                    spacing=10,
+                    fill=(102, 102, 102),
+                )
+            pp_jpg = pp_jpg.paste_img_invert(
+                top_img=PictureProcessing("RGB", (top_bg.width, pp_jpg.height,), (255, 255, 255), ), base="cc",
+                value=(0, 0))
+            detail_images.append(pp_jpg)
+            # 添加分割线
+            detail_images.append(PictureProcessing("RGB", (top_bg.width, 60), (255, 255, 255), ))
+
+        # 添加分割线
+        detail_images.append(PictureProcessing("RGB", (top_bg.width, 100), (255, 255, 255), ))
+        image = PictureProcessing(im=self.add_pic(detail_images))
+        return image
+
+    def deal_pic_5(self):
+        bg_color = (255, 255, 255)
+        detailed_images = []
+        goods_art_no_list = list(self.data.keys())
+        top_bg = PictureProcessing(
+            r"{}\template_5.png".format(
+                self.root
+            )
+        )
+
+        detailed_images.append(top_bg)
+        pp_list_1 = []
+        color_name_1 = ["俯视", "侧视", "内里", "后跟", "鞋底"]
+        color_name_2 = ["俯视", "鞋底"]
+
+        color_name_1 = ["俯视", "侧视", "鞋底"]
+        color_name_2 = ["俯视", "内里", "后跟"]
+        n = 0
+        pp_1_height = 100
+
+        for index, goods_art_no in enumerate(goods_art_no_list):
+            if index in [0, 2, 4, 6, 8]:
+                color_name = color_name_1
+            else:
+                color_name = color_name_2
+
+            for name in color_name:
+                pp_1 = self.get_overlay_pic_from_dict(
+                    goods_art_no=goods_art_no,
+                    color_name=name,
+                    bg_color=self.base_bg_color
+                )
+
+                if pp_1:
+                    n += 1
+                    if name != "后跟":
+                        pp_1 = pp_1.resize(value=int(top_bg.width / 1.4))
+                    else:
+                        pp_1 = pp_1.resize(value=int(top_bg.width / 3))
+
+                    if n == 1:
+                        pp_1_height = pp_1.height
+
+                    _height = pp_1.height if pp_1.height > pp_1_height else pp_1_height
+
+                    pp_1 = pp_1.paste_img_invert(base="cc",
+                                                 top_img=PictureProcessing("RGB",
+                                                                           (int(top_bg.width / 1.4), _height + 10,),
+                                                                           self.base_bg_color))
+
+                    pp_1 = pp_1.paste_img_invert(base="cc",
+                                                 top_img=PictureProcessing("RGB",
+                                                                           (top_bg.width, _height + 100,),
+                                                                           (255, 255, 255)))
+
+                    pp_list_1.append(pp_1)
+
+        if pp_list_1:
+            pp_list_1.append(PictureProcessing("RGB", (top_bg.width, 100), bg_color))
+            detailed_images.extend(pp_list_1)
+
+        # return PictureProcessing(im=self.add_pic(detailed_images))
+        return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
+
+
+    def get_font_render_size(self, text, font, canvas_size=(2048, 2048)):
+        canvas = Image.new('RGB', canvas_size)
+        draw = ImageDraw.Draw(canvas)
+        draw.text((0, 0), text, font=font, fill=(55, 55, 55))
+        bbox = canvas.getbbox()
+        # 宽高
+        size = (bbox[2] - bbox[0], bbox[3] - bbox[1])
+        return size
+

+ 459 - 0
python/custom_plugins/plugins/detail_template/xiaosushuoxie/detail_xiaosushuoxie4.py

@@ -0,0 +1,459 @@
+"""
+步骤:
+1、整理需要处理的款号图-输出款号图文件夹
+2、整理所有相关的图片作为素材图
+3、按要求进行拼接
+"""
+import os
+import settings
+
+from PIL import ImageFont
+# from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
+# from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
+is_test_plugins = False
+try:
+    is_test_plugins = settings.is_test_plugins
+except:
+    is_test_plugins = False
+
+if is_test_plugins:
+    from custom_plugins.plugins_mode.detail_generate_base import DetailBase
+    from custom_plugins.plugins_mode.pic_deal import PictureProcessing
+else:
+    from plugins_mode.detail_generate_base import DetailBase
+    from plugins_mode.pic_deal import PictureProcessing
+
+plugins_name = "详情模板"
+company_name_list = ["小苏"]
+template_name = "xiaosushuoxie-4"
+
+
+class DetailPicGet(DetailBase):
+    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
+    root = r"{}\resources\detail_temp\xiaosushuoxie\4".format(os.getcwd())
+
+    def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False, excel_data=None,
+                 assigned_page_list=None):
+        super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows, excel_data=excel_data,
+                         assigned_page_list=assigned_page_list)
+        self.template_name = template_name
+        self.root = r"{}\resources\detail_temp\xiaosushuoxie\4".format(os.getcwd())
+        print("run xiaosushuoxie-4 ")
+        self.base_bg_color = (255, 255, 255)
+        self.deal_pic_func_list = [
+            self.deal_pic_1,
+            self.deal_pic_2,
+            self.deal_pic_3,
+            self.deal_pic_4,
+            self.deal_pic_5,
+            self.deal_pic_6,
+            self.deal_pic_7,
+        ]
+
+        if test:
+            # for k, v in self.goods_no_value.items():
+            #     print(k, v)
+            self.run_test()
+        else:
+            self.run_all()
+
+    def run_test(self):
+        detailed_images = []
+        detailed_images.append(self.deal_pic_1())
+        # detailed_images.append(self.deal_pic_2())
+        # detailed_images.append(self.deal_pic_3())
+        # detailed_images.append(self.deal_pic_4())
+        # detailed_images.append(self.deal_pic_5())
+        # detailed_images.append(self.deal_pic_6())
+        # detailed_images.append(self.deal_pic_7())
+        img = self.add_pic(detailed_images)
+        # img.save(r"{}/{}.jpg".format(self.out_put_dir, self.goods_no, format="JPEG"))
+        img.show()
+
+    # 主图
+    def deal_pic_1(self):
+        """   制作主图  """
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\t (1).png".format(self.root))
+        # 添加分割线
+        # detailed_images.append(PictureProcessing("RGB", (1200, 100), (255, 255, 255)))
+        detailed_images.append(pp_bg)
+        # -------粘贴文字-------
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 56)
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 26)
+        text_list = []
+
+        text_list.append({"text": self.get_text_value("标题"),
+                          "font": font_1,
+                          "fill": (17, 16, 16),
+                          })
+        text_list.append({"text": self.get_text_value("副标题"),
+                          "font": font_2,
+                          "fill": (17, 16, 16),
+                          })
+        text_image = self.add_text_list(text_list, spacing=25, base="nc")
+        if text_image:
+            text_image = text_image.paste_img_invert(
+                top_img=PictureProcessing("RGB", (1200, text_image.height + 100), self.base_bg_color),
+                base="cc",
+                value=(0, 0))
+            detailed_images.append(text_image)
+        # ====粘贴组合图以及其他图
+        goods_art_no_list = list(self.data.keys())
+        # 文字排列
+        _zuhe_pic_list = []
+        color_name_list = ["组合", "组合2", "组合3", "组合4", "组合5"]
+        for color_name in color_name_list:
+            pp_1 = self.get_overlay_pic_from_dict(
+                goods_art_no=goods_art_no_list[0],
+                color_name=color_name,
+                bg_color=self.base_bg_color,
+            )
+            if not pp_1:
+                continue
+            pp_1 = pp_1.resize(value=int(pp_bg.width / 1.45))
+            pp_1 = pp_1.paste_img_invert(
+                top_img=PictureProcessing("RGB", (pp_bg.width, pp_1.height + 30), self.base_bg_color),
+                base="cc")
+            _zuhe_pic_list.append(pp_1)
+            _zuhe_pic_list.append(PictureProcessing("RGB", (pp_bg.width, 150), self.base_bg_color))
+
+        if not _zuhe_pic_list:
+            pp_1 = self.get_overlay_pic_from_dict(
+                goods_art_no=goods_art_no_list[0],
+                color_name="俯视",
+                bg_color=self.base_bg_color,
+            )
+            pp_1 = pp_1.resize(value=int(pp_bg.width / 1.45))
+            pp_1 = pp_1.paste_img_invert(
+                top_img=PictureProcessing("RGB", (pp_bg.width, pp_1.height + 30), self.base_bg_color),
+                base="cc")
+
+            _zuhe_pic_list.append(pp_1)
+
+        detailed_images.extend(_zuhe_pic_list)
+        detailed_images.append(PictureProcessing(r"{}\t (3).png".format(self.root)))
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 商品信息
+    def deal_pic_2(self):
+        """
+        细节解析
+        """
+        # 文字排列
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\t (4).png".format(self.root))
+        detailed_images.append(pp_bg)
+        detailed_images.append(PictureProcessing("RGB", (pp_bg.width, 120), self.base_bg_color))
+
+        goods_art_no_list = list(self.data.keys())
+        pp_bg_2 = PictureProcessing(r"{}\t (26) .png".format(self.root))
+
+        pp_1 = self.get_overlay_pic_from_dict(
+            goods_art_no=goods_art_no_list[0],
+            color_name="侧视",
+            bg_color=self.base_bg_color,
+        )
+        pp_1 = pp_1.resize(value=700)
+        pp_bg_2 = pp_bg_2.paste_img(top_img=pp_1,
+                                    base="sc",
+                                    value=(0, 90)
+                                    )
+        # 粘贴文字
+        font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 26)
+        text_key_list = ["鞋面特点", "跟高", "鞋底特点"]
+        for text_key in text_key_list:
+            text = self.get_text_value(text_key)
+            if not text:
+                continue
+            if text_key == "鞋面特点":
+                value = (131, 380)
+            if text_key == "跟高":
+                value = (935, 187)
+                text = "跟高:{}".format(text)
+            if text_key == "鞋底特点":
+                value = (831, 40)
+            text_image = pp_bg_2.get_text_image_advanced(
+                value=(0, 0),
+                font=font,
+                text=text,
+                spacing=5,
+                fill=(15, 15, 15),
+                return_mode="min_image",
+            )
+            if text_image:
+                pp_bg_2 = pp_bg_2.paste_img(top_img=text_image,
+                                            base="sw",
+                                            value=value
+                                            )
+
+        # 剪裁多余的
+        if pp_bg_2.height > pp_1.height + 90:
+            pp_bg_2 = pp_bg_2.crop(bbox=(0, pp_bg_2.height - 90 - pp_1.height, pp_bg_2.width, pp_bg_2.height))
+
+        detailed_images.append(pp_bg_2)
+
+        font_bg = PictureProcessing(r"{}\t (6).png".format(self.root))
+        # 商品信息文字
+        font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 35)
+        text_list = [
+            ("{}".format(self.get_text_value("品牌")), (294 + 20, 49)),
+            ("{}".format(self.get_text_value("临时款号")), (854 + 20, 49)),
+            ("{}".format(self.get_text_value("鞋面材质")), (294 + 20, 138)),
+            ("{}".format(self.get_text_value("内里材质")), (854 + 20, 138)),
+            ("{}".format(self.get_text_value("鞋垫材质")), (294 + 20, 230)),
+            ("{}".format(self.get_text_value("鞋底材质")), (854 + 20, 230)),
+        ]
+
+        for text_item in text_list:
+            if text_item[0]:
+                font_bg = font_bg.get_text_image_advanced(
+                    value=text_item[1],
+                    font=font,
+                    text=text_item[0],
+                    align="center",
+                    anchor=None,
+                    spacing=5,
+                    fill=(30, 30, 30),
+                    return_mode="image",
+                    margins=(0, 0, 0, 0)
+                )
+
+        # 其他图片
+        detailed_images.append(font_bg)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    def deal_pic_3(self):
+        """   各个颜色细节展示  """
+        detailed_images = []
+        # 添加分割线
+        detailed_images.append(PictureProcessing("RGB", (1200, 100), (255, 255, 255)))
+
+        # 放各个颜色图
+        pp_list_1 = []
+        font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 25)
+        goods_art_no_list = list(self.data.keys())
+
+        for index, goods_art_no in enumerate(goods_art_no_list):
+            pp_jpg = self.get_overlay_pic_from_dict(
+                goods_art_no=goods_art_no,
+                color_name="侧视",
+                bg_color=self.base_bg_color,
+            )
+            if pp_jpg is None:
+                continue
+            pp_jpg = pp_jpg.resize(value=480)
+            color_name = self.goods_no_value["货号资料"][index]["颜色名称"]
+            text_bg = PictureProcessing("RGB", (480, 50), (255, 255, 255))
+            text_bg = text_bg.get_text_image_advanced(
+                value=(480 / 2, 10),
+                font=font,
+                text="{}".format(color_name),
+                align="center",
+                anchor="mm",
+                spacing=5,
+                fill=(55, 55, 55),
+                return_mode="image",
+                margins=(0, 0, 0, 0)
+            )
+            # text_bg.show()
+            _bg = PictureProcessing("RGB", (440, pp_jpg.height + text_bg.height), (255, 255, 255))
+            _bg = _bg.paste_img(top_img=pp_jpg)
+            _bg = _bg.paste_img(top_img=text_bg, value=(0, pp_jpg.height))
+            pp_list_1.append(_bg)
+
+        rows = 2
+        shoes_bg = PictureProcessing().horizontal_distribution(
+            pp_list=pp_list_1,
+            bg_width=1200,
+            margins=(0, 0, 40, 40),
+            line_spacing=60,
+            number_per_row=rows,
+        )
+        detailed_images.append(shoes_bg)
+        # 添加分割线
+        detailed_images.append(PictureProcessing("RGB", (1200, 200), (255, 255, 255)))
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 细节展示
+    def deal_pic_4(self):
+        # =============细节展示================
+        detail_images = []
+        top_bg = PictureProcessing(r"{}\t (8).png".format(self.root))
+        detail_images.append(top_bg)
+
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Heavy.ttf", 120)  # 序号标签
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 36)  # 描述主标题
+        font_3 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 26)  # 描述副标题
+
+        # ==========3个图片描述信息=========
+        goods_art_no_list = list(self.data.keys())
+        color_name_list = ["俯视", "鞋底", "侧视"]
+        for index, color_name in enumerate(color_name_list):
+            # 添加分割线
+            detail_images.append(PictureProcessing("RGB", (top_bg.width, 20), (255, 255, 255)))
+
+            # 添加商品图片
+            pp_jpg = self.get_overlay_pic_from_dict(
+                goods_art_no=goods_art_no_list[0],
+                color_name=color_name,
+                bg_color=self.base_bg_color
+            )
+            if color_name == "俯视":
+                pp_jpg = pp_jpg.resize(value=1565)
+                pp_jpg = pp_jpg.paste_img_invert(
+                    top_img=PictureProcessing("RGB", (1200, 1050), (255, 255, 255)),
+                    base="ws",
+                    value=(104, 0))
+                text_pos_value = (50, 70)
+                text_pos_base = "nw"  # 粘贴文字的位置
+                text_base = "wn"  # 文字方向
+
+            if color_name == "鞋底":
+                pp_jpg = pp_jpg.resize(value=1766)
+                pp_jpg = pp_jpg.transpose(mode="left_right")
+
+                pp_jpg = pp_jpg.paste_img_invert(
+                    top_img=PictureProcessing("RGB", (1200, pp_jpg.height + 150), (255, 255, 255)), base="ec",
+                    value=(275, 0))
+                text_pos_value = (50, 150)
+                text_pos_base = "es"  # 粘贴文字的位置
+                text_base = "en"
+
+            if color_name == "侧视":
+                pp_jpg = pp_jpg.resize(value=1681)
+                pp_jpg = pp_jpg.transpose(mode="left_right")
+                pp_jpg = pp_jpg.paste_img_invert(
+                    top_img=PictureProcessing("RGB", (1200, 843), (255, 255, 255)), base="ws",
+                    value=(216, 0))
+                text_pos_value = (50, 150)
+                text_pos_base = "ws"  # 粘贴文字的位置
+                text_base = "wn"
+
+            text_list = []
+            # 序号
+            text_list.append({"text": "{}".format(index + 1).zfill(2),
+                              "font": font_1,
+                              "fill": (215, 215, 215),
+                              })
+            # 主标题
+            text_list.append({"text": self.get_text_value("提示{}主标题".format(index + 1)),
+                              "font": font_2,
+                              "fill": (55, 55, 55),
+                              })
+            text_list.append({"text": self.get_text_value("提示{}副标题".format(index + 1)),
+                              "font": font_3,
+                              "fill": (55, 55, 55),
+                              })
+
+            text_image = self.add_text_list(text_list, spacing=30, base=text_base)
+            pp_jpg = pp_jpg.paste_img(
+                top_img=text_image,
+                base=text_pos_base,
+                value=text_pos_value, )
+            detail_images.append(pp_jpg)
+            # 添加分割线
+            detail_images.append(PictureProcessing("RGB", (top_bg.width, 60), (255, 255, 255), ))
+
+        # 添加分割线
+        detail_images.append(PictureProcessing("RGB", (top_bg.width, 100), (255, 255, 255), ))
+        image = PictureProcessing(im=self.add_pic(detail_images))
+        return image
+
+    # 添加尺码表
+    def deal_pic_5(self):
+        image_path = r"{}\t (10).png".format(self.root)
+        return PictureProcessing(image_path)
+
+    # 静物展示
+    def deal_pic_6(self):
+        bg_color = (255, 255, 255)
+        detailed_images = []
+        goods_art_no_list = list(self.data.keys())
+        top_bg = PictureProcessing(r"{}\t (11).png".format(self.root))
+
+        detailed_images.append(top_bg)
+        pp_list_1 = []
+        color_name_show_list = []
+        color_name_show_list.append(["组合", "内里", "侧视", "鞋底", "俯视"])
+        color_name_show_list.append(["组合2", "内里", "侧视", "鞋底", "俯视"])
+        color_name_show_list.append(["组合3", "内里", "侧视", "鞋底", "俯视"])
+        color_name_show_list.append(["内里", "侧视", "鞋底", "俯视"])
+
+        color_name_text_show_dict = {
+            "组合": "合并展示 / MERGE",
+            "组合2": "合并展示 / MERGE",
+            "组合3": "合并展示 / MERGE",
+            "内里": "内里展示 / INSIDER",
+            "鞋底": "鞋底展示 / SOLE",
+            "侧视": "后跟展示 / HEELPIECE",
+            "俯视": "45°展示 / 45°",
+        }
+        font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 30)
+        n = 0
+        pp_1_height = 100
+
+        for index, goods_art_no in enumerate(goods_art_no_list):
+            try:
+                color_name = color_name_show_list[index]
+            except:
+                color_name = color_name_show_list[-1]
+
+            for name in color_name:
+                pp_1 = self.get_overlay_pic_from_dict(
+                    goods_art_no=goods_art_no,
+                    color_name=name,
+                    bg_color=self.base_bg_color
+                )
+                if pp_1:
+                    n += 1
+                    if name != "后跟":
+                        pp_1 = pp_1.resize(value=int(top_bg.width / 1.4))
+                    else:
+                        pp_1 = pp_1.resize(value=int(top_bg.width / 3))
+
+                    if n == 1:
+                        pp_1_height = pp_1.height
+
+                    _height = pp_1.height if pp_1.height > pp_1_height else pp_1_height
+                    _height = pp_1.height + 50
+                    # pp_1 = pp_1.paste_img_invert(base="sc",
+                    #                              top_img=PictureProcessing("RGB",
+                    #                                                        (int(top_bg.width / 1.4), _height + 10,),
+                    #                                                        self.base_bg_color))
+                    pp_1 = pp_1.paste_img_invert(base="sc",
+                                                 value=(0, 50),
+                                                 top_img=PictureProcessing("RGB",
+                                                                           (top_bg.width, _height + 100,),
+                                                                           (255, 255, 255)))
+
+                    pp_list_1.append(pp_1)
+                    font_bg = PictureProcessing("RGB", (top_bg.width, 100), (255, 255, 255))
+                    font_bg = font_bg.get_text_image_advanced(
+                        value=(600, 20),
+                        font=font,
+                        text=color_name_text_show_dict[name],
+                        align="center",
+                        anchor="mm",
+                        spacing=5,
+                        fill=(30, 30, 30),
+                        return_mode="image",
+                        margins=(0, 0, 0, 0)
+                    )
+                    pp_list_1.append(font_bg)
+
+        if pp_list_1:
+            pp_list_1.append(PictureProcessing("RGB", (top_bg.width, 100), bg_color))
+            detailed_images.extend(pp_list_1)
+
+        # return PictureProcessing(im=self.add_pic(detailed_images))
+        return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
+
+    # 添加备注图
+    def deal_pic_7(self):
+        image_path = r"{}\t (12).png".format(self.root)
+        return PictureProcessing(image_path)
+
+

+ 603 - 0
python/custom_plugins/plugins/detail_template/xiaosushuoxie/detail_xiaosushuoxie5.py

@@ -0,0 +1,603 @@
+"""
+步骤:
+1、整理需要处理的款号图-输出款号图文件夹
+2、整理所有相关的图片作为素材图
+3、按要求进行拼接
+"""
+import os
+import settings
+
+from PIL import ImageFont
+# from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
+# from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
+is_test_plugins = False
+try:
+    is_test_plugins = settings.is_test_plugins
+except:
+    is_test_plugins = False
+
+if is_test_plugins:
+    from custom_plugins.plugins_mode.detail_generate_base import DetailBase
+    from custom_plugins.plugins_mode.pic_deal import PictureProcessing
+else:
+    from plugins_mode.detail_generate_base import DetailBase
+    from plugins_mode.pic_deal import PictureProcessing
+
+plugins_name = "详情模板"
+company_name_list = ["小苏" ]
+template_name = "xiaosushuoxie-5"
+
+
+class DetailPicGet(DetailBase):
+    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
+    root = r"{}\resources\detail_temp\xiaosushuoxie\5".format(os.getcwd())
+
+    def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False, excel_data=None,assigned_page_list=None):
+        super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows, excel_data=excel_data,assigned_page_list=assigned_page_list)
+        self.template_name = template_name
+
+        self.root = r"{}\resources\detail_temp\xiaosushuoxie\5".format(os.getcwd())
+        print("run xiaosushuoxie-5 ")
+        self.base_bg_color = (255, 255, 255)
+        self.base_bg_color_2 = (244, 242, 243)
+        self.deal_pic_func_list = [
+            self.deal_pic_1,
+            self.deal_pic_2,
+            self.deal_pic_3,
+            self.deal_pic_4,
+            self.deal_pic_5,
+            self.deal_pic_6,
+            self.deal_pic_7,
+            self.deal_pic_8,
+            self.deal_pic_9,
+            self.deal_pic_10,
+            self.deal_pic_11,
+        ]
+
+        if test:
+            # pp = self.generate_font_list_to_pic()
+            # pp.im.save(r"C:\Users\gymmc\Desktop\细节图示例/字号.png")
+            # for k, v in self.goods_no_value.items():
+            #     print(k, v)
+            self.run_test()
+        else:
+            self.run_all()
+
+    def run_test(self):
+        detailed_images = []
+        detailed_images.append(self.deal_pic_1())
+        detailed_images.append(self.deal_pic_2())
+        detailed_images.append(self.deal_pic_3())
+        detailed_images.append(self.deal_pic_4())
+        detailed_images.append(self.deal_pic_5())
+        detailed_images.append(self.deal_pic_6())
+        detailed_images.append(self.deal_pic_7())
+        detailed_images.append(self.deal_pic_8())
+        detailed_images.append(self.deal_pic_9())
+        detailed_images.append(self.deal_pic_10())
+        detailed_images.append(self.deal_pic_11())
+
+        img = self.add_pic(detailed_images)
+        img.save(r"{}/{}.jpg".format(self.out_put_dir,self.goods_no, format="JPEG"))
+        # img.show()
+
+
+    # 标题文字展示
+    def deal_pic_1(self):
+        pp_bg = PictureProcessing(r"{}\t (1).png".format(self.root))
+
+        # -------粘贴文字-------
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 74)  # 设计理念
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 44)  # 描述主标题1
+        font_3 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 44)  # 描述副标题1
+
+        text_list = []
+        text_list.append({"text": self.get_text_value("设计理念"),
+                          "font": font_1,
+                          "fill": (47, 44, 51),
+                          "spacing": 50,
+                          })
+        # 主标题
+        text_list.append({"text": self.get_text_value("标题"),
+                          "font": font_2,
+                          "fill": (124, 91, 24),
+                          })
+        text_list.append({"text": self.get_text_value("副标题"),
+                          "font": font_3,
+                          "fill": (55, 55, 55),
+                          })
+
+        text_image = self.add_text_list(text_list, spacing=15, base="en")
+        if text_image:
+            pp_bg = pp_bg.paste_img(
+                top_img=text_image,
+                base="ne",
+                value=(133, 277))
+
+        return pp_bg
+
+    # 展示鞋头和后跟
+    def deal_pic_2(self):
+        pp_bg = PictureProcessing(r"{}\t (2).png".format(self.root))
+        goods_art_no_list = list(self.data.keys())
+        pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
+                                                goods_art_no=goods_art_no_list[0],
+                                                name="内里",
+                                                )
+        pp_png_1: PictureProcessing
+        pp_png_1 = pp_png_1.resize(value=1187)
+        pp_png_1 = pp_png_1.rotate_advance(doge=90)
+        pp_png_1 = pp_png_1.crop(bbox=(0, 0, pp_png_1.width, 473))
+        pp_bg = pp_bg.paste_img(top_img=pp_png_1,
+                                value=(349 - pp_png_1.width / 2, 342),
+                                base="sw"
+                                )
+
+        pp_jpg_2, pp_png_2 = self.image_one_pic(return_orign=True,
+                                                goods_art_no=goods_art_no_list[0],
+                                                name="后跟",
+                                                )
+        pp_png_2: PictureProcessing
+        pp_png_2 = pp_png_2.resize(value=502)
+        pp_png_2 = pp_png_2.crop(mode="min")
+        pp_png_2 = pp_png_2.crop(bbox=(0, 0, pp_png_2.width, 473))
+
+        pp_bg = pp_bg.paste_img(top_img=pp_png_2,
+                                value=(871 - pp_png_2.width / 2, 342),
+                                base="sw"
+                                )
+
+        # 添加标题文字等
+        # -------粘贴文字-------
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 42)  # 特征标题
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 30)  # 特征描述
+
+        text_list = []
+        # 鞋头特征
+        text_list.append({"text": self.get_text_value("鞋头特征"),
+                          "font": font_1,
+                          "fill": (48, 43, 49),
+                          "spacing": 0,
+                          })
+        # 主标题
+        # 鞋头描述
+        text_list.append({"text": self.get_text_value("鞋头描述"),
+                          "font": font_2,
+                          "fill": (164, 164, 164),
+                          })
+
+        text_image = self.add_text_list(text_list, spacing=15, base="nc")
+        if text_image:
+            pp_bg = pp_bg.paste_img(
+                top_img=text_image,
+                base="nw",
+                value=(349 - text_image.width / 2, 511))
+
+        text_list = []
+        # 后跟特征
+        text_list.append({"text": self.get_text_value("后跟特征"),
+                          "font": font_1,
+                          "fill": (48, 43, 49),
+                          "spacing": 0,
+                          })
+        # 后跟描述
+        text_list.append({"text": self.get_text_value("后跟描述"),
+                          "font": font_2,
+                          "fill": (164, 164, 164),
+                          })
+
+        text_image = self.add_text_list(text_list, spacing=15, base="nc")
+        if text_image:
+            pp_bg = pp_bg.paste_img(
+                top_img=text_image,
+                base="nw",
+                value=(871 - text_image.width / 2, 511))
+
+        return pp_bg
+
+    # 展示鞋头放大图
+    def deal_pic_3(self):
+        pp_bg = PictureProcessing(r"{}\t (3).png".format(self.root))
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 70)  # 设计理念
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 46)  # 描述主标题1
+        font_3 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 44)  # 描述主标题2
+
+        text_list = []
+        # 鞋头特征
+        text_list.append({"text": self.get_text_value("设计理念2"),
+                          "font": font_1,
+                          "fill": (3, 3, 2),
+                          "spacing": 40,
+                          })
+        # 主标题
+        text_list.append({"text": self.get_text_value("提示2主标题"),
+                          "font": font_2,
+                          "fill": (124, 91, 24),
+                          })
+        text_list.append({"text": self.get_text_value("提示2副标题"),
+                          "font": font_3,
+                          "fill": (26, 25, 23),
+                          })
+
+        text_image = self.add_text_list(text_list, spacing=10, base="nw")
+        if text_image:
+            pp_bg = pp_bg.paste_img(
+                top_img=text_image,
+                base="nw",
+                value=(140, 176))
+
+        # 粘贴俯视图
+        goods_art_no_list = list(self.data.keys())
+        pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
+                                                goods_art_no=goods_art_no_list[0],
+                                                name="俯视",
+                                                )
+        pp_png_1: PictureProcessing
+        pp_png_1 = pp_png_1.resize(value=1933)
+        pp_png_1 = pp_png_1.crop(mode="min")
+        pp_bg = pp_bg.paste_img(top_img=pp_png_1,
+                                value=(202, 86),
+                                base="sw"
+                                )
+
+        return pp_bg
+
+    # 展示后跟放大图
+    def deal_pic_4(self):
+        pp_bg = PictureProcessing(r"{}\t (4).png".format(self.root))
+        h = 176
+        # ===========粘贴文字============
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 46)  # 描述主标题1
+        font_3 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 44)  # 描述主标题2
+
+        text_list = []
+        # 鞋头特征
+        # 主标题
+        text_list.append({"text": self.get_text_value("提示3主标题"),
+                          "font": font_2,
+                          "fill": (124, 91, 24),
+                          })
+        text_list.append({"text": self.get_text_value("提示3副标题"),
+                          "font": font_3,
+                          "fill": (26, 25, 23),
+                          })
+
+        text_image = self.add_text_list(text_list, spacing=10, base="ne")
+        if text_image:
+            pp_bg = pp_bg.paste_img(
+                top_img=text_image,
+                base="ne",
+                value=(140, h))
+
+        # 粘贴侧视图
+        goods_art_no_list = list(self.data.keys())
+        pp_jpg, pp_png = self.image_one_pic(return_orign=True,
+                                            goods_art_no=goods_art_no_list[0],
+                                            name="侧视",
+                                            )
+        pp_jpg = pp_jpg.resize(value=2000)
+        pp_png = pp_png.resize(value=2000)
+
+        if text_image:
+            h = h + text_image.height
+        else:
+            h = h
+        pp_bg = pp_bg.to_overlay_pic_advance(mode="pixel", top_img=pp_jpg, base="en", value=(100, h),
+                                             top_png_img=pp_png)
+
+        # 总高
+        h = h + pp_jpg.height + 50
+        if h < pp_bg.height:
+            # 剪裁
+            pp_bg = pp_bg.crop(bbox=(0, 0, 1200, h))
+
+        return pp_bg
+
+    # 展示后跟细节卡片
+    def deal_pic_5(self):
+        pp_bg = PictureProcessing(r"{}\t (5).png".format(self.root))
+
+        # 粘贴侧视图
+        goods_art_no_list = list(self.data.keys())
+        pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
+                                                goods_art_no=goods_art_no_list[0],
+                                                name="侧视",
+                                                )
+        pp_png_1: PictureProcessing
+        pp_png_1 = pp_png_1.resize(value=1621)
+        pp_png_1 = pp_png_1.rotate_advance(doge=45)
+        pp_png_1 = pp_png_1.transpose()
+        pp_png_1 = pp_png_1.crop(mode="min")
+        shoe_bg = PictureProcessing("RGB", (448, 464), self.base_bg_color)
+        shoe_bg = shoe_bg.paste_img(top_img=pp_png_1,
+                                    value=(-80, 200),
+                                    base="wc"
+                                    )
+        shoe_bg = shoe_bg.radius(circular_pos=(0, 0, 1, 0), value=30)
+        pp_bg = pp_bg.paste_img(top_img=shoe_bg,
+                                value=(613, 174),
+                                base="nw")
+        # 添加文字
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 40)  # 设计理念
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 30)  # 描述主标题1
+
+        text_list = []
+        text_list.append({"text": self.get_text_value("提示4主标题"),
+                          "font": font_1,
+                          "fill": (10, 7, 6),
+                          })
+        text_list.append({"text": self.get_text_value("提示4副标题"),
+                          "font": font_2,
+                          "fill": (72, 65, 59),
+                          })
+
+        text_image = self.add_text_list(text_list, spacing=38, base="nw")
+        if text_image:
+            pp_bg = pp_bg.paste_img(
+                top_img=text_image,
+                base="nw",
+                value=(154, 210))
+
+        return pp_bg
+
+    # "心动"设计亮点,展示旋转的侧视图
+    def deal_pic_6(self):
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\t (6).png".format(self.root))
+        # 粘贴侧视图
+        goods_art_no_list = list(self.data.keys())
+        pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
+                                                goods_art_no=goods_art_no_list[0],
+                                                name="侧视",
+                                                )
+        pp_png_1: PictureProcessing
+        pp_png_1 = pp_png_1.resize(value=2050)
+        pp_png_1 = pp_png_1.transpose()
+        pp_png_1 = pp_png_1.rotate_advance(doge=20)
+        pp_png_1 = pp_png_1.crop(mode="min")
+        pp_bg = pp_bg.paste_img(top_img=pp_png_1,
+                                value=(-200, 200),
+                                base="ws"
+                                )
+
+        # ========添加文字==================
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 70)  # 设计理念
+        text = self.get_text_value("设计理念3")
+        pp_bg = pp_bg.get_text_image_advanced(
+            value=(pp_bg.width - 127, pp_bg.height - 43),
+            font=font_1,
+            text=text,
+            anchor="rs",
+            align="right",
+            spacing=5,
+            fill=(109, 107, 109),
+            return_mode="image",
+        )
+        return pp_bg
+
+    # 产品展示,展示大图各个细节
+    def deal_pic_7(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\t (7).png".format(self.root)))
+        goods_art_no_list = list(self.data.keys())
+        goods_art_no = goods_art_no_list[0]
+        # ======展示组合图============
+        pp_1 = self.get_overlay_pic_from_dict(
+            goods_art_no=goods_art_no,
+            color_name="组合",
+            bg_color=self.base_bg_color_2
+        )
+        if pp_1:
+            pp_1 = pp_1.resize(value=1200)
+            pp_1 = pp_1.paste_img_invert(
+                top_img=PictureProcessing("RGB", (1200, pp_1.height + 300), self.base_bg_color_2),
+                base="cc", )
+            detailed_images.append(pp_1)
+
+        # ======展示鞋面===============
+        detailed_images.append(PictureProcessing(r"{}\t (9).png".format(self.root)))
+        pp_2 = self.get_overlay_pic_from_dict(
+            goods_art_no=goods_art_no,
+            color_name="俯视",
+            bg_color=self.base_bg_color_2
+        )
+        pp_2: PictureProcessing
+        pp_2 = pp_2.resize(value=1519)
+        pp_2 = pp_2.paste_img_invert(top_img=PictureProcessing("RGB", (1200, pp_2.height + 50), self.base_bg_color_2),
+                                     base="ws", value=(171, 0))
+        detailed_images.append(pp_2)
+
+        # =======展示后跟=========
+        detailed_images.append(PictureProcessing(r"{}\t (10).png".format(self.root)))
+        pp_3 = self.get_overlay_pic_from_dict(
+            goods_art_no=goods_art_no,
+            color_name="侧视",
+            bg_color=self.base_bg_color_2
+        )
+        pp_3: PictureProcessing
+        pp_3 = pp_3.resize(value=1881)
+        pp_3 = pp_3.paste_img_invert(top_img=PictureProcessing("RGB", (1200, pp_3.height + 200), self.base_bg_color_2),
+                                     base="ec", value=(171, 0))
+        detailed_images.append(pp_3)
+
+        # =========展示鞋底============
+        detailed_images.append(PictureProcessing(r"{}\t (11).png".format(self.root)))
+        pp_jpg_4, pp_png_4 = self.image_one_pic(return_orign=True,
+                                                goods_art_no=goods_art_no,
+                                                name="鞋底",
+                                                )
+        pp_png_4: PictureProcessing
+        pp_png_4 = pp_png_4.resize(value=2380)
+        pp_png_4 = pp_png_4.rotate_advance(doge=45)
+        pp_png_4 = pp_png_4.paste_img_invert(
+            top_img=PictureProcessing("RGB", (1200, pp_png_4.height + 200), self.base_bg_color_2),
+            base="ws", value=(269, 81))
+        detailed_images.append(pp_png_4)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 功能展示与卖点
+    def deal_pic_8(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\t (12).png".format(self.root)))
+        goods_art_no_list = list(self.data.keys())
+        goods_art_no = goods_art_no_list[0]
+        color_name_list = ["侧视", "鞋底", "俯视"]
+
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 42)  # 卖点标题1
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 32)  # 卖点标题2
+        font_3 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 26)  # 卖点描述1
+
+        # =====卖点1,展示后跟========
+        for color_name in color_name_list:
+            bg = PictureProcessing(r"{}\t (13).png".format(self.root))
+            pp_jpg, pp_png = self.image_one_pic(return_orign=True,
+                                                goods_art_no=goods_art_no,
+                                                name=color_name,
+                                                )
+            temp_bg = PictureProcessing("RGB", (536, 424), (214, 214, 214))
+            if color_name == "侧视":
+                pp_png = pp_png.resize(value=990)
+                temp_bg = temp_bg.paste_img(top_img=pp_png, base="es")
+                shoe_paste_base = "wc"
+                text_1, text_2 = self.get_text_value("卖点1标题", subsection_len=2)
+                text_3 = self.get_text_value("卖点1介绍")
+                text_paste_base = "ec"
+                text_paste_value = (312, 0)
+
+            if color_name == "鞋底":
+                pp_png = pp_png.resize(value=1000)
+                temp_bg = temp_bg.paste_img(top_img=pp_png, base="wc", value=(0, 0))
+                shoe_paste_base = "ec"
+                text_1, text_2 = self.get_text_value("卖点2标题", subsection_len=2)
+                text_3 = self.get_text_value("卖点2介绍")
+                text_paste_base = "wc"
+                text_paste_value = (312, 0)
+            if color_name == "俯视":
+                pp_png = pp_png.resize(value=1418)
+                temp_bg = temp_bg.paste_img(top_img=pp_png, base="cc")
+                shoe_paste_base = "wc"
+                text_1, text_2 = self.get_text_value("卖点3标题", subsection_len=2)
+                text_3 = self.get_text_value("卖点3介绍")
+                text_paste_base = "ec"
+                text_paste_value = (312, 0)
+
+            # 添加圆角
+            temp_bg = temp_bg.radius(circular_pos=(1, 1, 1, 1), value=50)
+            # 粘贴到背景上
+            temp_bg = temp_bg.paste_img_invert(top_img=bg, base=shoe_paste_base, value=(99, 0))
+            text_list = []
+            # 卖点主标题
+            text_list.append({"text": text_1,
+                              "font": font_1,
+                              "fill": (2, 2, 2),
+                              "spacing": 0,
+                              })
+            text_list.append({"text": text_2,
+                              "font": font_2,
+                              "fill": (43, 43, 43),
+                              "spacing": 10,
+                              })
+            # 主标题
+            text_list.append({"text": text_3,
+                              "font": font_3,
+                              "fill": (165, 165, 165),
+                              })
+            text_image = self.add_text_list(text_list, spacing=15, base="nc")
+            if text_image:
+                temp_bg = temp_bg.paste_img(
+                    top_img=text_image,
+                    base=text_paste_base,
+                    value=(text_paste_value[0] - text_image.width / 2, text_paste_value[1]))
+            detailed_images.append(temp_bg)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 添加尺码表
+    def deal_pic_9(self):
+        image_path = r"{}\t (16).png".format(self.root)
+        return PictureProcessing(image_path)
+
+    # 角度展示
+    def deal_pic_10(self):
+        detailed_images = []
+        # 角度展示标题
+        detailed_images.append(PictureProcessing(r"{}\t (17).png".format(self.root)))
+        # 添加颜色名称字体
+        font_color = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 30)
+
+        for goods_art_no_dict in self.goods_no_value["货号资料"]:
+            color_name = goods_art_no_dict["颜色名称"]
+            goods_art_no = goods_art_no_dict["货号"]
+            # ====颜色主图
+            pp_1 = self.get_overlay_pic_from_dict(
+                goods_art_no=goods_art_no,
+                color_name="俯视",
+                bg_color=(255, 255, 255)
+            )
+            pp_1: PictureProcessing
+            pp_1 = pp_1.resize(value=865)
+            pp_1 = pp_1.paste_img_invert(top_img=PictureProcessing("RGB", (1152, pp_1.height + 100), (255, 255, 255)),
+                                         base="sc"
+                                         )
+            # 粘贴颜色名称
+            pp_1 = pp_1.get_text_image_advanced(
+                value=(90, 50),
+                font=font_color,
+                text=color_name,
+                spacing=1,
+                return_mode="image",
+            )
+            pp_1 = pp_1.paste_img_invert(top_img=PictureProcessing("RGB", (1200, pp_1.height), (243, 243, 243)),
+                                         base="cc"
+                                         )
+
+            detailed_images.append(pp_1)
+
+            # 添加处理各个角度
+            view_name_list = ["内里", "鞋底", "后跟", "侧视"]
+            color_pic_list = []
+            for view_name in view_name_list:
+                _, pp_png = self.image_one_pic(return_orign=True,
+                                               goods_art_no=goods_art_no,
+                                               name=view_name,
+                                               )
+                temp_bg = PictureProcessing("RGB", (546, 338), (243, 243, 243))
+
+                # if view_name == "内里":
+                #     pp_png = pp_png.resize(base_by_box=(temp_bg.width * 0.9, temp_bg.height * 0.9))
+                # if view_name == "鞋底":
+                #     pp_png = pp_png.resize(base_by_box=(temp_bg.width * 0.9, temp_bg.height * 0.9))
+                # if view_name == "后跟":
+                #     pp_png = pp_png.resize(base_by_box=(temp_bg.width * 0.9, temp_bg.height * 0.9))
+                # if view_name == "侧视":
+                #     pp_png = pp_png.resize(base_by_box=(temp_bg.width * 0.9, temp_bg.height * 0.9))
+
+                pp_png = pp_png.resize(base_by_box=(temp_bg.width * 0.9, temp_bg.height * 0.9))
+
+                temp_bg = temp_bg.paste_img(top_img=pp_png, base="cc")
+                temp_bg = temp_bg.radius(value=30)
+                color_pic_list.append(temp_bg)
+
+            # 颜色列表进行等分展示
+            all_color_pp = PictureProcessing().horizontal_distribution(color_pic_list, bg_width=1114, line_spacing=10,
+                                                                       number_per_row=2)
+            all_color_pp = all_color_pp.paste_img_invert(
+                top_img=PictureProcessing("RGB", (1152, all_color_pp.height + 100), (255, 255, 255)), base="cc")
+            all_color_pp = all_color_pp.paste_img_invert(
+                top_img=PictureProcessing("RGB", (1200, all_color_pp.height), (243, 243, 243)), base="cc")
+            detailed_images.append(all_color_pp)
+
+        # 添加底部圆弧分割线
+        b_bg = PictureProcessing("RGB", (1152, 30), (255, 255, 255))
+        b_bg = b_bg.radius(circular_pos=(0, 0, 1, 1), value=30)
+        b_bg = b_bg.paste_img_invert(top_img=PictureProcessing("RGB", (1200, b_bg.height + 50), (243, 243, 243)),
+                                     base="nc")
+        detailed_images.append(b_bg)
+
+        # return PictureProcessing(im=self.add_pic(detailed_images))
+        return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
+
+    # 添加注意事项
+    def deal_pic_11(self):
+        image_path = r"{}\t (21).png".format(self.root)
+        return PictureProcessing(image_path)

+ 576 - 0
python/custom_plugins/plugins/detail_template/xiaosushuoxie/detail_xiaosushuoxie6.py

@@ -0,0 +1,576 @@
+"""
+步骤:
+1、整理需要处理的款号图-输出款号图文件夹
+2、整理所有相关的图片作为素材图
+3、按要求进行拼接
+"""
+import os
+from PIL import ImageFont
+import sys
+import settings
+
+# from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
+# from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
+is_test_plugins = False
+try:
+    is_test_plugins = settings.is_test_plugins
+except:
+    is_test_plugins = False
+
+if is_test_plugins:
+    from custom_plugins.plugins_mode.detail_generate_base import DetailBase
+    from custom_plugins.plugins_mode.pic_deal import PictureProcessing
+else:
+    from plugins_mode.detail_generate_base import DetailBase
+    from plugins_mode.pic_deal import PictureProcessing
+
+plugins_name = "详情模板"
+company_name_list = ["小苏"]
+template_name = "xiaosushuoxie-6"
+
+
+class DetailPicGet(DetailBase):
+    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
+    root = r"{}\resources\detail_temp\xiaosushuoxie\6".format(os.getcwd())
+
+    def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False, excel_data=None,
+                 assigned_page_list=None):
+
+        super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows, excel_data=excel_data,
+                         assigned_page_list=assigned_page_list)
+        self.root = r"{}\resources\detail_temp\xiaosushuoxie\6".format(os.getcwd())
+        print(template_name)
+        self.template_name = template_name
+        self.base_bg_color = (228, 196, 147)
+        # 缩放倍数
+        self.sf = 16/12
+        self.deal_pic_func_list = [
+            self.deal_pic_1,
+            self.deal_pic_2,
+            self.deal_pic_3,
+            self.deal_pic_4,
+            self.deal_pic_5,
+            self.deal_pic_6,
+            self.deal_pic_7,
+            self.deal_pic_8,
+            self.deal_pic_9,
+        ]
+        # test = True
+        if test:
+            # pp_1 = self.generate_font_list_to_pic()
+            # pp_1.im.save(r"C:\Users\gymmc\Desktop\细节图示例/字号.png")
+            # for k, v in self.goods_no_value.items():
+            #     print(k, v)
+            self.run_test()
+        else:
+            self.run_all()
+
+    def run_test(self):
+        detailed_images = []
+        # detailed_images.append(self.deal_pic_1())
+        # detailed_images.append(self.deal_pic_2())
+        # detailed_images.append(self.deal_pic_3())
+        # detailed_images.append(self.deal_pic_4())
+        # detailed_images.append(self.deal_pic_5())
+        # detailed_images.append(self.deal_pic_6())
+        detailed_images.append(self.deal_pic_7())
+        # detailed_images.append(self.deal_pic_8())
+        # detailed_images.append(self.deal_pic_9())
+        img = self.add_pic(detailed_images)
+        # img.save(r"{}/{}.jpg".format(self.out_put_dir, self.goods_no, format="JPEG"))
+        if img:
+            img.show()
+
+    def deal_details_beifen(self):
+        detailed_images = []
+        self.image_list_append(detailed_images, self.deal_pic_1())
+        self.image_list_append(detailed_images, self.deal_pic_2())
+        self.image_list_append(detailed_images, self.deal_pic_3())
+        self.image_list_append(detailed_images, self.deal_pic_4())
+        self.image_list_append(detailed_images, self.deal_pic_5())
+        self.image_list_append(detailed_images, self.deal_pic_6())
+        self.image_list_append(detailed_images, self.deal_pic_7())
+        self.image_list_append(detailed_images, self.deal_pic_8())
+        self.image_list_append(detailed_images, self.deal_pic_9())
+        return [x for x in detailed_images if x]
+
+    # 组合图1
+    def deal_pic_1(self):
+        pp_bg = PictureProcessing(r"{}\t (1).jpg".format(self.root))
+
+        # -------粘贴文字-------
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 38)  # 设计理念
+        text_list = []
+        text_list.append({"text": self.get_text_value("设计理念"),
+                          "font": font_1,
+                          "fill": (102, 92, 92),
+                          })
+        text_image = self.add_text_list(text_list, spacing=15, base="nw")
+        if text_image:
+            pp_bg = pp_bg.paste_img(
+                top_img=text_image,
+                base="nw",
+                value=(20*self.sf, 895*self.sf))
+
+        # ----粘贴组合图
+        goods_art_no_list = list(self.data.keys())
+        goods_art_no = goods_art_no_list[0]
+        view_list = ["组合", "俯视"]
+        for view_name in view_list:
+            pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
+                                                    goods_art_no=goods_art_no,
+                                                    name=view_name,
+                                                    )
+            if not pp_jpg_1:
+                continue
+            pp_jpg_1: PictureProcessing
+            pp_png_1: PictureProcessing
+            pp_jpg_1 = pp_jpg_1.resize(base_by_box=(485*self.sf, 588*self.sf))
+            pp_png_1 = pp_png_1.resize(base_by_box=(485*self.sf, 588*self.sf))
+            pp_bg = pp_bg.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1,
+                                                 value=(947*self.sf - pp_jpg_1.width / 2, 888*self.sf - pp_jpg_1.height / 2), base="nw")
+            break
+
+        return pp_bg
+
+    # 展示设计理念2和组合2
+    def deal_pic_2(self):
+        pp_bg = PictureProcessing(r"{}\t (2).jpg".format(self.root))
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 38)  # 设计理念
+
+        text_list = []
+        text_list.append({"text": self.get_text_value("设计理念2"),
+                          "font": font_1,
+                          "fill": (109, 103, 97),
+                          })
+        text_image = self.add_text_list(text_list, spacing=15, base="nw")
+        if text_image:
+            pp_bg = pp_bg.paste_img(
+                top_img=text_image,
+                base="nw",
+                value=(60*self.sf, 141*self.sf))
+
+        # ====粘贴组合2或侧视图
+        goods_art_no_list = list(self.data.keys())
+        pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
+                                                goods_art_no=goods_art_no_list[0],
+                                                name="组合2",
+                                                )
+        if not pp_jpg_1:
+            pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
+                                                    goods_art_no=goods_art_no_list[0],
+                                                    name="侧视",
+                                                    )
+        pp_jpg_1: PictureProcessing
+        pp_png_1: PictureProcessing
+        pp_jpg_1 = pp_jpg_1.resize(base_by_box=(546*self.sf, 592*self.sf))
+        pp_png_1 = pp_png_1.resize(base_by_box=(546*self.sf, 592*self.sf))
+
+        pp_bg = pp_bg.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1,
+                                             value=(786*self.sf - pp_jpg_1.width / 2, 816*self.sf - pp_jpg_1.height / 2))
+
+        return pp_bg
+
+    # 亮点解析
+    def deal_pic_3(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\t (3).jpg".format(self.root)))
+        goods_art_no_list = list(self.data.keys())
+
+        # =====添加内里图
+        pp_bg_1 = PictureProcessing(r"{}\t (4).jpg".format(self.root))
+        pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
+                                                goods_art_no=goods_art_no_list[0],
+                                                name="内里",
+                                                )
+        pp_png_1: PictureProcessing
+        pp_png_1 = pp_png_1.resize(value=1600*self.sf)
+        pp_png_1 = pp_png_1.paste_img_invert(top_img=PictureProcessing("RGB", (1200*self.sf, 1061*self.sf), (255, 255, 255)),
+                                             base="ws",
+                                             value=(-85*self.sf, 0))
+
+        # 添加内里描述
+        _neili_bg = PictureProcessing(r"{}\t (25).png".format(self.root))
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 44)  # 内里描述
+        text_list = [{"text": self.get_text_value("内里特点"),
+                      "font": font_1,
+                      "fill": (110, 110, 110),
+                      }]
+        text_image = self.add_text_list(text_list, spacing=10, base="nc")
+        if text_image:
+            _neili_bg = _neili_bg.paste_img(
+                top_img=text_image,
+                base="sc",
+                value=(0, 69*self.sf))
+        pp_bg_1 = pp_bg_1.paste_img(top_img=pp_png_1, base="sc", value=(0, 266*self.sf))
+        pp_bg_1 = pp_bg_1.paste_img(top_img=_neili_bg, base="sc", value=(0, 137*self.sf))
+        detailed_images.append(pp_bg_1)
+
+        # ======添加鞋底图====
+        pp_2 = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
+                                              color_name="鞋底",
+                                              bg_color=(255, 255, 255),
+                                              )
+        pp_2 = pp_2.resize(value=1396*self.sf)
+        pp_bg_2 = PictureProcessing("RGB", (1600, pp_2.height + 80*self.sf), (255, 255, 255))
+        pp_bg_2 = pp_bg_2.paste_img(top_img=pp_2, base="wc", value=(80*self.sf, 0))
+        detailed_images.append(pp_bg_2)
+
+        # --添加鞋底特点
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 40)  # 内里描述
+        text_list = [{"text": self.get_text_value("鞋底特点"),
+                      "font": font_1,
+                      "fill": (110, 110, 110),
+                      }]
+        text_image = self.add_text_list(text_list, spacing=10, base="nc")
+        if text_image:
+            pp_bg_3 = PictureProcessing("RGB", (1600, text_image.height + 80*self.sf), (255, 255, 255))
+            pp_bg_3 = pp_bg_3.paste_img(top_img=text_image, base="cc", value=(0, 0))
+            detailed_images.append(pp_bg_3)
+
+        # ---添加鞋子的俯视图,并标注尺寸----------------
+        pp_bg_4 = PictureProcessing(r"{}\t (6).jpg".format(self.root))
+        pp_4 = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
+                                              color_name="俯视",
+                                              bg_color=(255, 255, 255),
+                                              )
+        pp_4 = pp_4.resize(value=332 * 1.8*self.sf)
+        pp_bg_4 = pp_bg_4.paste_img(top_img=pp_4, base="sc", value=(0, 222*self.sf))
+        # -添加文字描述等
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 34)
+        if self.get_text_value("鞋长"):
+            text = "长:{}".format(self.get_text_value("鞋长"))
+            text_image = pp_bg_4.get_text_image_advanced(font=font_1,
+                                                         text=text,
+                                                         fill=(110, 110, 110),
+                                                         return_mode="min_image")
+            pp_bg_4 = pp_bg_4.paste_img(top_img=text_image, base="sc", value=(0, 134*self.sf))
+        if self.get_text_value("跟高"):
+            text = "跟高:{}".format(self.get_text_value("跟高"))
+            text_image = pp_bg_4.get_text_image_advanced(font=font_1,
+                                                         text=text,
+                                                         fill=(110, 110, 110),
+                                                         return_mode="min_image")
+            pp_bg_4 = pp_bg_4.paste_img(top_img=text_image, base="se", value=(72*self.sf, 404*self.sf))
+        if self.get_text_value("脚掌围"):
+            text = "脚掌围:{}".format(self.get_text_value("脚掌围"))
+            text_image = pp_bg_4.get_text_image_advanced(font=font_1,
+                                                         text=text,
+                                                         fill=(110, 110, 110),
+                                                         return_mode="min_image")
+            pp_bg_4 = pp_bg_4.paste_img(top_img=text_image, base="sw", value=(179*self.sf, 510*self.sf))
+        if pp_bg_4.height > pp_4.height + 250*self.sf:
+            pp_bg_4 = pp_bg_4.crop(bbox=(0, pp_bg_4.height - pp_4.height - 250*self.sf, pp_bg_4.width, pp_bg_4.height))
+
+        detailed_images.append(pp_bg_4)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 展示产品信息和颜色图
+    def deal_pic_4(self):
+        detailed_images = []
+
+        pp_bg_1 = PictureProcessing(r"{}\t (7).jpg".format(self.root))
+
+        # 粘贴产品信息
+        # ---添加组合2图片
+        color_name_list = ["组合2", "组合", "俯视"]
+
+        goods_art_no_list = list(self.data.keys())
+
+        for color_name in color_name_list:
+            pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
+                                                    goods_art_no=goods_art_no_list[0],
+                                                    name=color_name,
+                                                    )
+            if not pp_png_1:
+                continue
+
+            pp_jpg_1: PictureProcessing
+            pp_png_1: PictureProcessing
+
+            pp_jpg_1 = pp_jpg_1.resize(base_by_box=(589*self.sf, 416*self.sf))
+            pp_png_1 = pp_png_1.resize(base_by_box=(589*self.sf, 416*self.sf))
+            pp_bg_1 = pp_bg_1.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1, base="nc", value=(0, 257*self.sf))
+            break
+
+        # ====添加文字信息
+        text_list = [{"title": "帮面材质:", "get_text": "鞋面材质"},
+                     {"title": "鞋型:", "get_text": "鞋型"},
+                     {"title": "内里材质:", "get_text": "内里材质"},
+                     {"title": "头型:", "get_text": "头型"},
+                     {"title": "大底材质:", "get_text": "鞋底材质"},
+                     {"title": "货号:", "get_text": "款号"},
+                     ]
+        x, y = 176*self.sf, 779*self.sf
+        pos_list = [
+            (x, y),
+            (x + 592*self.sf, y),
+            (x, y + 101*self.sf),
+            (x + 592*self.sf, y + 101*self.sf),
+            (x, y + 101*self.sf + 101*self.sf),
+            (x + 592*self.sf, y + 101*self.sf + 101*self.sf),
+        ]
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Regular.ttf", 40)  # 鞋材料信息
+
+        n = -1
+        for text_data in text_list:
+            text_value = self.get_text_value(text_data["get_text"])
+            if text_value:
+                n += 1
+                text = "{}  {}".format(text_data["title"], text_value)
+                text_image = pp_bg_1.get_text_image_advanced(font=font_1,
+                                                             text=text,
+                                                             fill=(0, 0, 0),
+                                                             return_mode="min_image")
+                pp_bg_1 = pp_bg_1.paste_img(top_img=text_image, base="nw", value=pos_list[n])
+
+        detailed_images.append(pp_bg_1)
+        # =======添加各个颜色====多余高度需要剪裁
+        pp_bg_2 = PictureProcessing(r"{}\t (8).jpg".format(self.root))
+
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 34)  # 颜色名称
+        color_pic_list_1 = []
+        color_pic_list_2 = []
+        for goods_art_no_dict in self.goods_no_value["货号资料"]:
+            color_name = goods_art_no_dict["颜色名称"]
+            goods_art_no = goods_art_no_dict["货号"]
+
+            pp_jpg, pp_png = self.image_one_pic(return_orign=True,
+                                                goods_art_no=goods_art_no,
+                                                name="侧视",
+                                                )
+            pp_jpg: PictureProcessing
+            pp_jpg = pp_jpg.resize(value=390*self.sf)
+            pp_png = pp_png.resize(value=390*self.sf)
+
+            pp_jpg = pp_jpg.paste_img_invert(
+                top_img=PictureProcessing("RGBA", (pp_jpg.width, pp_jpg.height + 70*self.sf), (255, 255, 255, 0)),
+                base="nw"
+            )
+            pp_png = pp_png.paste_img_invert(
+                top_img=PictureProcessing("RGBA", (pp_png.width, pp_png.height + 70*self.sf), (255, 255, 255, 0)),
+                base="nw"
+            )
+
+            text_image = pp_bg_2.get_text_image_advanced(font=font_2,
+                                                         text="{} / COLOR".format(color_name),
+                                                         fill=(0, 0, 0),
+                                                         return_mode="min_image")
+
+            pp_jpg = pp_jpg.paste_img(top_img=text_image, base="sc", value=(0, 10*self.sf))
+            color_pic_list_1.append(pp_jpg)
+            color_pic_list_2.append(pp_png)
+
+        # 颜色列表进行等分展示
+        all_color_pp_1 = PictureProcessing().horizontal_distribution(color_pic_list_1, bg_width=1114*self.sf, line_spacing=10,
+                                                                     number_per_row=2)
+        all_color_pp_2 = PictureProcessing().horizontal_distribution(color_pic_list_2, bg_width=1114*self.sf, line_spacing=10,
+                                                                     number_per_row=2)
+
+        pp_bg_2 = pp_bg_2.to_overlay_pic_advance(top_img=all_color_pp_1, top_png_img=all_color_pp_2, base="nc",
+                                                 value=(0, 131*self.sf))
+
+        if pp_bg_2.height > all_color_pp_1.height + 131*self.sf + 50*self.sf:
+            pp_bg_2 = pp_bg_2.crop(
+                bbox=(0, 0, pp_bg_2.width, all_color_pp_1.height + 181*self.sf))
+
+        detailed_images.append(pp_bg_2)
+
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 产品细节
+    def deal_pic_5(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\t (9).jpg".format(self.root)))
+        detailed_images.append(PictureProcessing(r"{}\t (10).jpg".format(self.root)))
+
+        # ==================俯视图鞋头===============
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 64)  # 主标题
+        font_1_color = (1, 1, 1)
+        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 34)  # 副标题
+        font_2_color = (51, 51, 51)
+        goods_art_no_list = list(self.data.keys())
+
+        view_list = ["俯视", "侧视", "内里", "鞋底"]
+        for index, view_name in enumerate(view_list):
+            bg = PictureProcessing(r"{}\t (11).jpg".format(self.root))
+            text_list = []
+            text_list.append({"text": self.get_text_value("提示{}主标题".format(index + 1)),
+                              "font": font_1,
+                              "fill": font_1_color,
+                              })
+            # self.get_text_value("提示{}副标题".format(index + 1))
+            # text = "副标题副标题副标题副标题副标题副标题副标题副标题\n副标题副标题副标题副标题副标题副标题副标题副标题\n副标题\n副标题\n副标题\n副标题\n副标题"
+            text_list.append({"text": self.get_text_value("提示{}副标题".format(index + 1)),
+                              "font": font_2,
+                              "fill": font_2_color,
+                              })
+            text_image = self.add_text_list(text_list, spacing=30, base="nc")
+            if text_image:
+                bg = bg.paste_img(
+                    top_img=text_image,
+                    base="nc",
+                    value=(0, 0))
+                bg = bg.crop(bbox=(0, 0, bg.width, text_image.height + 50*self.sf))
+                detailed_images.append(bg)
+
+            # ===粘贴图片
+            pp_1 = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
+                                                  color_name=view_name,
+                                                  bg_color=(255, 255, 255)
+                                                  )
+
+            if view_name == "俯视":
+                resize_value = 1011*self.sf
+                paste_img_value = (252*self.sf, 0)
+                base = "ws"
+            if view_name == "侧视":
+                resize_value = 1253*self.sf
+                paste_img_value = (270*self.sf, 0)
+                base = "es"
+            if view_name == "内里":
+                resize_value = 1539*self.sf
+                paste_img_value = (0, 0)
+                base = "ws"
+            if view_name == "鞋底":
+                resize_value = 1104*self.sf
+                paste_img_value = (0, 0)
+                base = "cc"
+
+            pp_1 = pp_1.resize(value=resize_value)
+
+            pp_1 = pp_1.paste_img_invert(top_img=PictureProcessing("RGB", (1079*self.sf, 572*self.sf), (255, 255, 255)),
+                                         base=base,
+                                         value=paste_img_value
+                                         )
+
+            bg = PictureProcessing(r"{}\t (11).jpg".format(self.root))
+            bg = bg.paste_img(top_img=pp_1,
+                              base="nc",
+                              value=(0, 0),
+                              )
+            bg = bg.crop(bbox=(0, 0, bg.width, pp_1.height + 10*self.sf))
+            detailed_images.append(bg)
+
+        detailed_images.append(PictureProcessing(r"{}\t (13).jpg".format(self.root)))
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 组合图展示
+    def deal_pic_6(self):
+        flag = False  # 判断是否有组合图
+        detailed_images = []
+        pp_bg_1 = PictureProcessing(r"{}\t (15).jpg".format(self.root))
+        detailed_images.append(pp_bg_1)
+        goods_art_no_list = list(self.data.keys())
+        goods_art_no = goods_art_no_list[0]
+
+        # 组合图1
+        pp_bg_2 = PictureProcessing(r"{}\t (16).jpg".format(self.root))
+        pp_jpg, pp_png = self.image_one_pic(return_orign=True,
+                                            goods_art_no=goods_art_no,
+                                            name="组合",
+                                            )
+        if pp_jpg:
+            flag = True
+            pp_jpg: PictureProcessing
+            pp_jpg = pp_jpg.resize(base_by_box=(910 * 0.9*self.sf, 800 * 0.9*self.sf))
+            pp_png = pp_png.resize(base_by_box=(910 * 0.9*self.sf, 800 * 0.9*self.sf))
+            pp_bg_2 = pp_bg_2.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="cc")
+            detailed_images.append(pp_bg_2)
+
+        # ============组合图2
+        pp_bg_3 = PictureProcessing(r"{}\t (17).jpg".format(self.root))
+        pp_jpg, pp_png = self.image_one_pic(return_orign=True,
+                                            goods_art_no=goods_art_no,
+                                            name="组合2",
+                                            )
+        if pp_jpg:
+            flag = True
+            pp_jpg: PictureProcessing
+            pp_jpg = pp_jpg.resize(base_by_box=(937 * 0.9*self.sf, 827 * 0.9*self.sf))
+            pp_png = pp_png.resize(base_by_box=(937 * 0.9*self.sf, 827 * 0.9*self.sf))
+            pp_bg_3 = pp_bg_3.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="cc")
+            detailed_images.append(pp_bg_3)
+
+        # ==========组合图3
+        pp_bg_4 = PictureProcessing(r"{}\t (18).jpg".format(self.root))
+        detailed_images.append(pp_bg_4)
+        pp_bg_5 = PictureProcessing(r"{}\t (19).jpg".format(self.root))
+        pp_jpg, pp_png = self.image_one_pic(return_orign=True,
+                                            goods_art_no=goods_art_no,
+                                            name="组合3",
+                                            )
+        if pp_jpg:
+            flag = True
+            pp_jpg: PictureProcessing
+            pp_jpg = pp_jpg.resize(base_by_box=(1062*self.sf, 937*self.sf))
+            pp_png = pp_png.resize(base_by_box=(1062*self.sf, 937*self.sf))
+            pp_bg_5 = pp_bg_5.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="cc")
+            detailed_images.append(pp_bg_5)
+
+        if flag:
+            return PictureProcessing(im=self.add_pic(detailed_images))
+        else:
+            return None
+
+    # 各个颜色展示
+    def deal_pic_7(self):
+        detailed_images = []
+
+        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 36)  # 副标题
+        view_list = ["俯视", "侧视", "后跟", "鞋底"]
+        bg_color = (241, 239, 240)
+        for goods_art_no_dict in self.goods_no_value["货号资料"]:
+            print("523   goods_art_no_dict",goods_art_no_dict)
+            bg = PictureProcessing(r"{}\t (20).jpg".format(self.root))
+            # bg.show()
+            color_name = goods_art_no_dict["颜色名称"]
+            goods_art_no = goods_art_no_dict["货号"]
+
+            # 粘贴颜色名称
+            if color_name:
+                text_image = bg.get_text_image_advanced(font=font_1,
+                                                        text="{}".format(color_name),
+                                                        fill=(0, 0, 0),
+                                                        return_mode="min_image")
+                # text_image.show()
+                bg = bg.paste_img(top_img=text_image, base="nw", value=(85*self.sf, 35*self.sf))
+                # bg.show()
+            # 粘贴图片
+            for view_name in view_list:
+                pp = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no,
+                                                    color_name=view_name,
+                                                    bg_color=bg_color,
+                                                    )
+                if view_name == "俯视":
+                    pp = pp.resize(base_by_box=(779 * 0.8*self.sf, 838 * 0.8*self.sf))
+                    pp = pp.paste_img_invert(top_img=PictureProcessing("RGB", (779*self.sf, 836*self.sf), bg_color), base="cc")
+                    bg = bg.paste_img(top_img=pp, value=(38*self.sf, 152*self.sf))
+                if view_name == "侧视":
+                    pp = pp.resize(base_by_box=(321*self.sf, 244*self.sf))
+                    pp = pp.paste_img_invert(top_img=PictureProcessing("RGB", (321*self.sf, 244*self.sf), bg_color), base="cc")
+                    bg = bg.paste_img(top_img=pp, value=(844*self.sf, 152*self.sf))
+
+                if view_name == "后跟":
+                    pp = pp.resize(base_by_box=(321 * 0.7*self.sf, 278 * 0.9*self.sf))
+                    pp = pp.paste_img_invert(top_img=PictureProcessing("RGB", (321*self.sf, 278*self.sf), bg_color), base="cc")
+                    bg = bg.paste_img(top_img=pp, value=(844*self.sf, 417*self.sf))
+                if view_name == "鞋底":
+                    pp = pp.resize(base_by_box=(321*self.sf, 270*self.sf))
+                    pp = pp.paste_img_invert(top_img=PictureProcessing("RGB", (321*self.sf, 270*self.sf), bg_color), base="cc")
+                    bg = bg.paste_img(top_img=pp, value=(844*self.sf, 720*self.sf))
+            detailed_images.append(bg)
+        return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
+
+    # 添加注意事项
+    def deal_pic_8(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\t (22).jpg".format(self.root)))
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 添加注意事项
+    def deal_pic_9(self):
+        detailed_images = []
+        detailed_images.append(PictureProcessing(r"{}\t (23).jpg".format(self.root)))
+        detailed_images.append(PictureProcessing(r"{}\t (24).jpg".format(self.root)))
+        return PictureProcessing(im=self.add_pic(detailed_images))

+ 0 - 0
python/custom_plugins/plugins/generate_and_upload/__init__.py


+ 151 - 0
python/custom_plugins/plugins/generate_and_upload/main_run.py

@@ -0,0 +1,151 @@
+plugins_name = "主图生成与上传"
+from UI.auto_deal_pics_ui.show_process import Ui_Form as show_process_Ui_Form
+from UI.auto_deal_pics_ui.auto_deal_pics_ui import Ui_Form as MainUi
+from UI.auto_deal_pics_ui.matching_photos import Ui_Form as matching_photos_Ui_Form
+
+
+
+
+
+
+from functools import partial
+from module.view_control.MineQWidget import MineQWidget, DialogShow
+
+
+from module.view_control.generate_main_image.grenerate_main_image_test import GeneratePic
+from module.view_control.matching_photos.data import DataModeMatchPhoto
+from collections import defaultdict
+
+
+
+import settings
+from module.view_control.generate_goods_no_detail_pic import detail_func
+import json
+from module.base_mode.base import *
+from import_qt_mode import *
+import threading
+import concurrent.futures
+from module.view_control.generate_goods_no_detail_pic.data import DataModeGenerateDetail, DataModeUploadPic
+from module.view_control.generate_goods_no_detail_pic.detail_func import create_folder
+import time
+from PIL import Image
+from io import BytesIO
+import os, re
+from func_timeout import FunctionTimedOut
+
+is_test_plugins = False
+try:
+    is_test_plugins = settings.is_test_plugins
+except:
+    is_test_plugins = False
+
+if is_test_plugins:
+    from custom_plugins.plugins_mode.plugins_base_func import *
+else:
+    from plugins_mode.plugins_base_func import *
+
+_Type = ['.png', '.PNG', '.jpg', '.JPG', '.gif', '.GIF', ".jpge", ".JPGE"]
+
+
+# 主程序入口
+class AutoDealPics1(MineQWidget):
+
+    def __init__(self, windows=None):
+        super().__init__()
+        self.windows = windows
+        self.ui = MainUi()
+        self.ui.setupUi(self)
+        self.setWindowTitle("图片处理(插件)")
+        self.resize(618, 651)
+        # 线程锁
+        self.lock = Lock()
+        self.init()
+        self.show()
+
+    def init(self):
+        self.show_process = ShowProcess(self)
+        self.ui.main_stackedWidget.addWidget(self.show_process)
+        self.show_process.back_sign.connect(self.to_back)
+        self.show_process.stop_sign.connect(self.to_stop)
+
+        # 匹配图片页面
+        self.show_matching_pic = MatchingPhotos(self)
+        self.ui.main_stackedWidget.addWidget(self.show_matching_pic)
+
+        # 抠图与生成详情页
+        self.show_generate_detail_pic = GenerateDetailPic(self, top_windows=self.windows)
+        self.ui.main_stackedWidget.addWidget(self.show_generate_detail_pic)
+
+        self.show_generate_detail_pic.text_show.connect(self.show_progress_detail)
+        self.show_generate_detail_pic.progress_show_sign.connect(self.switch_to_process_ui)
+        self.show_generate_detail_pic.progress_end_sign.connect(self.end_process)
+
+        # 开始抠图生成主图处理
+        self.show_matching_pic.run_cutout_sign.connect(self.switch_to_detail_ui)
+        self.ui.main_stackedWidget.setCurrentIndex(1)
+
+    def to_back(self, *args):
+        self.switch_to_detail_ui()
+
+    def to_stop(self):
+        self.show_generate_detail_pic.to_stop()
+
+    def switch_to_process_ui(self, flag):
+        if flag:
+            self.show_process.clearn()
+            self.ui.main_stackedWidget.setCurrentIndex(0)
+        else:
+            self.ui.main_stackedWidget.setCurrentIndex(2)
+
+    def end_process(self, *args):
+        self.show_process.is_end()
+
+    def show_progress_detail(self, text):
+        self.show_process.show_progress_detail(text)
+
+    # 页面切换到详情页生成的窗口
+    def switch_to_detail_ui(self, data=None):
+        if data:
+            folder_path = data["folder_path"]
+            self.show_generate_detail_pic.change_img_dir_by_text(folder_path)
+        self.ui.main_stackedWidget.setCurrentIndex(2)
+
+
+class ShowProcess(QWidget):
+    back_sign = Signal()
+    stop_sign = Signal()
+
+    def __init__(self, parent=None, windows=None):
+        super().__init__(parent)
+        self.windows = windows
+        self.ui = show_process_Ui_Form()
+        self.ui.setupUi(self)
+        self.ui.back.clicked.connect(self.back_sign.emit)
+        self.ui.stop.clicked.connect(self.stop_sign.emit)
+        self.ui.progressBar.hide()
+        self.show()
+
+    def show_progress_detail(self, text):
+        self.ui.textBrowser_4.append(text)
+
+    def is_end(self):
+        self.ui.back.show()
+        self.ui.stop.hide()
+
+    def clearn(self):
+        self.ui.progressBar.setValue(0)
+        self.ui.textBrowser_4.clear()
+        self.ui.back.hide()
+        self.ui.stop.show()
+
+
+
+
+
+
+
+
+
+
+
+

+ 0 - 0
python/custom_plugins/plugins/micropython_update/__init__.py


+ 418 - 0
python/custom_plugins/plugins/micropython_update/ampy_plugin.py

@@ -0,0 +1,418 @@
+import json
+import time
+
+if __name__ == '__main__':
+    raise "不允许在当前目录下运行"
+
+import os
+import settings
+from ampy.pyboard import Pyboard
+import ampy.files
+from module.view_control.main_window.data_main import DataMode
+from module.base_mode.base import calculate_sha256, download_file, compare_two_times, get_modified_time
+import concurrent.futures
+
+plugins_name = "AMPY插件"
+
+
+class AmpyScribe(object):
+    def __init__(self, port_name="COM37", baud_rate=115200, windows=None):
+        self.port_name = port_name
+        self.baud_rate = baud_rate
+        self.windows = windows
+        self.pyb = Pyboard(self.port_name, baudrate=self.baud_rate)
+
+    def send_log(self, text):
+        if self.windows:
+            self.windows.send_log(text)
+
+    # 运行本地脚本
+    def run_remote_script(self, script_path):
+        """Run a script on the remote device."""
+        try:
+            self.pyb.enter_raw_repl()
+            result = self.pyb.execfile(script_path)
+            print(result.decode())
+            return result.decode()
+        except Exception as e:
+            print(f"An error occurred while running the script: {e}")
+            return None
+
+    def close(self):
+        if self.pyb is not None:
+            self.pyb.close()
+            self.pyb = None
+
+
+    # 上传文件
+    def upload_file(self, local_path, remote_path, local_path_is_file=True):
+        """
+        local_path:电脑本地路径
+        remote_path:单片机路径,/开头表示根目录
+        """
+        try:
+            if local_path_is_file:
+                # 打开文件并读取内容
+                with open(local_path, 'rb') as file:
+                    content = file.read()
+            else:
+                content = local_path
+
+            # 创建一个 Files 对象用于文件操作
+            files = ampy.files.Files(self.pyb)
+            # 将文件内容写入 MicroPython 设备
+            files.put(remote_path, content)
+        except Exception as e:
+            print(f"An error occurred while upload_file: {e}")
+
+    # 获取远程文件
+    def get_file_from_device(self, remote_filename, local_filename):
+        try:
+            # 创建一个 Files 对象用于文件操作
+            files = ampy.files.Files(self.pyb)
+            # 获取远程文件内容
+            content = files.get(remote_filename)
+            # 将内容写入本地文件
+            with open(local_filename, 'wb') as file:
+                file.write(content)
+            print(f"文件 {remote_filename} 下载成功并保存为 {local_filename}")
+        except Exception as e:
+            print(f"get_file_from_device 发生错误: {e}")
+
+
+# 远程更新脚本
+class RemoteUpdate(object):
+    # instance = None
+    # init_flag = None
+
+    def __init__(self, port_name=None, top_windows=None, windows=None, is_test=False):
+        # if self.init_flag:
+        #     return
+        # else:
+        #     self.init_flag = True
+        self.is_test = is_test
+        self.port_name = port_name
+        self.top_windows = top_windows
+        self.windows = windows
+        self.ampy_scribe = None
+        self.root = os.getcwd()
+        self.value = 0
+        # 基础数据mode
+        self.data_mode = DataMode()
+        self.mcu_code_path = "{}\micropython_online_code\mcu_code".format(os.getcwd())
+
+    def send_log(self, text):
+        print(text)
+        pass
+
+    def show_text_info(self, text):
+        print(text)
+        if self.windows:
+            self.windows.text_info_sign.emit({"text": text})
+
+    def show_progress_bar(self, add_value=None, value=None):
+        if self.windows:
+            if value:
+                self.windows.progress_bar_sign.emit(value)
+            else:
+                self.value += add_value
+                self.windows.progress_bar_sign.emit(self.value)
+
+    def check_windows_state(self):
+        if self.windows:
+            if self.windows.state != 1:
+                self.show_text_info("已取消")
+                raise "主动停止"
+
+    def run(self):
+        """
+        步骤:
+        1、进行设备终止,并连接
+        2、获取远程文件的md5合集
+        3、比对线上合集
+        4、整理差异内容,以及对应文件的has校验码
+        5、下发文件到临时目录
+        6、运行远程更新脚本
+        7、自动重启
+        """
+        self.show_progress_bar(add_value=5)
+        self.show_text_info("开始检查处理,停止MCU")
+        self.stop_mcu()
+        time.sleep(0.5)
+        self.connect_pyboard()
+        if self.ampy_scribe is None:
+            self.show_text_info("串口链接失败,已退出")
+            return
+
+        # 删除远程的临时文件
+        self.show_text_info("开始 删除远程的临时文件")
+        self.remove_remote_files()
+        self.show_progress_bar(add_value=5)
+        self.show_text_info("开始 获取MCU文件的md5合集")
+        # 获取远程文件的md5合集
+        micropython_file_dict = self.get_remote_has()
+        if micropython_file_dict is None:
+            self.show_text_info("获取MCU文件的md5失败")
+            return
+
+        print("==============micropython_file_dict")
+        print(micropython_file_dict)
+
+        # 获取线上的数据
+        self.show_text_info("开始 获取线上的数据")
+        online_files_dict = self.check_resources_download()
+        self.show_progress_bar(add_value=5)
+        if not online_files_dict:
+            self.show_text_info("开始 获取线上的数据  失败")
+            return
+        # 线上数据与单片机文件进行比对
+        print("==============online_files_dict")
+        print(online_files_dict)
+
+        # 生成差异文件
+        self.show_text_info("比对差异文件数据")
+        differential_files_dict = self.get_differential_files(micropython_file_dict=micropython_file_dict,
+                                                              online_files_dict=online_files_dict)
+        print("==============differential_files_dict")
+        print(differential_files_dict)
+        ## 动态创建文件夹路径
+        # self.create_all_folder()
+        if not differential_files_dict:
+            self.show_progress_bar(value=95)
+            self.show_text_info("MCU文件为最新无需更新,开始重启")
+            self.restart()
+            self.show_text_info("开始断开连接")
+            self.ampy_scribe.close()
+            # 尝试连接MCU
+            self.mcu_connect()
+            self.show_text_info("完成")
+            self.show_progress_bar(value=100)
+            return
+        # 移动差异文件
+        self.show_text_info("开始下发差异文件,总数:{}".format(len(differential_files_dict)))
+        to_move_files = self.upload_all_file(differential_files_dict)
+        if not to_move_files:
+            self.show_text_info("下发差异文件失败")
+            return
+
+        # 制作更新脚本
+        self.show_text_info("开始MCU主程序更新")
+        result = self.update_from_temp()
+        if result:
+            if "更新成功" in result:
+                self.show_text_info("更新成功,即将重启")
+                print("单片机程序为最新,5秒后重启")
+                # 重启
+                self.restart()
+                self.show_text_info("开始断开连接")
+                self.ampy_scribe.close()
+                # 尝试连接MCU
+                self.mcu_connect()
+                self.show_progress_bar(value=100)
+                return
+
+    # 制作更新脚本
+    def update_from_temp(self):
+        print("制作更新脚本")
+        path = r"{}\custom_plugins\plugins\micropython_update\other_micropython_code\update_from_temp.py".format(
+            os.getcwd())
+        return self.ampy_scribe.run_remote_script(path)
+
+    # 创建所有文件夹路径
+    def create_all_folder(self):
+        path = r"{}\custom_plugins\plugins\micropython_update\other_micropython_code\create_all_folders.py".format(
+            os.getcwd())
+        self.ampy_scribe.run_remote_script(path)
+        print("创建文件夹路径已完成")
+
+    # 批量移动文件到单片机
+    def upload_all_file(self, files_dict):
+        # k 示例:sensor/other_sensor/nrf24.py    settings.py
+        to_move_files = {}
+        f = True
+        total_s = 100 - self.value - 5
+        total_len = len(files_dict)
+        step = int(total_s / total_len)
+
+        for relative_file_path, value in files_dict.items():
+            local_path = "{}\{}".format(self.mcu_code_path, relative_file_path)
+            # 注意路径格式 / 开头
+            remote_path = r"/temp/{}".format(relative_file_path)
+            print("移动文件", local_path, remote_path)
+            try:
+                self.ampy_scribe.upload_file(local_path, remote_path)
+                # to_move_files[remote_path] = value["file_sha256"]
+                # 使用本地has
+                to_move_files[remote_path] = calculate_sha256(local_path)
+                self.show_text_info("文件:{}下发成功".format(relative_file_path))
+            except BaseException as e:
+                self.show_text_info("文件:{}下发失败:{}".format(relative_file_path, e))
+                f = False
+                return None
+            self.show_progress_bar(add_value=step)
+
+        if f:
+            # 创建配置文件
+            print("创建配置文件")
+            self.show_text_info("创建配置md5文件 并开始下发")
+            _to_move_files_config = json.dumps(to_move_files)
+            self.ampy_scribe.upload_file(local_path=_to_move_files_config,
+                                         remote_path=r"/temp/_to_move_files_config.json", local_path_is_file=False)
+            self.show_text_info("创建配置md5文件 并下发成功")
+        if f:
+            return to_move_files
+        else:
+            return None
+
+    # 生成差异文件
+    def get_differential_files(self, micropython_file_dict: dict, online_files_dict: dict):
+        # 生成差异文件
+        ignore_path = ["machine.py", "boot.py"]  # "main.py"
+        differential_files_dict = {}
+        for online_file_path, value in online_files_dict.items():
+            if online_file_path in ignore_path:
+                continue
+            if online_file_path not in micropython_file_dict:
+                differential_files_dict[online_file_path] = {"file_sha256": value["file_sha256"]}
+                print("文件不存在:{}".format(online_file_path))
+            else:
+                if value["file_sha256"] != micropython_file_dict[online_file_path]["file_sha256"]:
+                    differential_files_dict[online_file_path] = {"file_sha256": value["file_sha256"]}
+                else:
+                    print("文件相同:{}".format(online_file_path))
+
+        return differential_files_dict
+
+    # 删除远程的临时文件
+    def remove_remote_files(self):
+        script_path = r"{}\custom_plugins\plugins\micropython_update\other_micropython_code\delete_all_temp.py".format(
+            self.root)
+        result = self.ampy_scribe.run_remote_script(script_path)
+        print(result)
+
+    def run_run_remote_script_restart(self):
+        script_path = r"{}\custom_plugins\plugins\micropython_update\other_micropython_code\restart.py".format(
+            self.root)
+        self.ampy_scribe.run_remote_script(script_path)
+
+    # 重启单片机
+    def restart(self):
+        try:
+            # 使用上下文管理器确保线程池会正确关闭
+            with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
+                future = executor.submit(self.run_run_remote_script_restart)
+                try:
+                    result = future.result(timeout=1)  # 等待最多5秒
+                except BaseException as e:
+                    print("自动超时")
+                finally:
+                    # 如果需要立即释放资源,可以显式地调用 shutdown。
+                    # 在 with 语句块结束时也会自动调用 shutdown。
+                    # executor.shutdown(wait=False)
+                    print("shutdown")
+            print("-----------end--------------")
+        except BaseException as e:
+            print(e)
+            print("程序遇到了一个致命错误")
+
+    def mcu_connect(self):
+        self.show_text_info("5秒后 尝试连接MCU进行恢复")
+        time.sleep(5)
+        self.top_windows.mcu.to_connect_com(port_name=self.port_name)
+        self.show_progress_bar(value=100)
+
+    # 检查file_sha256 并进行下载更新文件
+    def check_resources_download(self):
+        if self.is_test is False:
+            if not settings.IsLogin:
+                print("当前未登录")
+                return
+        # 请求获取配置文件
+        online_data = self.data_mode.get_all_resource_config(plugins_name="plugins_micropython")
+        # print("check_resources_download")
+        # print(data)
+        if not online_data:
+            text = "check_resources_download  data为空"
+            self.send_log(text)
+        elif "data" not in online_data:
+            text = "check_resources_download  data不存在"
+            self.send_log(text)
+        else:
+            # 步骤:
+            # 1、获取线上数据
+            # 2、如本地MD5不同,但是修改时间比线上的最新,则也不更新下载。
+            for relative_file_path, value in online_data["data"].items():
+                file_path = "{}\{}".format(self.mcu_code_path, relative_file_path)
+                if os.path.exists(file_path):
+                    file_has256 = calculate_sha256(file_path)
+                    if file_has256 != value["file_sha256"]:
+                        file_modified_time = get_modified_time(file_path)
+                        if compare_two_times(file_modified_time, online_data["update_time"]) == "left_new":
+                            continue
+                        else:
+                            text = "has256 不同 开始下载:{}".format(file_path)
+                            self.send_log(text)
+                            download_file(url=value["url"], file_path=file_path)
+                    else:
+                        pass
+                else:
+                    text = "文件不存在 开始下载:{}".format(file_path)
+                    self.send_log(text)
+                    download_file(url=value["url"], file_path=file_path)
+        if online_data:
+            return online_data["data"]
+        return None
+
+    def get_remote_has(self):
+        self.ampy_scribe: AmpyScribe
+        script_path = r"{}\custom_plugins\plugins\micropython_update\other_micropython_code\get_remote_has256.py".format(
+            self.root)
+        result = self.ampy_scribe.run_remote_script(script_path)
+        if result is None:
+            return None
+        has_dict = {}
+        try:
+            result_list = result.split("\n")
+            for i in result_list:
+                if "@" not in i:
+                    continue
+                path, _has = i.split("@")
+                has_dict[path[1:]] = {"file_sha256": _has.replace("\r", "")}
+            return has_dict
+        except BaseException as e:
+            return None
+
+    def stop_mcu(self):
+        if self.is_test:
+            return
+        if self.ampy_scribe is None:
+            self.top_windows.mcu.stop_mcu()
+
+    def connect_pyboard(self):
+        if self.is_test:
+            self.ampy_scribe = AmpyScribe(port_name=self.port_name, windows=None)
+            print("ampy_scribe 接连成功")
+            return
+
+        if self.ampy_scribe is None:
+            if self.port_name:
+                pass
+            else:
+                self.port_name = self.top_windows.mcu.port_name
+
+            print("port_name:", self.port_name)
+            if self.port_name:
+                self.top_windows.mcu.close_connect()
+                time.sleep(3)
+                try:
+                    self.ampy_scribe = AmpyScribe(port_name=self.port_name, windows=None)
+                    print("ampy_scribe 接连成功")
+                except BaseException as e:
+                    print("ampy_scribe 连接失败", e)
+                    self.ampy_scribe = None
+
+    def __new1__(cls, *args, **kwargs):
+        """如果当前没有实例时,调用父类__new__方法,生成示例,有则返回保存的内存地址。"""
+        if not cls.instance:
+            cls.instance = super().__new__(cls)
+        return cls.instance

+ 0 - 0
python/custom_plugins/plugins/micropython_update/other_micropython_code/__init__.py


+ 23 - 0
python/custom_plugins/plugins/micropython_update/other_micropython_code/create_all_folders.py

@@ -0,0 +1,23 @@
+import uos
+
+def mkdir_p(path):
+    """递归创建目录"""
+    try:
+        uos.mkdir(path)
+    except :
+        pass
+
+
+mkdir_p('mode')
+mkdir_p('oled')
+mkdir_p('sensor')
+mkdir_p('sensor/base_mode')
+mkdir_p('sensor/mode')
+mkdir_p('sensor/other_sensor')
+mkdir_p('temp')
+mkdir_p('temp/mode')
+mkdir_p('temp/oled')
+mkdir_p('temp/sensor')
+mkdir_p('temp/sensor/base_mode')
+mkdir_p('temp/sensor/mode')
+mkdir_p('temp/sensor/other_sensor')

+ 50 - 0
python/custom_plugins/plugins/micropython_update/other_micropython_code/delete_all_temp.py

@@ -0,0 +1,50 @@
+import uos
+
+
+def rmdir_recursive(path):
+    """Recursively delete a directory and all its contents."""
+    try:
+        # 列出目录下的所有文件和子目录
+        for entry in uos.ilistdir(path):
+            full_path = path + '/' + entry[0]
+            if entry[1] == 0x4000:  # 目录标志
+                # 如果是子目录,递归调用自身
+                rmdir_recursive(full_path)
+            else:
+                # 如果是文件,则直接删除
+                # print("Deleting file:", full_path)
+                uos.remove(full_path)
+        # 删除空的顶级目录
+        # print("Deleting directory:", path)
+        uos.rmdir(path)
+    except OSError as e:
+        pass
+        # print("Error deleting directory:", path, "Error:", e)
+
+
+def mkdir_p(path):
+    """递归创建目录"""
+    try:
+        uos.mkdir(path)
+    except:
+        pass
+
+
+# 使用函数删除指定目录及其所有内容
+rmdir_recursive('/temp')
+
+mkdir_p('other_config')
+mkdir_p('mode')
+mkdir_p('oled')
+mkdir_p('sensor')
+mkdir_p('sensor/base_mode')
+mkdir_p('sensor/mode')
+mkdir_p('sensor/other_sensor')
+mkdir_p('temp')
+mkdir_p('temp/other_config')
+mkdir_p('temp/mode')
+mkdir_p('temp/oled')
+mkdir_p('temp/sensor')
+mkdir_p('temp/sensor/base_mode')
+mkdir_p('temp/sensor/mode')
+mkdir_p('temp/sensor/other_sensor')

+ 56 - 0
python/custom_plugins/plugins/micropython_update/other_micropython_code/get_remote_has256.py

@@ -0,0 +1,56 @@
+# micropython 中使用
+import time
+import uhashlib
+import uos
+import ubinascii  # 导入用于转换二进制到十六进制字符串的模块
+
+
+def calculate_sha256(filename):
+    h = uhashlib.sha256()
+    with open(filename, 'rb') as f:
+        while True:
+            chunk = f.read(1024)
+            if not chunk:
+                break
+            h.update(chunk)
+
+    # 获取摘要并转换为十六进制字符串
+    hash_bytes = h.digest()  # 获取摘要的二进制形式
+    return ubinascii.hexlify(hash_bytes).decode()  # 将二进制摘要转换为十六进制字符串
+
+
+# 遍历目录
+all_file_data = {}
+
+
+def list_directory(path='.', list_all=False):
+    try:
+        for entry in uos.ilistdir(path):
+            name = entry[0]
+            if name == "__pycache__" or name == "temp":
+                continue
+            type_code = entry[1]
+            if type_code == 0x4000:  # 目录标志位,可能根据实现不同
+                _type = "dir"
+            else:
+                _type = "file"
+            file_path = "{}/{}".format(path, name)
+            # print("_type:{},  {}/{}".format(_type, path, name))
+            all_file_data[file_path] = {"_type": _type,
+                                        "file": name,
+                                        }
+            if _type == "dir":
+                list_directory(file_path, list_all=True)
+    except OSError as e:
+        # print("path", path)
+        # print(f"{path} Error listing directory: {e}")
+        pass
+
+
+# 示例使用
+list_directory('', list_all=True)
+# 执行你想要测量的部分代码
+for k, v in all_file_data.items():
+    if v["_type"] == "file":
+        md5_checksum = calculate_sha256(k)
+        print("{}@{}".format(k, md5_checksum))

+ 24 - 0
python/custom_plugins/plugins/micropython_update/other_micropython_code/restart.py

@@ -0,0 +1,24 @@
+import time
+
+import machine
+from sensor.led import LED
+import uasyncio as asyncio
+from machine import WDT
+
+led = LED(25)
+n = 20
+while n:
+    n -= 1
+    time.sleep(0.05)
+    led.toggle()
+
+wdt = WDT(timeout=500)  # 超时时间单位为毫秒
+# machine.reset()
+
+#
+# # 上传重启脚本
+# ampy --port COM37 put test/reset.py
+
+# # 运行重启脚本
+# ampy --port COM37 run /re_set.py
+# /reset.py

+ 101 - 0
python/custom_plugins/plugins/micropython_update/other_micropython_code/update_from_temp.py

@@ -0,0 +1,101 @@
+import uos
+import json
+import time
+import uhashlib
+import ubinascii  # 导入用于转换二进制到十六进制字符串的模块
+
+
+class Main():
+    def __init__(self):
+        pass
+
+    def get_has256_config(self):
+        try:
+            with open("/temp/_to_move_files_config.json", "rb") as f:
+                data = f.read()
+                data = data.decode("utf-8")
+                data = json.loads(data)
+        except:
+            data = {}
+        return data
+
+    def calculate_sha256(self, path):
+        h = uhashlib.sha256()
+        with open(path, 'rb') as f:
+            while True:
+                chunk = f.read(1024)
+                if not chunk:
+                    break
+                h.update(chunk)
+
+        # 获取摘要并转换为十六进制字符串
+        hash_bytes = h.digest()  # 获取摘要的二进制形式
+        return ubinascii.hexlify(hash_bytes).decode()  # 将二进制摘要转换为十六进制字符串
+
+    def run(self):
+        """
+        步骤:
+        1、检查需要更新的配置文件
+        2、检查文件的md5值
+        3、移动文件到指定目录进行替换
+        """
+        config_data = self.get_has256_config()
+        if not config_data:
+            print("错误")
+            print("config_data 为空或异常")
+            return
+        f = True
+        for file_path, value in config_data.items():
+            _has256 = self.calculate_sha256(file_path)
+            if _has256 != value:
+                print("文件:{} has不一致".format(file_path))
+                f = False
+        if not f:
+            print("错误")
+            return
+        # ============移动文件进行替换
+        for file_path in config_data:
+            src_path = file_path
+            dst_path = file_path.replace("/temp", "")
+            self.move_file(src_path, dst_path)
+        print("更新成功")
+
+    def move_file(self, src_path, dst_path):
+        """Move a file from src_path to dst_path, overwriting if the destination exists."""
+        try:
+            # 检查目标文件是否存在
+            if self.check_exists(dst_path):
+                # print(f"Destination file {dst_path} exists. Removing it...")
+                uos.remove(dst_path)  # 删除目标文件以允许覆盖
+
+            # 复制文件内容
+            with open(src_path, 'rb') as src_file:
+                with open(dst_path, 'wb') as dst_file:
+                    while True:
+                        chunk = src_file.read(1024)  # 分块读取和写入以节省内存
+                        if not chunk:
+                            break
+                        dst_file.write(chunk)
+
+            # print(f"File copied from {src_path} to {dst_path}.")
+
+            # 可选:删除源文件(如果需要移动而非复制)
+            uos.remove(src_path)
+            # print(f"Source file {src_path} removed.")
+        except OSError as e:
+            print("文件移动错误")
+            print("Error moving file:", e)
+
+    def check_exists(self, path):
+        """Check if a file or directory exists."""
+        try:
+            # 尝试获取路径的状态
+            uos.stat(path)
+            return True
+        except OSError:
+            # 如果发生OSError异常,说明路径不存在
+            return False
+
+
+if __name__ == '__main__':
+    Main().run()

+ 0 - 0
python/custom_plugins/plugins_mode/__init__.py


+ 638 - 0
python/custom_plugins/plugins_mode/detail_generate_base.py

@@ -0,0 +1,638 @@
+import settings
+import os
+
+try:
+    is_test_plugins = settings.is_test_plugins
+except:
+    is_test_plugins = False
+
+if is_test_plugins:
+    from custom_plugins.plugins_mode.pic_deal import PictureProcessing
+else:
+    from plugins_mode.pic_deal import PictureProcessing
+
+from PIL import Image
+import shutil
+from service.base import get_images, check_path, get_image_mask
+from natsort import ns, natsorted
+# import math
+from PIL import ImageFont
+import settings
+
+
+class DetailBase(object):
+    def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, excel_data=None,
+                 assigned_page_list=None, output_queue=None):
+        self.goods_no = goods_no
+        self.output_queue = output_queue
+        self.out_put_dir = out_put_dir
+        self.deal_pic_func_list = []
+        self.goods_no_value = goods_no_value
+        self.root = ""
+        self.windows = windows
+        self.template_name = None
+
+        print(goods_no_value)
+        # 重新解析为新的数据结构
+        self.data = {}
+        self.detailed_images = []
+        self.assigned_page_list = assigned_page_list
+        self.overlay_pic_dict = {}
+        self.init()
+        # for goods_art_no_dict in self.goods_no_value["货号资料"]:
+        #     print(goods_art_no_dict)
+        #
+        # raise 1
+
+        if excel_data:
+            ig_keys = ["模板名称"]
+            for k, v in excel_data.items():
+                if k not in ig_keys:
+                    self.goods_no_value[k] = v
+
+    def del_detail_folder(self):
+        out_path = "{out_put_dir}/{goods_no}".format(out_put_dir=self.out_put_dir, goods_no=self.goods_no)
+        if not os.path.exists(out_path):
+            return
+        try:
+            shutil.rmtree(out_path)
+        except BaseException as e:
+            print("删除文件夹失败", e)
+
+    def run_all(self):
+        if self.template_name:
+            self.out_put_dir = "{}/{}".format(self.out_put_dir, self.template_name)
+
+        print("===================detailed_images=================")
+        # 如果没有指定页面,则删除指定目录下的对应的详情文件夹
+        if not self.assigned_page_list:
+            self.del_detail_folder()
+        detailed_images = self.deal_details()
+        self.create_folder(self.out_put_dir)
+        detail_path = "{out_put_dir}/{goods_no}/details".format(out_put_dir=self.out_put_dir, goods_no=self.goods_no)
+        self.create_folder(detail_path)
+        self.save_to_png(detailed_images=detailed_images, detail_path=detail_path)
+        # 生成拼接图
+        self.generate_spliced_picture()
+
+        # ------------移动其他图片---------------------
+        # 获取主图模板列表
+        main_pic_path_list = DetailBase.get_temp_pic_info(root=self.root)["main_pic_path_list"]
+        if not main_pic_path_list:
+            self.move_other_pic(move_main_pic=True)
+        else:
+            self.move_other_pic(move_main_pic=True)
+            if not self.assigned_page_list:
+                self.deal_all_main_pic()
+            else:
+                if "主图" in self.assigned_page_list:
+                    self.deal_all_main_pic()
+        return True
+
+    # 生成各个详情图切片
+    def deal_details(self):
+        detailed_images = []
+        for index, func in enumerate(self.deal_pic_func_list):
+            image_pp = func()
+            if not self.assigned_page_list:
+                self.image_list_append(detailed_images, image_pp)
+            else:
+                index = "{}".format(index + 1)
+                if index in self.assigned_page_list:
+                    self.image_list_append(detailed_images, image_pp)
+                else:
+                    self.image_list_append(detailed_images, {"mes": "不生成"})
+
+        return [x for x in detailed_images if x]
+
+    # 生成拼接的图片
+    def generate_spliced_picture(self):
+        detail_path = "{out_put_dir}/{goods_no}/details".format(out_put_dir=self.out_put_dir, goods_no=self.goods_no)
+        if not os.path.exists(detail_path):
+            return
+        detailed_images = []
+        for image_data in get_images(detail_path):
+            detailed_images.append(PictureProcessing(image_data["file_path"]))
+        # 生成拼接图
+        img = self.add_pic(detailed_images)
+        join_path = "{out_put_dir}/{goods_no}/拼接图".format(out_put_dir=self.out_put_dir, goods_no=self.goods_no)
+        self.create_folder(join_path)
+        img.save("{}/1.jpg".format(join_path), format="JPEG")
+
+    def image_list_append(self, image_list: list, data):
+        self.check_state_end()
+        if isinstance(data, list):
+            image_list.extend(data)
+        else:
+            image_list.append(data)
+
+    def save_to_png(self, detailed_images, detail_path):
+        self.check_state_end()
+        for index, pp in enumerate(detailed_images):
+            if isinstance(pp, dict):
+                continue
+            pp.im.save("{}/{}({}).png".format(detail_path, self.goods_no, str(index + 11).zfill(2)))
+
+    def check_state_end(self):
+        if self.windows is not None:
+            if self.windows.state == 99:
+                raise "用户主动取消"
+
+    @classmethod
+    def get_temp_pic_info(cls, root):
+        """
+        获取详情页模板中的信息
+        """
+        main_pic_list = []
+        mask_pic_list = []
+        if os.path.exists(r"{}\main_image".format(root)):
+            for _name in os.listdir(r"{}\main_image".format(root)):
+                _path = r"{}\main_image\{}".format(root, _name)
+                if os.path.isdir(_path):
+                    main_pic_list.append([x["file_path"] for x in get_images(_path)])
+                    mask_pic_list.append(
+                        [x["file_path"] for x in get_image_mask(_path)]
+                    )
+        _l = get_images(r"{}\show".format(root))
+        temp_pic_path = _l[0]["file_path"] if _l else None
+
+        other_pic_list = [x["file_path"] for x in get_images(r"{}".format(root))]
+        return {
+            "main_pic_path_list": main_pic_list,
+            "temp_pic_path": temp_pic_path,
+            "mask_pic_list": mask_pic_list,
+            "other_pic_path_list": other_pic_list,
+        }
+
+    def init(self):
+        for goods_art_no_value in self.goods_no_value["货号资料"]:
+            self.data[goods_art_no_value["货号"]] = {"pics": goods_art_no_value["pics"],
+                                                   "pic_is_deal": {}
+                                                   }
+
+    def get_text_value(self, key, subsection_len=0):
+        text = ""
+        if key in self.goods_no_value:
+            if self.goods_no_value[key]:
+                text = str(self.goods_no_value[key])
+                text = text.replace(r"\n", "\n")
+
+        if key in ["跟高", "鞋宽", "帮高", "脚掌围", "鞋长"]:
+            if text:
+                text = text.split(".")[0]
+
+        if subsection_len != 0:
+            text = text.split("\n")
+            text = [x for x in text if x]
+            if len(text) == 2:
+                text_1 = text[0]
+                text_2 = text[1]
+                return text_1, text_2
+            else:
+                if text:
+                    text_1 = text[0]
+                else:
+                    text_1 = ""
+                text_2 = ""
+                return text_1, text_2
+
+        return text
+
+    def create_folder(self, path):
+        if not os.path.exists(path):
+            os.makedirs(path)
+
+    def get_all_process_pics(self):
+        """
+        获取所有颜色的过程图片
+        data = [
+            {"货号": "",
+             "素材": [{
+                 "名称": "俯视",
+                 "抠图": "路径1",
+                 "阴影": "路径2"
+             }, ]},
+        ]
+        """
+        return_data = []
+        for goods_art_no in self.data:
+            goods_art_no_dict = {"货号": goods_art_no,
+                                 "素材": [],
+                                 }
+
+            # 图片数据重新排序
+            pic_data = []
+            for pic_name, pic_path in self.data[goods_art_no]["pics"].items():
+                root_path, file_name = os.path.split(pic_path)
+                pic_data.append(file_name)
+
+            pic_data = natsorted(pic_data, alg=ns.PATH)
+
+            for file_name in pic_data:
+                if "阴影" in file_name:
+                    _, action_name, _ = file_name.split("_")
+                    pic_path = self.data[goods_art_no]["pics"]["{}-阴影".format(action_name)]
+                    pic_cutout_path = self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)]
+                    if os.path.exists(pic_path) and os.path.exists(pic_cutout_path):
+                        goods_art_no_dict["素材"].append({"名称": action_name, "抠图": pic_cutout_path, "阴影": pic_path})
+            return_data.append(goods_art_no_dict)
+
+        return return_data
+
+    def get_overlay_pic_from_dict(self, goods_art_no, color_name, bg_color) -> PictureProcessing:
+        self.check_state_end()
+        # 增加逻辑,获取任意货号下的组合图
+        if "组合" in color_name:
+            goods_art_no, color_name = self.get_all_scene_list(goods_art_no, color_name)
+
+        key = "{}-{}-{}".format(goods_art_no, color_name, bg_color)
+        if key in self.overlay_pic_dict:
+            return self.overlay_pic_dict[key]
+
+        if goods_art_no in self.data:
+            for pic_name, pic_path in self.data[goods_art_no]["pics"].items():
+                if "阴影" in pic_name:
+                    action_name = pic_name.replace("-阴影", "")
+                    if action_name == color_name:
+                        pp1 = PictureProcessing(pic_path)
+                        pp2 = PictureProcessing(self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)])
+                        pp1 = pp1.get_overlay_pic(top_img=pp2, color=bg_color).resize(mode="pixel", base="width",
+                                                                                      value=1600)
+                        self.overlay_pic_dict[key] = pp1
+
+        if key in self.overlay_pic_dict:
+            return self.overlay_pic_dict[key]
+
+    def image_init(self, bg_color=(246, 246, 246)):
+        # 制作一批素材图,添加背景色,并保留阴影,以及处理成最小尺寸
+        for goods_art_no in self.data:
+            for pic_name, pic_path in self.data[goods_art_no]["pics"].items():
+                if "阴影" in pic_name:
+                    action_name = pic_name.replace("-阴影", "")
+                    pp1 = PictureProcessing(pic_path)
+                    pp2 = PictureProcessing(self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)])
+                    pp1 = pp1.get_overlay_pic(top_img=pp2, color=bg_color).resize(mode="pixel", base="width",
+                                                                                  value=1600)
+                    self.data[goods_art_no]["pic_is_deal"][action_name] = pp1
+
+    # 获取任意货号的场景图,优先取指定货号;
+    # 调整,按顺序从货号列表中提取所有组合图
+    def get_all_scene_info(self, goods_art_no):
+        data = []
+        # 收集所有组合图
+        # 找任意一个有组合图的货号
+        for goods_art_no_dict in self.goods_no_value["货号资料"]:
+            _goods_art_no = goods_art_no_dict["货号"]
+            _view_name_list = set([x.split("-")[0] for x in goods_art_no_dict["pics"]])
+            for _view_name in _view_name_list:
+                if "组合" not in _view_name:
+                    continue
+                return _goods_art_no
+        return goods_art_no
+
+    def get_all_scene_list(self, goods_art_no, view_name: str):
+        if "组合" == view_name:
+            view_name = "组合1"
+        try:
+            view_index = int(view_name.replace("组合", "")) - 1
+        except:
+            return goods_art_no, "无法匹配"
+
+        data = []
+        # 收集所有组合图
+        # 找任意一个有组合图的货号
+        for goods_art_no_dict in self.goods_no_value["货号资料"]:
+            _goods_art_no = goods_art_no_dict["货号"]
+            _view_name_list = set([x.split("-")[0] for x in goods_art_no_dict["pics"]])
+            for _view_name in _view_name_list:
+                if "组合" not in _view_name:
+                    continue
+                data.append(
+                    {"goods_art_no": _goods_art_no,
+                     "view_name": _view_name
+                     }
+                )
+
+        if len(data) <= view_index:
+            return goods_art_no, "无法匹配"
+        else:
+            return data[view_index]["goods_art_no"], data[view_index]["view_name"]
+
+    def image_one_pic(self, goods_art_no, name, bg_color=None, return_orign=None):
+        # 增加逻辑,获取任意货号下的组合图
+        if "组合" in name:
+            goods_art_no, name = self.get_all_scene_list(goods_art_no, name)
+            print("324 goods_art_no, name", goods_art_no, name)
+
+        # 制作一批素材图,添加背景色,并保留阴影,以及处理成最小尺寸
+        for pic_name, pic_path in self.data[goods_art_no]["pics"].items():
+            if "阴影" in pic_name:
+                action_name = pic_name.replace("-阴影", "")
+                if name != action_name:
+                    continue
+                pp1 = PictureProcessing(pic_path)
+                pp2 = PictureProcessing(self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)])
+                if not return_orign:
+                    pp1 = pp1.get_overlay_pic(top_img=pp2, color=bg_color).resize(mode="pixel", base="width",
+                                                                                  value=1600)
+                    return pp1
+                else:
+                    return pp1, pp2
+
+        if not return_orign:
+            return None
+        else:
+            return None, None
+
+    def move_other_pic(self, move_main_pic=True):
+        # ------------------------------移动其他图片------------------------------
+        goods_no_main_pic_number = 0
+        for goods_art_no_dict in self.goods_no_value["货号资料"]:
+            if "800x800" not in goods_art_no_dict:
+                continue
+            if not goods_art_no_dict["800x800"]:
+                continue
+
+            goods_art_no = ""
+            if "编号" in goods_art_no_dict:
+                if goods_art_no_dict["编号"]:
+                    goods_art_no = goods_art_no_dict["编号"]
+            if not goods_art_no:
+                goods_art_no = goods_art_no_dict["货号"]
+            # print("goods_art_no:", goods_art_no)
+            # 移动颜色图=====================
+            goods_art_no_f = "{}/{}/{}".format(self.out_put_dir, self.goods_no, goods_art_no)
+            self.create_folder(goods_art_no_f)
+            # 放入一张主图
+            old_pic_path_1 = goods_art_no_dict["800x800"][0]
+            shutil.copy(old_pic_path_1,
+                        "{}/{}{}".format(goods_art_no_f, goods_art_no, os.path.splitext(old_pic_path_1)[1]))
+
+            # 把其他主图放入作为款号图=====================
+            if move_main_pic:
+                for pic_path in goods_art_no_dict["800x800"]:
+                    goods_no_main_pic_number += 1
+                    e = os.path.splitext(pic_path)[1]
+                    shutil.copy(pic_path,
+                                "{out_put_dir}/{goods_no}/{goods_no}({goods_no_main_pic_number}){e}".format(
+                                    out_put_dir=self.out_put_dir, goods_no=self.goods_no,
+                                    goods_no_main_pic_number=str(goods_no_main_pic_number + 10).zfill(2),
+                                    e=e))
+
+    def deal_all_main_pic(self):
+        """
+        处理主图模板,如存在出图模板则进行对应处理
+        """
+        # 获取主图模板列表
+        all_main_pic_path_list = DetailBase.get_temp_pic_info(root=self.root)["main_pic_path_list"]
+        if not all_main_pic_path_list:
+            return
+        mask_pic_list = DetailBase.get_temp_pic_info(root=self.root)["mask_pic_list"]
+        data = self.get_all_process_pics()
+        print("========deal_all_main_pic=========主图相关素材:")
+
+        view_list = ["组合", "组合2", "组合3", "组合4", "组合5", "组合6", "俯视", "侧视", "后跟", "鞋底", "内里", ]
+
+        for _index, main_pic_path_list in enumerate(all_main_pic_path_list):
+            self.check_state_end()
+            out_path_root = "{out_put_dir}/{goods_no}/main_image_{_index}".format(
+                out_put_dir=self.out_put_dir,
+                goods_no=self.goods_no,
+                _index=_index
+            )
+            check_path(out_path_root)
+            if mask_pic_list[_index]:
+                mask_pic = mask_pic_list[_index][0]
+            else:
+                mask_pic = None
+            goods_no_main_pic_number = 10
+            # g_index 为第几个颜色货号
+            for g_index, goods_art_no_dict in enumerate(data):
+                goods_art_no = goods_art_no_dict["货号"]
+                # =====================重新指定=================================
+                _material_sort_dict = {}
+                for index, material_dict in enumerate(goods_art_no_dict["素材"]):
+                    name = material_dict["名称"]
+                    _material_sort_dict[name] = material_dict
+
+                # ======================================================
+                file_name_index = -1
+                for view_name in view_list:
+                    # 组合图比较特殊,为全局获取
+                    if g_index != 0:
+                        if "组合" in view_name:
+                            continue
+
+                    if view_name not in _material_sort_dict:
+                        continue
+                    self.check_state_end()
+                    pp_jpg, pp_png = self.image_one_pic(goods_art_no, view_name, bg_color=None, return_orign=True)
+                    if not pp_jpg:
+                        continue
+
+                    file_name_index += 1
+                    # 获取对应主图模板
+                    if len(main_pic_path_list) < file_name_index + 1:
+                        main_pic_path = main_pic_path_list[-1]
+                    else:
+                        main_pic_path = main_pic_path_list[file_name_index]
+                    pp_bg = PictureProcessing(main_pic_path)
+                    original_width = pp_bg.width
+
+                    if original_width != 1600:
+                        pp_bg = pp_bg.resize(value=1600)
+
+                    if mask_pic:
+                        mask_bg = PictureProcessing(mask_pic)
+                        mask_bg = mask_bg.resize(value=1600)
+                        mask_box_im = mask_bg.get_im()
+                        box_size = mask_box_im.getbbox()
+                        result_image = mask_box_im.crop(box_size)
+                        mask_width, mask_height = result_image.size
+                        mask_x, mask_y = box_size[0], box_size[1]
+                    else:
+                        mask_width, mask_height = pp_bg.size
+                        mask_width, mask_height = int(mask_width * 12 / 16), int(mask_height * 12 / 16)
+                        mask_x, mask_y = int((pp_bg.size[0] - mask_width) / 2), int((pp_bg.size[1] - mask_height) / 2)
+
+                    if view_name != "后跟":
+                        pp_jpg = pp_jpg.resize(base_by_box=(mask_width, mask_height))
+                        pp_png = pp_png.resize(base_by_box=(mask_width, mask_height))
+
+                        # 计算粘贴的位置 mask的位置+图片在mask中的位置
+                        p_x = mask_x + int((mask_width - pp_jpg.width) / 2)
+                        p_y = mask_y + int((mask_height - pp_jpg.height) / 2)
+                        pp_bg = pp_bg.to_overlay_pic_advance(mode="pixel", top_img=pp_jpg, base="nw",
+                                                             value=(p_x, p_y), top_png_img=pp_png)
+                    else:
+                        new_mask_width, new_mask_height = int(mask_width / 1.6), int(mask_height / 1.6)
+
+                        pp_jpg = pp_jpg.resize(base_by_box=(new_mask_width, new_mask_height))
+                        pp_png = pp_png.resize(base_by_box=(new_mask_width, new_mask_height))
+                        new_mask_x = int((mask_width - new_mask_width) / 2 + mask_x)
+                        new_mask_y = int((mask_height - new_mask_height) / 2 + mask_y)
+
+                        # 计算粘贴的位置 mask的位置+图片在mask中的位置
+                        p_x = new_mask_x + int((new_mask_width - pp_jpg.width) / 2)
+                        p_y = new_mask_y + int((new_mask_height - pp_jpg.height) / 2)
+
+                        pp_bg = pp_bg.to_overlay_pic_advance(mode="pixel", top_img=pp_jpg, base="nw", value=(p_x, p_y),
+                                                             top_png_img=pp_png)
+
+                    goods_no_main_pic_number += 1
+                    out_pic_path = "{out_path_root}/{goods_no}({goods_no_main_pic_number}){pic_mode}".format(
+                        out_path_root=out_path_root,
+                        goods_no=self.goods_no,
+                        goods_no_main_pic_number=goods_no_main_pic_number,
+                        pic_mode=settings.OUT_PIC_MODE,
+                    )
+
+                    if settings.OUT_PIC_FACTOR > 1.0:
+                        print("图片锐化处理")
+                        pp_bg = pp_bg.sharpen_image(factor=settings.OUT_PIC_FACTOR)
+
+                    if original_width < 1600:
+                        pp_bg = pp_bg.resize(value=original_width)
+
+                    print("392  out_pic_path", out_pic_path)
+                    if settings.OUT_PIC_MODE == ".jpg":
+                        pp_bg.save_as_rgb(out_pic_path)
+                    else:
+                        pp_bg.save_as_png(out_pic_path)
+
+    def add_pic(self, detailed_images):
+        self.check_state_end()
+        todo_detailed_images = []
+        detailed_images = [x for x in detailed_images if x]
+        if not detailed_images:
+            return
+        for i in detailed_images:
+            if isinstance(i, list):
+                for n in i:
+                    todo_detailed_images.append(n)
+            else:
+                todo_detailed_images.append(i)
+
+        page_len = 0
+        for index, pp in enumerate(todo_detailed_images):
+            page_len += pp.height
+        bg_im = Image.new("RGB", (pp.width, page_len), (255, 255, 255))
+        n = 0
+        for index, pp in enumerate(todo_detailed_images):
+            bg_im.paste(pp.im, (0, n))
+            n += pp.height
+        return bg_im
+
+    # 通用方法,用于写文字
+    def add_text_list(self, text_list, spacing=5, base="wn", base_width=1600):
+        text_list = [x for x in text_list if x["text"]]
+        # print(text_list)
+        # spacing 行间距
+        text_image_list = []
+        max_w = 0
+        total_h = 0
+
+        for text_data in text_list:
+            _pp = PictureProcessing("RGBA", (base_width, 1200), (255, 255, 255, 0))
+            if base == "wn" or base == "nw":
+                align = "left"
+                anchor = None
+                value = (0, 250)
+            if base == "cn" or base == "nc":
+                align = "center"
+                anchor = "mm"
+                value = (int(base_width / 2), 250)
+            if base == "en" or base == "ne":
+                align = "right"
+                anchor = "rs"
+                value = (base_width - 10, 250)
+
+            _pp = _pp.get_text_image_advanced(
+                value=value,
+                font=text_data["font"],
+                text=text_data["text"],
+                align=align,
+                anchor=anchor,
+                spacing=5,
+                fill=text_data["fill"],
+                return_mode="min_image",
+                margins=(0, 0, 0, 0)
+            )
+            text_image_list.append(_pp)
+            if _pp.width > max_w:
+                max_w = _pp.width
+
+            total_h += _pp.height
+            if "spacing" in text_data:
+                total_h += text_data["spacing"]
+
+        if not text_image_list:
+            return None
+        #
+        bg = PictureProcessing("RGBA", (max_w, total_h * 3), (0, 0, 0, 0))
+        y = 0
+        for text_image, text_data in zip(text_image_list, text_list):
+            bg = bg.paste_img(top_img=text_image, value=(0, y), base=base)
+            y += spacing + text_image.height
+            if "spacing" in text_data:
+                y += text_data["spacing"]
+
+        bg = bg.crop(mode="min")
+        # _ = bg.paste_img_invert(top_img=PictureProcessing("RGB", (bg.width,bg.height), (255, 255, 255)))
+        # _.show()
+        return bg
+
+    def generate_font_list_to_pic(self):
+        font_path_list = [r"resources\ttf\puhui\Bold.ttf",
+                          r"resources\ttf\puhui\Medium.ttf",
+                          r"resources\ttf\puhui\Heavy.ttf",
+                          r"resources\ttf\puhui\Light.ttf",
+                          r"resources\ttf\puhui\Regular.ttf",
+                          ]
+        text_v_list = [
+            "这是一段话Bold",
+            "这是一段话Medium",
+            "这是一段话Heavy",
+            "这是一段话Light",
+            "这是一段话Regular",
+        ]
+        detailed_images = []
+        for font_path, text in zip(font_path_list, text_v_list):
+            text_list = []
+            for size in range(26, 80, 2):
+                font = ImageFont.truetype(font_path, size)
+                text_list.append({"text": "{}-字号{}".format(text, size),
+                                  "font": font,
+                                  "fill": (110, 110, 110),
+                                  })
+            text_image = self.add_text_list(text_list, spacing=15, base="nw")
+            text_image = text_image.crop(mode="min")
+            text_image = text_image.paste_img_invert(top_img=PictureProcessing("RGB", text_image.size, (255, 255, 255)))
+            detailed_images.append(text_image)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 图片分段,每段至少大于N长度
+    def pp_pic_subsection(self, pp: PictureProcessing, one_height=3200):
+        total_height = pp.height
+        now_height = 0
+        detailed_images = []
+
+        while 1:
+            if now_height + one_height < total_height:
+                h1 = now_height
+                h2 = now_height + one_height
+                bbox = (0, h1, pp.width, h2)
+                # print("bbox1", bbox)
+                detailed_images.append(pp.crop(bbox=bbox))
+                now_height = now_height + one_height
+                continue
+
+            if now_height + one_height >= total_height:
+                h1 = now_height
+                h2 = total_height
+                bbox = (0, h1, pp.width, h2)
+                # print("bbox2", bbox)
+                detailed_images.append(pp.crop(bbox=bbox))
+                break
+
+        return detailed_images

+ 593 - 0
python/custom_plugins/plugins_mode/pic_deal.py

@@ -0,0 +1,593 @@
+import os.path
+
+from PIL import Image, ImageDraw, ImageEnhance
+# import cv2
+import numpy as np
+from blend_modes import multiply
+
+
+class PictureProcessing(object):
+    def __init__(self, *args, **kwargs):
+        self.im: Image
+        if args:
+            p = args[0]
+            if isinstance(p, str):
+                if p == "RGB" or p == "RGBA":
+                    size = int(args[1][0]), int(args[1][1])
+                    self.im = Image.new(args[0], size, args[2])
+                else:
+                    # 设计优先取值处理
+                    _path = args[0]
+                    file_path, file = os.path.split(_path)
+                    custom_path = "{}/custom/{}".format(file_path, file)
+                    if os.path.exists(custom_path):
+                        _path = custom_path
+                    self.im = Image.open(_path)
+
+        elif "im" in kwargs:
+            self.im = kwargs["im"]
+        else:
+            self.im = Image.new(mode="RGB", size=(1600, 500), color=(255, 255, 255))
+
+    def getbbox(self):
+        return self.im.getbbox()
+
+    def expand_bbox(self, bbox, value=100):
+        x1, y1, x2, y2 = bbox[0] - value, bbox[1] - value, bbox[2] + value, bbox[3] + value
+        if x1 < 0:
+            x1 = 0
+        if y1 < 0:
+            y1 = 0
+        bbox = (x1, y1, x2, y2)
+        return [int(x) for x in bbox]
+
+    def show(self):
+        self.im.show()
+
+    def get_size(self):
+        return self.im.size
+
+    def get_im(self):
+        self.im: Image
+        return self.im
+
+    def to_color_2(self, target, blend):  # 正片叠底
+        return np.array(np.multiply(target / 256, blend / 256) * 256, dtype=np.uint8)
+
+    def get_overlay_pic(self, top_img, color=None):
+        # 正片叠底
+        top_img: PictureProcessing
+        image_white = Image.new("RGB", (self.get_size()), color)
+        backdrop_prepped = np.asfarray(image_white.convert('RGBA'))
+        source_prepped = np.asfarray(self.im.convert('RGBA'))
+        blended_np = multiply(backdrop_prepped, source_prepped, 1)
+        img = Image.fromarray(np.uint8(blended_np)).convert('RGB')
+        img.paste(top_img.im, (0, 0), top_img.im)
+        return PictureProcessing(im=img)
+
+    def to_overlay_pic_advance(self, mode="pixel", top_img="", base="nw", value=(0, 0), percentage=(0, 0),
+                               margins=(0, 0, 0, 0), opacity=100, top_png_img=None):
+        # opacity 透明度
+        # 正片叠底
+        _p = PictureProcessing("RGBA", (self.width, self.height), (255, 255, 255, 255))
+        top_img = _p.paste_img(mode=mode,
+                               top_img=top_img,
+                               base=base,
+                               value=value,
+                               percentage=percentage,
+                               margins=margins)
+
+        backdrop_prepped = np.asfarray(self.im.convert('RGBA'))
+        source_prepped = np.asfarray(top_img.im.convert('RGBA'))
+        blended_np = multiply(backdrop_prepped, source_prepped, opacity / 100)
+        im = Image.fromarray(np.uint8(blended_np)).convert('RGB')
+        pp = PictureProcessing(im=im)
+        if top_png_img:
+            pp = pp.paste_img(mode=mode,
+                              top_img=top_png_img,
+                              base=base,
+                              value=value,
+                              percentage=percentage,
+                              margins=margins)
+
+        return pp
+
+    def __to_resize(self, width=None, height=None):
+        _im_x, _im_y = self.get_size()
+        if width and height:
+            if _im_x >= _im_y:
+                high = None
+            else:
+                width = None
+        if width:
+            re_x = int(width)
+            re_y = int(_im_y * re_x / _im_x)
+        else:
+            re_y = int(height)
+            re_x = int(_im_x * re_y / _im_y)
+        img = self.get_im().resize((re_x, re_y))
+        return img
+
+    # 锐化图片
+    def sharpen_image(self, factor=1.0):
+        # 创建一个ImageEnhance对象
+        enhancer = ImageEnhance.Sharpness(self.im)
+        # 应用增强,值为0.0给出模糊图像,1.0给出原始图像,大于1.0给出锐化效果
+        # 调整这个值来增加或减少锐化的程度
+        sharp_img = enhancer.enhance(factor)
+        return PictureProcessing(im=sharp_img)
+
+    @property
+    def width(self):
+        return self.im.width
+
+    @property
+    def height(self):
+        return self.im.height
+
+    @property
+    def size(self):
+        return self.im.size
+
+    def resize(self, mode="pixel", base="width", value=0, base_im=None, percentage=0, base_by_box=None):
+        """
+        plugins_mode # relative相对(宽度、高度、其他参考图),或  pixel绝对像素
+        base # pixel,width,height,by_im 基于长边、基于短边  (基于短边时,则缩放到指定尺寸)by_im确保能塞进参考图内
+        value # 固定值,如果为百分比,则为0
+        percentage #百分比
+        base_im # 参考基于其他图 PictureProcessing 格式
+        """
+
+        # 在箱子内
+        if base_by_box:
+            mode = "relative"
+            base = "by_im"
+            base_by_box = (int(base_by_box[0]), int(base_by_box[1]))
+            base_im = Image.new("RGB", base_by_box, (255, 255, 255))
+
+        # 绝对值
+        if mode == "pixel":
+            if base == "width":
+                img = self.__to_resize(width=value)
+            if base == "high":
+                img = self.__to_resize(height=value)
+
+        # 相对值
+        if mode == "relative":
+            if base == "width":
+                img = self.__to_resize(
+                    width=self.width * percentage if not base_im else int(base_im.width * percentage))
+            if base == "height":
+                img = self.__to_resize(
+                    width=self.height * percentage if not base_im else int(base_im.height * percentage))
+
+            # by_im确保能塞进参考图内
+            if base == "by_im":
+                percentage = 1 if not percentage else percentage
+                box_width, box_height = int(base_im.width * percentage), int(base_im.height * percentage)
+                width, height = self.width, self.height
+                if box_width / box_height < width / height:
+                    scale = box_width / width
+                else:
+                    scale = box_height / height
+                img = self.get_im().resize((int(width * scale), int(height * scale)))
+
+        return PictureProcessing(im=img)
+
+    def paste_img(self, mode="pixel", top_img="", base="nw", value=(0, 0), percentage=(0, 0), margins=(0, 0, 0, 0)):
+        top_img: PictureProcessing
+        """
+        {
+            "command": "paste_img",
+            "im": 需要粘贴的图片
+            "pos": {"plugins_mode": "relative",  # pixel
+                    "base": "center",  # nw,nc,ne,ec ... 各个方向参考点
+                    "value": (100, 100),
+                    "percentage": (0.5, 0.5),
+                    },
+            "margins": (0, 0, 0, 0),  # 上下左右边距
+        }
+        """
+        value = (int(value[0]), int(value[1]))
+        # 处理默认值
+        base = "nw" if not base else base
+        percentage = (0, 0) if not percentage else percentage
+        if margins:
+            top, down, left, right = margins
+        else:
+            top, down, left, right = 0, 0, 0, 0
+
+        if percentage != (0, 0):  # percentage 不按占比模式
+            if base in ("nw", "wn", "wc", "cw", "nc", "cn", "center"):
+                value = (int(self.width), int(self.height))
+            if base in ("sw", "ws", "sc", "cs", "center"):
+                value = (int(self.width), -1 * int(self.height))
+            if base in ("ec", "ce"):
+                value = (int(self.width), int(self.height))
+
+        if mode == "pixel":
+            # 基于右边,上下居中
+            if base == "ec" or base == "ce":
+                p_x = int(self.width - (top_img.width + value[0]))
+                p_y = int((self.height - top_img.height) / 2) + value[1]
+
+            # 基于顶部,左右居中
+            if base == "nc" or base == "cn":
+                # 顶部对齐
+                deviation_x, deviation_y = int((self.width - top_img.width) / 2), int(
+                    (self.height - top_img.height) / 2)
+                p_x = deviation_x + value[0] + left
+                p_y = value[1]
+
+            # 基于右上角
+            if base == "en" or base == "ne":
+                p_x = int(self.width - (top_img.width + value[0])) + left
+                p_y = value[1]
+
+            # 基于左上角
+            if base == "nw" or base == "wn":
+                deviation_x, deviation_y = 0, 0
+                p_x, p_y = value
+
+            # 基于底部,左右居中
+            if base == "cs" or base == "sc":
+                deviation_x, deviation_y = int((self.width - top_img.width) / 2), int(
+                    (self.height - top_img.height) / 2)
+
+                p_y = self.height - (top_img.height + value[1] + down)
+                p_x = deviation_x + value[0] + left
+
+            # 上下左右居中
+            if base == "center" or base == "cc":
+                deviation_x, deviation_y = int((self.width - top_img.width) / 2), int(
+                    (self.height - top_img.height) / 2)
+                p_x = deviation_x + value[0] + left
+                p_y = deviation_y + value[1] + top
+
+            # 基于左下角
+            if base == "sw" or base == "ws":
+                # deviation_x, deviation_y = 0, int((img.height - img_1.height))
+                p_x = value[0] + left
+                p_y = self.height - (top_img.height + value[1] + down)
+
+            # 基于左边,上下居中
+            if base == "wc" or base == "cw":
+                p_x = value[0] + left
+                p_y = int((self.height - top_img.height) / 2) + value[1] + top
+
+            # 基于右下角
+            if base == "es" or base == "se":
+                p_x = int(self.width - (top_img.width + value[0])) + left
+                p_y = self.height - (top_img.height + value[1] + down) + top
+
+            img = PictureProcessing(im=self.im).im
+            # top_img.get_im().show()
+            top_img_im = top_img.im
+            try:
+                img.paste(top_img_im, box=(p_x, p_y), mask=top_img_im.convert("RGBA"))
+            except:
+                img.paste(top_img_im, box=(p_x, p_y), mask=top_img_im)
+
+        return PictureProcessing(im=img)
+
+    def paste_img_invert(self, mode="pixel", top_img="", base="nw", value=(0, 0), percentage=(0, 0),
+                         margins=(0, 0, 0, 0)):
+        top_img: PictureProcessing
+        bg_img = top_img.im
+
+        top_img = PictureProcessing(im=self.im)
+        self.im = bg_img
+        return self.paste_img(mode=mode, top_img=top_img, base=base, value=value, percentage=percentage,
+                              margins=margins)
+
+    # 水平分布处理,一行N个
+    def horizontal_distribution(self, pp_list, bg_width=1200, margins=(0, 0, 0, 0), line_spacing=0, number_per_row=3, ):
+        """
+        pp_list
+        line_spacing:行间距
+        number_per_row:每行个数
+        margins: (0, 0, 0, 0),  # 上下左右边距
+        """
+        bg_width = int(bg_width)
+
+        total_row = len(pp_list) // number_per_row
+        if len(pp_list) % number_per_row > 0:
+            total_row = total_row + 1
+        # print("total_row", total_row)
+        every_height = pp_list[0].height
+        bg_pp = PictureProcessing("RGBA", (
+            bg_width, margins[0] + every_height * total_row + line_spacing * (total_row - 1) + margins[1]),
+                                  (255, 255, 255, 0))
+
+        row_num = 0
+        y = margins[0]
+        for i in range(0, len(pp_list), number_per_row):  # 切片获取每N个元素
+            row_list = pp_list[i:i + number_per_row]  # 输出每行的元素
+            if row_list:
+                row_num += 1
+                # 计算每个元素间距
+                t_w = bg_pp.width - margins[2] - margins[3]
+                al_w = sum([x.width for x in row_list])
+                space = int((t_w - al_w) / (len(row_list) + 1))
+                x = margins[2]
+                # 粘贴每个元素
+                for pp in row_list:
+                    x = x + space
+                    bg_pp = bg_pp.paste_img(mode="pixel", top_img=pp, base="", value=(x, y))
+                    x = x + pp.width
+
+                if row_num != total_row:
+                    y += (every_height + line_spacing)
+        return bg_pp
+
+    def get_text_image_advanced(self, value=(0, 0), font="", text="", anchor=None, align="left", spacing=0,
+                                fill=(0, 0, 0),
+                                return_mode="image", margins=(0, 0, 0, 0)):
+        """
+        {
+            "command": "add_text",
+            "pos": {"plugins_mode": "relative",  # pixel
+                    "base": "center",  # nw,nc,ne,ec ... 各个方向参考点
+                    "value": (100, 100),
+                    "percentage": 0, },
+            "font": "",
+            "text": "",
+            "anchor": "",  # mm 为居中 ma 为左右居中,上面居顶 rs 右边;从哪边开始输入
+            "align": "对齐方式",left  center right
+            "direction": "文本的方向",
+            "max_len_one_line": "单行长度",
+            "spacing": 10,
+            "fill": "文字颜色",
+        }
+        margins 边距像素,上下左右;只有返回min_image_high 有效
+        """
+
+        # =====
+        """
+        return_mode:image返回图片,min_image_high返回最小高度尺寸但宽度不变,min_image返回最小高度与宽度
+        """
+        if not text:
+            return self
+        # pp = PictureProcessing("RGBA", self.size, (0, 0, 0, 0))
+        pp = PictureProcessing("RGBA", self.size, (255, 255, 255, 0))
+        draw_1 = ImageDraw.Draw(pp.im)
+        # 定义字体,你需要有一个.ttf字体文件
+        spacing = 4 if not spacing else spacing
+        align = "left" if not align else align  # left, center 或 right
+
+        _, _, text_width, text_height = draw_1.textbbox((0, 0), text, font=font)
+        value = (int(value[0]), int(value[1]))
+
+        draw_1.multiline_text((value[0], value[1] + margins[0]), text,
+                              fill=fill,
+                              font=font,
+                              anchor=anchor,
+                              spacing=spacing,
+                              align=align,
+                              direction=None,
+                              features=None,
+                              language=None,
+                              stroke_width=0,
+                              stroke_fill=None,
+                              embedded_color=False)
+
+        if return_mode == "image":
+            pp = pp.paste_img_invert(mode="pixel", top_img=self, base="nw", value=(0, 0))
+            pass
+        if return_mode == "min_image_high":
+            # pp.show()
+            bbox = pp.getbbox()
+            bbox = (0, 0, pp.width, bbox[3] + margins[1])
+            pp = pp.paste_img_invert(mode="pixel", top_img=self, base="nw", value=(0, 0))
+            pp = pp.crop(bbox)
+
+        if return_mode == "min_image":
+            bbox = pp.getbbox()
+            pp = pp.crop(bbox)
+
+        return pp
+
+    def add_text(self, mode="", base="", value="", percentage="", font="", text="", anchor="", align="", direction="",
+                 max_len_one_line="", spacing="", fill=""):
+        """
+        {
+            "command": "add_text",
+            "pos": {"plugins_mode": "relative",  # pixel
+                    "base": "center",  # nw,nc,ne,ec ... 各个方向参考点
+                    "value": (100, 100),
+                    "percentage": 0, },
+            "font": "",
+            "text": "",
+            "anchor": "",  # mm 为居中 ma 为左右居中,上面居顶 rs 右边;从哪边开始输入
+            "align": "对齐方式",left  center right
+            "direction": "文本的方向",
+            "max_len_one_line": "单行长度",
+            "spacing": 10,
+            "fill": "文字颜色",
+        }
+
+        """
+        pp = PictureProcessing(im=self.im)
+        draw_1 = ImageDraw.Draw(pp.im)
+        # 定义字体,你需要有一个.ttf字体文件
+        spacing = 4 if not spacing else spacing
+        anchor = None if not anchor else anchor
+        align = "left" if not align else align  # left, center 或 right
+        _, _, text_width, text_height = draw_1.textbbox((0, 0), text, font=font)
+
+        xy = (0, 0)
+        if mode == "pixel":
+            xy = value
+
+        draw_1.multiline_text(xy, text,
+                              fill=fill,
+                              font=font,
+                              anchor=anchor,
+                              spacing=spacing,
+                              align=align,
+                              direction=None,
+                              features=None,
+                              language=None,
+                              stroke_width=0,
+                              stroke_fill=None,
+                              embedded_color=False)
+        return pp
+
+    def crop_img(self, mode="pixel", base="nw", value=(100, 100, 10, 10), color_fill=(255, 255, 255),
+                 margins=(0, 0, 0, 0)):
+        """
+        {
+            "command": "crop_img",
+            "img": {"im": "im"},
+            "pos": {"plugins_mode": "relative",  # pixel
+                    "base": "center",  # nw,nc,ne,ec ... 各个方向参考点
+                    "value": (100, 100, 10, 10),# 顶点,以及图片大小
+                    },
+            "color_fill": (255, 255, 255)
+        }
+
+        """
+        pp = PictureProcessing(im=self.im)
+
+        base = "nw" if not base else base
+        if margins:
+            top, down, left, right = margins
+        else:
+            top, down, left, right = 0, 0, 0, 0
+
+        out_img_size = (value[2], value[3])
+        # 默认填充色
+        if not color_fill:
+            color_fill = (0, 0, 0)
+
+        if mode == "pixel":
+            # 左上脚
+            if base == "nw" or "wn":
+                box = value
+            # 左下角
+            if base == "sw" or base == "ws":
+                # deviation_x, deviation_y = 0, int((img.height - img_1.height))
+                box = (value[0], pp.height - (value[1] + value[3]), value[2], value[3])
+                # print(box)
+
+            # 右下角
+            if base == "se" or base == "es":
+                box = (pp.width - (value[0] + value[2]), pp.height - (value[1] + value[3]), value[2], value[3])
+                # print(box)
+
+            # 居中
+            if base == "cc":
+                # print("11-value", value)
+                x = int((pp.width + value[0] - value[2]) / 2)
+                y = int((pp.height + value[1] - value[3]) / 2)
+                box = (x,
+                       y,
+                       value[2],
+                       value[3])
+                # print("11-box", box)
+
+            box = [box[0], box[1], box[0] + box[2], box[1] + box[3]]
+
+        # print("12-box", box)
+        # print("ww-hhh", pp.width, pp.height)
+        out_img = pp.im.crop(box=box)
+        # print("out_img", out_img.width, out_img.height)
+        # print("-----")
+
+        if box[0] < 0:
+            out_img.paste(Image.new("RGB", (-1 * box[0], out_img.height), color_fill), (0, 0))
+
+        if box[1] < 0:
+            out_img.paste(Image.new("RGB", (out_img.width, -1 * box[1]), color_fill), (0, 0))
+
+        if box[2] > pp.width:
+            # print(box[2] - img.width, img.height)
+            i = Image.new("RGB", (box[2] - pp.width, out_img.height), color_fill)
+            out_img.paste(i, (pp.width - box[0], 0))
+
+        if box[3] > pp.height:
+            out_img.paste(Image.new("RGB", (out_img.width, box[3] - pp.height), color_fill),
+                          (0, pp.height - box[1]))
+
+        return PictureProcessing(im=out_img)
+
+    def crop(self, bbox=(0, 0, 0, 0), mode=None):
+        bbox = (int(bbox[0]), int(bbox[1]), int(bbox[2]), int(bbox[3]))
+        if mode == "min":
+            bbox = self.getbbox()
+        return PictureProcessing(im=self.im.crop(bbox))
+
+    def rotate(self, doge):
+        return PictureProcessing(im=self.im.rotate(doge))
+
+    def rotate_advance(self, doge, is_crop=True):
+        max_px = max(self.width, self.height)
+        max_px = max_px * 2
+        bg = PictureProcessing("RGBA", (max_px, max_px), (255, 255, 255, 0))
+        bg = bg.paste_img(top_img=self, base="cc")
+        bg = bg.rotate(doge)
+        if is_crop:
+            bg = bg.crop(mode="min")
+
+        return bg
+
+    def radius(self, mode="pixel", circular_pos=(1, 1, 1, 1), value=30, percentage=""):
+        """
+        {"command": "radius",  # radius
+             "plugins_mode": "relative",  # pixel 相对(短边),或绝对像素
+             "circular_pos": (0, 1, 0, 1),  # 从左上角顺时针,记录圆角数量
+             "value": 649,  # 固定值,如果为百分比,则为0
+             "percentage": 0, }  # 百分比
+        """
+        # 单图圆角处理
+        pp = PictureProcessing(im=self.im)
+
+        radii = value
+        if radii > pp.width / 2:
+            radii = int(pp.width / 2)
+        if radii > pp.height / 2:
+            radii = int(pp.height / 2)
+
+        # 画圆(用于分离4个角)
+        circle = Image.new('L', (radii * 2, radii * 2), 0)  # 创建一个黑色背景的画布
+        draw = ImageDraw.Draw(circle)
+        draw.ellipse((0, 0, radii * 2, radii * 2), fill=255)  # 画白色圆形
+
+        # 原图
+        img = pp.im.convert("RGBA")
+        w, h = img.size
+
+        # 画4个角(将整圆分离为4个部分)
+        alpha = Image.new('L', img.size, 255)
+        _pos = circular_pos
+        if not _pos:
+            _pos = (1, 1, 1, 1)
+        for index, i in enumerate(_pos):
+            if index == 0 and i == 1:
+                alpha.paste(circle.crop((0, 0, radii, radii)), (0, 0))  # 左上角
+            if index == 1 and i == 1:
+                alpha.paste(circle.crop((radii, 0, radii * 2, radii)), (w - radii, 0))  # 右上角
+            if index == 2 and i == 1:
+                alpha.paste(circle.crop((radii, radii, radii * 2, radii * 2)), (w - radii, h - radii))  # 右下角
+            if index == 3 and i == 1:
+                alpha.paste(circle.crop((0, radii, radii, radii * 2)), (0, h - radii))  # 左下角
+        # alpha.show()
+        img.putalpha(alpha)  # 白色区域透明可见,黑色区域不可见
+        return PictureProcessing(im=img)
+
+    # 图片翻转
+    def transpose(self, mode="left_right"):
+        img = self.get_im()
+        img = img.transpose(Image.FLIP_LEFT_RIGHT)
+        return PictureProcessing(im=img)
+
+    def convert(self, mode):
+        return PictureProcessing(im=self.im.convert(mode))
+
+    def save_as_rgb(self, path):
+        self.im = self.im.convert("RGB")
+        self.im.save(path, format="JPEG")
+
+    def save_as_png(self, path):
+        self.im = self.im.convert("RGBA")
+        self.im.save(path)

+ 23 - 0
python/custom_plugins/plugins_mode/plugins_base_func.py

@@ -0,0 +1,23 @@
+import os
+
+
+# 输入文件夹,并检查是否是一个正常的图片文件夹。
+def check_goods_folder(folder_path):
+    all_files = os.listdir(folder_path)
+    for file in all_files:
+        file_path = "{}/{}".format(folder_path, file)
+        if not os.path.isdir(file_path):
+            continue
+        if "原始图" in os.listdir(file_path):
+            return folder_path
+    # 上述检查不通过,可能是选择目录错误
+    if "原始图" in all_files:
+        root_path, _ = os.path.split(folder_path)
+        return root_path
+    return None
+
+
+if __name__ == '__main__':
+    a = check_goods_folder(
+        r"D:\MyDocuments\PythonCode\MyPython\red_dragonfly\deal_pics\auto_capture_V2\auto_photo\output\2024-12-20-2")
+    print(a)