Browse Source

Merge branch 'master' of http://gitlab.pubdata.cn/liangyibo/CameraMachine

panqiuyao 6 months ago
parent
commit
13a5b883f2

+ 2 - 1
python/.gitignore

@@ -9,4 +9,5 @@ resources/
 output/*
 qt_test/*
 *.jpg
-*.png
+*.png
+xinnuo-*/

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


+ 792 - 0
python/custom_plugins/plugins/detail_template/xinnuo/detail_xinnuo1.py

@@ -0,0 +1,792 @@
+"""
+步骤:
+1、整理需要处理的款号图-输出款号图文件夹
+2、整理所有相关的图片作为素材图
+3、按要求进行拼接
+"""
+
+from ast import mod
+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 = "xinnuo-1"
+
+
+class DetailPicGet(DetailBase):
+    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里","组合","组合2","组合3"]
+    root = r"{}\resources\detail_temp\xinnuo\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\xinnuo\1".format(os.getcwd())
+        print("run xinnuo-1 ")
+        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,
+            self.deal_pic_13,
+            self.deal_pic_14,
+            self.deal_pic_15,
+            self.deal_pic_16,
+            self.deal_pic_17,
+            self.deal_pic_18,
+            self.deal_pic_19,
+            self.deal_pic_20,
+        ]
+
+        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())
+        detailed_images.append(self.deal_pic_13())
+        detailed_images.append(self.deal_pic_14())
+        detailed_images.append(self.deal_pic_15())
+        detailed_images.append(self.deal_pic_16())
+        detailed_images.append(self.deal_pic_17())
+        detailed_images.append(self.deal_pic_18())
+        detailed_images.append(self.deal_pic_19())
+        detailed_images.append(self.deal_pic_20())
+
+        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"{}\1.jpg".format(self.root))
+        font_main = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 102)  # 设计理念
+        mainTitle = self.get_text_value("主标题")
+        subTitle = self.get_text_value("副标题")
+        pp_bg.get_text_image_advanced(
+            value=(336, 102),
+            font=font_main,
+            text=mainTitle,
+            align="left",
+            # anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        font_sub = ImageFont.truetype(
+            r"resources\ttf\puhui\Bold.ttf", 40
+        )  # 设计理念
+        pp_bg.get_text_image_advanced(
+            value=(82, 102),
+            font=font_sub,
+            text=subTitle,
+            align="left",
+            # anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        return pp_bg
+
+    # 展示鞋头和后跟
+    def deal_pic_2(self):
+        pp_bg = PictureProcessing(r"{}\2.jpg".format(self.root))
+        font = ImageFont.truetype(
+            r"resources\ttf\puhui\Regular.ttf", 24
+        )  # 设计理念
+        design_text = self.get_text_value("设计理念")
+        pp_bg.get_text_image_advanced(
+            value=(226, 359),
+            font=font,
+            text=design_text,
+            align="center",
+            # anchor="ma",
+            spacing=20,
+            fill=(88, 52, 28),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        return pp_bg
+
+    # 展示鞋头放大图
+    def deal_pic_3(self):
+        pp_bg = PictureProcessing(r"{}\3.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=1600)
+        pp_png_1 = pp_png_1.resize(value=1600)
+        # pp_bg = pp_bg.paste_img(top_img=shoe_bg, value=(0, 0), base="nw")
+        pp_bg = pp_bg.to_overlay_pic_advance(
+            mode="pixel",
+            top_img=pp_jpg_1,
+            base="ne",
+            value=(100, 0),
+            top_png_img=pp_png_1,
+        )
+        return pp_bg
+
+    # 展示后跟放大图
+    def deal_pic_4(self):
+        pp_bg = PictureProcessing(r"{}\4.jpg".format(self.root))
+
+        return pp_bg
+
+    # 展示后跟细节卡片
+    def deal_pic_5(self):
+        pp_bg = PictureProcessing(r"{}\5.jpg".format(self.root))
+        return pp_bg
+
+    # "心动"设计亮点,展示旋转的侧视图
+    def deal_pic_6(self):
+        pp_bg = PictureProcessing(r"{}\6.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=pp_bg.width/1.4)
+        pp_png_1 = pp_png_1.resize(value=pp_bg.width / 1.4)
+        # pp_bg = pp_bg.paste_img(top_img=shoe_bg, value=(0, 0), base="nw")
+        pp_bg = pp_bg.to_overlay_pic_advance(
+            mode="pixel",
+            top_img=pp_jpg_1,
+            base="center",
+            value=(0, 0),
+            top_png_img=pp_png_1,
+        )
+        return pp_bg
+
+    # 产品展示,帮面等等
+    def deal_pic_7(self):
+        pp_bg = PictureProcessing(r"{}\7.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=500)
+        pp_png_1 = pp_png_1.resize(value=500)
+        # pp_bg = pp_bg.paste_img(top_img=shoe_bg, value=(0, 0), base="nw")
+        pp_bg = pp_bg.to_overlay_pic_advance(
+            mode="pixel",
+            top_img=pp_jpg_1,
+            base="ne",
+            value=(200, 578),
+            top_png_img=pp_png_1,
+        )
+        font = ImageFont.truetype(
+            r"resources\ttf\puhui\Medium.ttf", 24
+        )  # 设计理念
+        font_hei = ImageFont.truetype(r"resources\ttf\simhei.ttf", 24)  # 设计理念
+        bangmian  = self.get_text_value("帮面")
+        neili = self.get_text_value("内里")
+        xiedi = self.get_text_value("鞋底")
+        xiedian = self.get_text_value("鞋垫")
+        xiekuan = self.get_text_value("鞋宽")
+        banggao = self.get_text_value("帮高")
+        gengao = self.get_text_value("跟高")
+        pp_bg.get_text_image_advanced(
+            value=(230, 346),
+            font=font,
+            text=bangmian,
+            align="left",
+            # anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        pp_bg.get_text_image_advanced(
+            value=(551, 346),
+            font=font,
+            text=neili,
+            align="left",
+            # anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        pp_bg.get_text_image_advanced(
+            value=(230, 456),
+            font=font,
+            text=xiedi,
+            align="left",
+            # anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        pp_bg.get_text_image_advanced(
+            value=(551, 456),
+            font=font,
+            text=xiedian,
+            align="left",
+            # anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        pp_bg.get_text_image_advanced(
+            value=(64, 901),
+            font=font_hei,
+            text=xiekuan,
+            align="left",
+            # anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        pp_bg.get_text_image_advanced(
+            value=(621, 650),
+            font=font_hei,
+            text=banggao,
+            align="left",
+            # anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        pp_bg.get_text_image_advanced(
+            value=(621, 752),
+            font=font_hei,
+            text=gengao,
+            align="left",
+            # anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        return pp_bg
+
+    # 功能展示与卖点
+    def deal_pic_8(self):
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\7.jpg".format(self.root))
+        # detailed_images.append(pp_bg)
+        goods_art_no_list = list(self.data.keys())
+        all_color_name = []
+        bg_color = (253, 250, 242)
+        text_color = (70, 48, 41)
+        font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 25)
+        goods_art_images = []
+        total_height = 0
+        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=pp_bg.width/2.5)
+            color_name = self.goods_no_value["货号资料"][index]["颜色名称"]
+            all_color_name.append(color_name)
+            text_bg = PictureProcessing("RGB", (pp_jpg.width, 50), bg_color)
+            text_bg = text_bg.get_text_image_advanced(
+                value=(0, 0),
+                font=font,
+                text="● {}".format(color_name),
+                align="center",
+                # anchor="mm",
+                spacing=5,
+                fill=text_color,
+                return_mode="image",
+                margins=(0, 0, 0, 0),
+            )
+            _bg = PictureProcessing(
+                "RGB",
+                (pp_bg.width / 2, pp_jpg.height+200),
+                bg_color,
+            )
+            if (index+1) == 1:
+                total_height += _bg.height
+            if (index + 1) % 2 != 0 and (index + 1) != 1:
+                total_height += _bg.height
+            print("高度:", total_height)
+            _bg = _bg.paste_img(top_img=pp_jpg, base="center")
+            _bg = _bg.paste_img(
+                top_img=text_bg, value=(pp_jpg.width / 2, pp_jpg.height+100)
+            )
+            goods_art_images.append(_bg)
+        rows = 2
+        shoes_bg = PictureProcessing(
+        ).horizontal_distribution(
+            pp_list=goods_art_images,
+            bg_width=pp_bg.width,
+            margins=(0, 0, 0, 0),
+            line_spacing=0,
+            number_per_row=rows,
+        )
+        main_bg = PictureProcessing(
+            "RGB",
+            (pp_bg.width, total_height),
+            bg_color,
+        )
+        main_bg.paste_img(top_img=shoes_bg)
+        detailed_images.append(main_bg)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 添加尺码表
+    def deal_pic_9(self):
+        image_path = r"{}\9.jpg".format(self.root)
+        return PictureProcessing(image_path)
+
+    # 角度展示
+    def deal_pic_10(self):
+        detailed_images = []
+        # 角度展示标题
+        detailed_images.append(PictureProcessing(r"{}\10.jpg".format(self.root)))
+        return self.pp_pic_subsection(
+            PictureProcessing(im=self.add_pic(detailed_images))
+        )
+
+    # 添加注意事项
+    def deal_pic_11(self):
+        detailed_images = []
+        image_path = r"{}\11.jpg".format(self.root)
+        pp_bg = PictureProcessing(image_path)
+        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=1400)
+        pp_png_1 = pp_png_1.resize(value=1400)
+        pp_bg = pp_bg.to_overlay_pic_advance(
+            mode="pixel",
+            top_img=pp_jpg_1,
+            base="nw",
+            value=(0, pp_bg.height - pp_jpg_1.height),
+            top_png_img=pp_png_1,
+        )
+        font_main = ImageFont.truetype(
+            r"resources\ttf\puhui\Medium.ttf", 58
+        )  # 设计理念
+        mainTitle = self.get_text_value("细节亮点主标题")
+        subTitle = self.get_text_value("细节亮点副标题")
+        pp_bg.get_text_image_advanced(
+            value=(pp_bg.width/2, 219),
+            font=font_main,
+            text=mainTitle,
+            align="center",
+            anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 36)  # 设计理念
+        pp_bg.get_text_image_advanced(
+            value=(pp_bg.width / 2, 313),
+            font=font_sub,
+            text=subTitle,
+            align="center",
+            anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        detailed_images.append(pp_bg)
+        bg_12_image_path = r"{}\12.jpg".format(self.root)
+        bg_12 = PictureProcessing(bg_12_image_path)
+        detailed_images.append(bg_12)
+        return self.pp_pic_subsection(
+            PictureProcessing(im=self.add_pic(detailed_images))
+        )
+
+    def deal_pic_13(self):
+        detailed_images = []
+        image_path = r"{}\13.jpg".format(self.root)
+        pp_bg = PictureProcessing(image_path)
+        image_path_1 = r"{}\13_1.png".format(self.root)
+        pp_bg_1 = PictureProcessing(image_path_1)
+        font_main = ImageFont.truetype(
+            r"resources\ttf\puhui\Medium.ttf", 58
+        )  # 设计理念
+        pp_bg.get_text_image_advanced(
+            value=(pp_bg.width / 2, 168),
+            font=font_main,
+            text="经典系带",
+            align="center",
+            anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 36)  # 设计理念
+        pp_bg.get_text_image_advanced(
+            value=(pp_bg.width / 2, 261),
+            font=font_sub,
+            text="松紧自由调节",
+            align="center",
+            anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        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=1500)
+        pp_png_1 = pp_png_1.resize(value=1500)
+        pp_bg = pp_bg.to_overlay_pic_advance(
+            mode="pixel",
+            top_img=pp_jpg_1,
+            base="cs",
+            value=(0, - pp_jpg_1.height/4),
+            top_png_img=pp_png_1,
+        )
+        pp_bg.paste_img(top_img=pp_bg_1)
+        detailed_images.append(pp_bg)
+        return self.pp_pic_subsection(
+            PictureProcessing(im=self.add_pic(detailed_images))
+        )
+
+    def deal_pic_14(self):
+        # 场景展示
+        detailed_images = []
+        image_path = r"{}\14.jpg".format(self.root)
+        pp_bg_14 = PictureProcessing(image_path)
+        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=pp_bg_14.width)
+        pp_png_1 = pp_png_1.resize(value=pp_bg_14.width)
+        pp_bg_14 = pp_bg_14.to_overlay_pic_advance(
+            mode="pixel",
+            top_img=pp_jpg_1,
+            base="cc",
+            value=(0, 0),
+            top_png_img=pp_png_1,
+        )
+        detailed_images.append(pp_bg_14)
+        return self.pp_pic_subsection(
+            PictureProcessing(im=self.add_pic(detailed_images))
+        )
+
+    def deal_pic_15(self):
+        detailed_images = []
+        image_path = r"{}\15.jpg".format(self.root)
+        pp_bg_15 = PictureProcessing(image_path)
+        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",
+        )
+        pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_15.width)
+        pp_png_1 = pp_png_1.resize(value=pp_bg_15.width)
+        pp_bg_15 = pp_bg_15.to_overlay_pic_advance(
+            mode="pixel",
+            top_img=pp_jpg_1,
+            base="cc",
+            value=(0, 0),
+            top_png_img=pp_png_1,
+        )
+        detailed_images.append(pp_bg_15)
+        return self.pp_pic_subsection(
+            PictureProcessing(im=self.add_pic(detailed_images))
+        )
+
+    def deal_pic_16(self):
+        detailed_images = []
+        image_path = r"{}\16.jpg".format(self.root)
+        pp_bg_16 = PictureProcessing(image_path)
+        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="组合3",
+        )
+        pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_16.width)
+        pp_png_1 = pp_png_1.resize(value=pp_bg_16.width)
+        pp_bg_16 = pp_bg_16.to_overlay_pic_advance(
+            mode="pixel",
+            top_img=pp_jpg_1,
+            base="cc",
+            value=(0, 0),
+            top_png_img=pp_png_1,
+        )
+        detailed_images.append(pp_bg_16)
+        return self.pp_pic_subsection(
+            PictureProcessing(im=self.add_pic(detailed_images))
+        )
+
+    def deal_pic_17(self):
+        # 产品细节
+        image_path = r"{}\17.jpg".format(self.root)
+        image_path_1 = r"{}\17_1.png".format(self.root)
+        detailed_images = []
+        pp_bg_1 = PictureProcessing(image_path_1)
+        pp_bg = PictureProcessing(image_path)
+        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=pp_bg.width+100)
+        pp_png_1 = pp_png_1.resize(value=pp_bg.width + 100)
+        pp_bg = pp_bg.to_overlay_pic_advance(
+            mode="pixel",
+            top_img=pp_jpg_1,
+            base="cs",
+            value=(0, 0),
+            top_png_img=pp_png_1,
+        )
+        mainTitle = self.get_text_value("艺-主标题")
+        subTitle = self.get_text_value("艺-副标题")
+        font_main = ImageFont.truetype(
+            r"resources\ttf\puhui\Medium.ttf", 30
+        )  # 设计理念
+        pp_bg.get_text_image_advanced(
+            value=(113, 545),
+            font=font_main,
+            text=mainTitle,
+            align="left",
+            # anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24)  # 设计理念
+        pp_bg.get_text_image_advanced(
+            value=(113, 602),
+            font=font_sub,
+            text=subTitle,
+            align="left",
+            # anchor="ma",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        pp_bg.paste_img(top_img=pp_bg_1)
+        detailed_images.append(pp_bg)
+        return self.pp_pic_subsection(
+            PictureProcessing(im=self.add_pic(detailed_images))
+        )
+
+    def deal_pic_18(self):
+        image_path = r"{}\18.jpg".format(self.root)
+        image_path_1 = r"{}\18_1.png".format(self.root)
+        detailed_images = []
+        pp_bg_1 = PictureProcessing(image_path_1)
+        pp_bg = PictureProcessing(image_path)
+        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=1400)
+        pp_png_1 = pp_png_1.resize(value=1400)
+        pp_bg = pp_bg.to_overlay_pic_advance(
+            mode="pixel",
+            top_img=pp_jpg_1,
+            base="cs",
+            value=(-pp_jpg_1.width/3, 0),
+            top_png_img=pp_png_1,
+        )
+        mainTitle = self.get_text_value("跟-主标题")
+        subTitle = self.get_text_value("跟-副标题")
+        gengao = self.get_text_value("跟高")
+        font_main = ImageFont.truetype(
+            r"resources\ttf\puhui\Medium.ttf", 30
+        )  # 设计理念
+        pp_bg.get_text_image_advanced(
+            value=(441, 220),
+            font=font_main,
+            text=mainTitle,
+            align="right",
+            # anchor="rs",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24)  # 设计理念
+        pp_bg.get_text_image_advanced(
+            value=(441, 272),
+            font=font_sub,
+            text=subTitle,
+            align="right",
+            # anchor="ls",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        pp_bg.get_text_image_advanced(
+            value=(605, 648),
+            font=font_main,
+            text=gengao,
+            align="right",
+            # anchor="ls",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        pp_bg.paste_img(top_img=pp_bg_1)
+        detailed_images.append(pp_bg)
+        return self.pp_pic_subsection(
+            PictureProcessing(im=self.add_pic(detailed_images))
+        )
+
+    def deal_pic_19(self):
+        detailed_images = []
+        image_path = r"{}\19.jpg".format(self.root)
+        pp_bg = PictureProcessing(image_path)
+        # 鞋底
+        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=pp_bg.width)
+        pp_png_1 = pp_png_1.resize(value=pp_bg.width)
+        pp_bg = pp_bg.to_overlay_pic_advance(
+            mode="pixel",
+            top_img=pp_jpg_1,
+            base="center",
+            value=(0, 200),
+            top_png_img=pp_png_1,
+        )
+        mainTitle = self.get_text_value("底-主标题")
+        subTitle = self.get_text_value("底-副标题")
+        font_main = ImageFont.truetype(
+            r"resources\ttf\puhui\Medium.ttf", 30
+        )  # 设计理念
+        pp_bg.get_text_image_advanced(
+            value=(114, 259),
+            font=font_main,
+            text=mainTitle,
+            align="left",
+            # anchor="rs",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24)  # 设计理念
+        pp_bg.get_text_image_advanced(
+            value=(114, 311),
+            font=font_sub,
+            text=subTitle,
+            align="left",
+            # anchor="ls",
+            spacing=5,
+            fill=(60, 40, 29),
+            return_mode="image",
+            margins=(0, 0, 0, 0),
+        )
+        # return PictureProcessing(image_path)
+        detailed_images.append(pp_bg)
+        return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
+
+    def deal_pic_20(self):
+        detailed_images = []
+        bg_20 = PictureProcessing(r"{}\20.jpg".format(self.root))
+        bg_21 = PictureProcessing(r"{}\21.jpg".format(self.root))
+        bg_22 = PictureProcessing(r"{}\22.jpg".format(self.root))
+        detailed_images.append(bg_20)
+        detailed_images.append(bg_21)
+        detailed_images.append(bg_22)
+        return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
+
+
+if __name__ == "__main__":
+
+    d = DetailPicGet(
+        goods_no="test",
+        goods_no_value={},
+        out_put_dir="./output/xinnuo-1",
+        test=True,
+    )
+    d.run_test()

+ 16 - 11
python/custom_plugins/plugins/micropython_update/ampy_plugin.py

@@ -9,7 +9,7 @@ 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
+from module.base_mode.base import calculate_sha256, download_file, compare_two_times, get_modified_time, get_md5
 import concurrent.futures
 
 plugins_name = "AMPY插件"
@@ -43,7 +43,6 @@ class AmpyScribe(object):
             self.pyb.close()
             self.pyb = None
 
-
     # 上传文件
     def upload_file(self, local_path, remote_path, local_path_is_file=True):
         """
@@ -137,8 +136,9 @@ class RemoteUpdate(object):
         """
         self.show_progress_bar(add_value=5)
         self.show_text_info("开始检查处理,停止MCU")
-        self.stop_mcu()
-        time.sleep(0.5)
+        if self.top_windows.mcu.connect_state:
+            self.stop_mcu()
+            time.sleep(2)
         self.connect_pyboard()
         if self.ampy_scribe is None:
             self.show_text_info("串口链接失败,已退出")
@@ -272,12 +272,14 @@ class RemoteUpdate(object):
         for online_file_path, value in online_files_dict.items():
             if online_file_path in ignore_path:
                 continue
+            online_file_sha256 = calculate_sha256(
+                "{}\micropython_online_code\mcu_code\{}".format(os.getcwd(), online_file_path))
             if online_file_path not in micropython_file_dict:
-                differential_files_dict[online_file_path] = {"file_sha256": value["file_sha256"]}
+                differential_files_dict[online_file_path] = {"file_sha256": online_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"]}
+                if online_file_sha256 != micropython_file_dict[online_file_path]["file_sha256"]:
+                    differential_files_dict[online_file_path] = {"file_sha256": online_file_sha256}
                 else:
                     print("文件相同:{}".format(online_file_path))
 
@@ -344,8 +346,8 @@ class RemoteUpdate(object):
             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_md5 = get_md5(file_path)
+                    if file_md5 != value["file_md5"]:
                         file_modified_time = get_modified_time(file_path)
                         if compare_two_times(file_modified_time, online_data["update_time"]) == "left_new":
                             continue
@@ -398,11 +400,14 @@ class RemoteUpdate(object):
             if self.port_name:
                 pass
             else:
-                self.port_name = self.top_windows.mcu.port_name
+                if self.top_windows.mcu.connect_state:
+                    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()
+                if self.top_windows.mcu.connect_state:
+                    self.top_windows.mcu.close_connect()
+                print("close_connect")
                 time.sleep(3)
                 try:
                     self.ampy_scribe = AmpyScribe(port_name=self.port_name, windows=None)

+ 33 - 3
python/custom_plugins/plugins_mode/detail_generate_base.py

@@ -87,8 +87,38 @@ class DetailBase(object):
             else:
                 if "主图" in self.assigned_page_list:
                     self.deal_all_main_pic()
+        # ----------如果是红蜻蜓则创建同颜色下的其他货号颜色文件夹---------------
+        if settings.PROJECT == "红蜻蜓":
+            if "data_all_goods_art_info" in self.goods_no_value:
+                # 数据格式:[{'number': '14250232', 'goods_art_no': 'AC52001173', 'color': '杏色'}, ]
+                for pic_data in self.goods_no_value["货号资料"]:
+                    if "颜色名称" not in pic_data:
+                        continue
+                    color_name = pic_data["颜色名称"]
+
+                    color_file_path = "{out_put_dir}/{goods_no}/{goods_number}".format(out_put_dir=self.out_put_dir,
+                                                                                       goods_no=self.goods_no,
+                                                                                       goods_number=pic_data["编号"])
+                    for i in self.goods_no_value["data_all_goods_art_info"]:
+                        if color_name in i["color"]:
+                            new_path = "{out_put_dir}/{goods_no}/{goods_number}".format(out_put_dir=self.out_put_dir,
+                                                                                        goods_no=self.goods_no,
+                                                                                        goods_number="NUM{}".format(
+                                                                                            i["number"]))
+                            if not os.path.exists(new_path):
+                                # 创建文件夹
+                                os.makedirs(new_path)
+                                self.move_one_pic(color_file_path, new_path, "NUM{}".format(i["number"]))
         return True
 
+    # 移动一张图片到新的文件夹
+    def move_one_pic(self, old_path, new_path, new_name):
+        image_file = os.listdir(old_path)[0]
+        old_image_path = "{}/{}".format(old_path, image_file)
+        image_e = os.path.splitext(image_file)[1]
+        new_image_path = "{}/{}{}".format(new_path, new_name, image_e)
+        shutil.copy(old_image_path, new_image_path)
+
     # 生成各个详情图切片
     def deal_details(self):
         detailed_images = []
@@ -177,9 +207,9 @@ class DetailBase(object):
                 text = str(self.goods_no_value[key])
                 text = text.replace(r"\n", "\n")
 
-        if key in ["跟高", "鞋宽", "帮高", "脚掌围", "鞋长"]:
-            if text:
-                text = text.split(".")[0]
+        # if key in ["跟高", "鞋宽", "帮高", "脚掌围", "鞋长"]:
+        #     if text:
+        #         text = text.split(".")[0]
 
         if subsection_len != 0:
             text = text.split("\n")

+ 82 - 0
python/detail_template_test.json

@@ -0,0 +1,82 @@
+{
+    "AC5120913": {
+        "款号": "AC5120913",
+        "货号资料": [
+            {
+                "货号": "AC51016112",
+                "文件夹名称": "AC51016112",
+                "编号": "AC51016112",
+                "颜色名称": "枪色",
+                "pics": {
+                    "俯视-抠图": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(1)_俯视_抠图.png",
+                    "俯视-阴影": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(1)_俯视_阴影.png",
+                    "侧视-抠图": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(2)_侧视_抠图.png",
+                    "侧视-阴影": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(2)_侧视_阴影.png",
+                    "后跟-抠图": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(3)_后跟_抠图.png",
+                    "后跟-阴影": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(3)_后跟_阴影.png",
+                    "鞋底-抠图": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(4)_鞋底_抠图.png",
+                    "鞋底-阴影": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(4)_鞋底_阴影.png",
+                    "内里-抠图": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(5)_内里_抠图.png",
+                    "内里-阴影": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(5)_内里_阴影.png",
+                    "组合-抠图": "C:/Users/15001/Desktop/测试文件夹/测试/ST001-2/阴影图处理/ST001-2(6)_组合_抠图.png",
+                    "组合-阴影": "C:/Users/15001/Desktop/测试文件夹/测试/ST001-2/阴影图处理/ST001-2(6)_组合_阴影.png",
+                    "组合2-抠图": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(7)_组合2_抠图.png",
+                    "组合2-阴影": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(7)_组合2_阴影.png",
+                    "组合3-抠图": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(8)_组合3_抠图.png",
+                    "组合3-阴影": "C:/Users/15001/Desktop/测试文件夹/测试/ST003-1/阴影图处理/ST003-1(8)_组合3_阴影.png"
+                },
+                "800x800": [
+                    "C:/Users/15001/Desktop/测试文件夹/AC51016112/800x800/AC51016112(1).jpg",
+                    "C:/Users/15001/Desktop/测试文件夹/AC51016112/800x800/AC51016112(2).jpg",
+                    "C:/Users/15001/Desktop/测试文件夹/AC51016112/800x800/AC51016112(3).jpg",
+                    "C:/Users/15001/Desktop/测试文件夹/AC51016112/800x800/AC51016112(4).jpg",
+                    "C:/Users/15001/Desktop/测试文件夹/AC51016112/800x800/AC51016112(5).jpg"
+                ]
+            },
+            {
+                "货号": "AC51209131",
+                "文件夹名称": "AC51209131",
+                "编号": "AC51209131",
+                "颜色名称": "白色",
+                "pics": {
+                    "俯视-抠图": "C:/Users/15001/Desktop/测试文件夹/AC51209131/阴影图处理/AC51209131(1)_俯视_抠图.png",
+                    "俯视-阴影": "C:/Users/15001/Desktop/测试文件夹/AC51209131/阴影图处理/AC51209131(1)_俯视_阴影.png",
+                    "侧视-抠图": "C:/Users/15001/Desktop/测试文件夹/AC51209131/阴影图处理/AC51209131(2)_侧视_抠图.png",
+                    "侧视-阴影": "C:/Users/15001/Desktop/测试文件夹/AC51209131/阴影图处理/AC51209131(2)_侧视_阴影.png",
+                    "后跟-抠图": "C:/Users/15001/Desktop/测试文件夹/AC51209131/阴影图处理/AC51209131(3)_后跟_抠图.png",
+                    "后跟-阴影": "C:/Users/15001/Desktop/测试文件夹/AC51209131/阴影图处理/AC51209131(3)_后跟_阴影.png",
+                    "鞋底-抠图": "C:/Users/15001/Desktop/测试文件夹/AC51209131/阴影图处理/AC51209131(4)_鞋底_抠图.png",
+                    "鞋底-阴影": "C:/Users/15001/Desktop/测试文件夹/AC51209131/阴影图处理/AC51209131(4)_鞋底_阴影.png",
+                    "内里-抠图": "C:/Users/15001/Desktop/测试文件夹/AC51209131/阴影图处理/AC51209131(5)_内里_抠图.png",
+                    "内里-阴影": "C:/Users/15001/Desktop/测试文件夹/AC51209131/阴影图处理/AC51209131(5)_内里_阴影.png"
+                },
+                "800x800": [
+                    "C:/Users/15001/Desktop/测试文件夹/AC51209131/800x800/AC51209131(1).jpg",
+                    "C:/Users/15001/Desktop/测试文件夹/AC51209131/800x800/AC51209131(2).jpg",
+                    "C:/Users/15001/Desktop/测试文件夹/AC51209131/800x800/AC51209131(3).jpg",
+                    "C:/Users/15001/Desktop/测试文件夹/AC51209131/800x800/AC51209131(4).jpg",
+                    "C:/Users/15001/Desktop/测试文件夹/AC51209131/800x800/AC51209131(5).jpg"
+                ]
+            }
+        ],
+        "文件夹名称": "AC51016112",
+        "主标题": "休闲运动",
+        "副标题": "舒适百搭",
+        "设计理念": "经典凹出兼具动感同时带来轻盈\n步调轻软,松弛自在蔓延\n立体质感让朝气肆意绽放",
+        "帮面": "网布+合成革",
+        "鞋底": "橡胶底",
+        "内里": "网布",
+        "鞋垫": "合成革",
+        "鞋宽": "11.8CM",
+        "帮高": "5.7CM",
+        "跟高": "7.0CM",
+        "细节亮点主标题": "舒适鞋面",
+        "细节亮点副标题": "轻透网面享受每一步的清爽",
+        "艺-主标题": "鞋面弧形拼接",
+        "艺-副标题": "尽显不拘一格风尚",
+        "跟-主标题": "鞋底跟高7.0CM",
+        "跟-副标题": "迈步更轻松",
+        "底-主标题": "全底贴地 出行畅快",
+        "底-副标题": "凹凸纹理,轻松行走"
+    }
+}

+ 20 - 0
python/detail_template_test.py

@@ -0,0 +1,20 @@
+import json
+import settings
+
+settings.is_test_plugins = True
+
+
+from custom_plugins.plugins.detail_template.xinnuo.detail_xinnuo1 import (
+    DetailPicGet,
+)
+
+
+data = json.load(open("detail_template_test.json", mode="r", encoding="utf-8"))
+for goods_no, value in data.items():
+    d = DetailPicGet(
+        goods_no=goods_no,
+        goods_no_value=value,
+        out_put_dir=r"C:\Development\project\python\CameraMachine\python\output\xinnuo-1",
+        test=True,
+    )
+print("生成成功")

+ 15 - 8
python/service/grenerate_main_image_test.py

@@ -9,6 +9,7 @@ import settings
 from functools import wraps
 from .multi_threaded_image_saving import ImageSaver
 from .get_mask_by_green import GetMask
+from middleware import UnicornException
 
 def time_it(func):
     @wraps(func)  # 使用wraps来保留原始函数的元数据信息
@@ -547,10 +548,16 @@ class GeneratePic(object):
             else:
                 if os.path.exists(logo_path):
                     logo_im = Image.open(logo_path)
+                    if logo_im.mode != 'RGBA':
+                        logo_im = logo_im.convert('RGBA')
                 else:
                     logo_im = Image.new("RGBA", (1600, 1600), (0, 0, 0, 0))
 
-            image_bg.paste(logo_im, (0, 0), logo_im)
+            try:
+                image_bg.paste(logo_im, (0, 0), logo_im)
+            except Exception as e:
+                alpha_mask = logo_im.split()[3]
+                image_bg.paste(logo_im, (0, 0), alpha_mask)
 
         # image_bg = image_bg.resize((out_pic_size, out_pic_size), Image.BICUBIC)
         if settings.OUT_PIC_FACTOR > 1.0:
@@ -559,17 +566,17 @@ class GeneratePic(object):
         for imageSize in out_pic_size:
             dot_index = out_path.rfind(".")
             if dot_index != -1:
-                    # 拆分文件路径和后缀
-                    file_without_suffix = out_path[:dot_index]
-                    suffix = out_path[dot_index + 1 :]
+                # 拆分文件路径和后缀
+                file_without_suffix = out_path[:dot_index]
+                suffix = out_path[dot_index + 1 :]
             else:
-                    file_without_suffix = out_path
-                    suffix = ""
-                # 单独拼接字符串示例
+                file_without_suffix = out_path
+                suffix = ""
+            # 单独拼接字符串示例
             new_file_path = f"{file_without_suffix}_{imageSize}.{suffix}"
             if imageSize < 1600:
                 image_bg = image_bg.resize(
-                    (out_pic_size, out_pic_size), resample=settings.RESIZE_IMAGE_MODE
+                    (imageSize, imageSize), resample=settings.RESIZE_IMAGE_MODE
                 )
                 if settings.OUT_PIC_MODE == ".jpg":
                     self.saver.save_image(

+ 12 - 4
python/service/init_load_source.py

@@ -1,7 +1,7 @@
 import asyncio
 import json
 import time
-from settings import HLM_HOST
+from settings import DOMAIN as HLM_HOST
 import aiohttp
 import os
 from utils.utils_func import get_md5, get_modified_time, compare_two_times, check_path
@@ -13,9 +13,19 @@ class init_load_source:
         await self.down_resouce()
 
     async def down_resouce(self):
-        response_data = await self.get_update_file()
+        response_data = await self.get_update_file(plugins_name="new_custom_plugins")
         if response_data:
             for relative_file_path, value in response_data['data'].items():
+                if "new_custom_plugins" in relative_file_path and os.path.exists("lib") == False:
+                    print("主目录不存在,不下载")
+                    continue
+                if (
+                    "new_custom_plugins" in relative_file_path
+                    and os.path.exists("lib")
+                ):
+                    relative_file_path = relative_file_path.replace(
+                        "new_custom_plugins", "lib/custom_plugins"
+                    )
                 file_path = f"{os.getcwd()}/{relative_file_path}"
                 if os.path.exists(file_path):
                     file_md5 = get_md5(file_path)
@@ -44,7 +54,6 @@ class init_load_source:
         }
         await message_queue.put(json.dumps(message))
 
-
     async def get_update_file(self, type="client_camera", plugins_name="plugins_A"):
         """异步获取指定类型的插件文件更新信息
 
@@ -83,7 +92,6 @@ class init_load_source:
             print(f"An error occurred: {e}")
             return None
 
-
     async def async_download_file(self, url: str, file_path: str):
         """异步下载文件"""
         async with aiohttp.ClientSession() as session: