"""
步骤：
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 = "hongqingting-3" 


class DetailPicGet(DetailBase):
    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
    root = r"{}\resources\detail_temp\hongqingting-show\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.template_name = template_name
        self.root = r"{}\resources\detail_temp\hongqingting-show\3".format(os.getcwd())
        print("run hongqingt-3 ")
        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.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_12
        ]
        self.run_all()

    def deal_pic_1(self):

        goods_art_no_list = list(self.data.keys())
        # 背景图
        bg_img = PictureProcessing(r"{}\1.jpg".format(self.root))

        font_hei = ImageFont.truetype(r"resources\ttf\simhei.ttf", 40)

        year  = self.get_text_value("出品年") or "2025S/S"
        bg_img.get_text_image_advanced(
            value=(620, 499),
            font=font_hei,
            text=year,
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(255, 255, 255),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )

        mtitle  = self.get_text_value("主标题") or "(气质简约包头凉鞋)"
        bg_img.get_text_image_advanced(
            value=(510, 567),
            font=font_hei,
            text=mtitle,
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(255, 255, 255),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )

        stitle  = self.get_text_value("副标题") or "气 质 亮 眼 | 4 C M 显 高 | 柔 软 垫 脚"
        bg_img.get_text_image_advanced(
            value=(300, 650),
            font=font_hei,
            text=stitle,
            align="left",
            # anchor="ma",
            spacing=15,
            fill=(255, 255, 255),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )

        pp_jpg_1, pp_png_1 = self.image_one_pic(
            return_orign=True,
            goods_art_no=goods_art_no_list[0],
            name="俯视",
        )
        if self.check_shoe_is_right_by_pixel(im=pp_png_1.im):
            pp_png_1 = pp_png_1.transpose()
            pp_jpg_1 = pp_jpg_1.transpose()

        # aaa_img = PictureProcessing("RGBA", (pp_jpg_1.width*1.2, pp_jpg_1.height*1.2), (255,255,255,0))
        #
        ph=pp_png_1.height
        pw=pp_png_1.width
        if (ph/pw)>0.8:
            aheight =600
            # 等比计算目标宽度
            awidth = int(pp_jpg_1.width * aheight / pp_jpg_1.height)
        else:
            aheight =450
            # 等比计算目标宽度
            awidth = int(pp_jpg_1.width * aheight / pp_jpg_1.height)
        pp_png_1 = pp_png_1.resize(value=awidth)
        pp_jpg_1 = pp_jpg_1.resize(value=awidth)
        #
        # aaa_img = aaa_img.paste_img(top_img=pp_png_1,base="cc", value=(0, 0))


        # pp_png_1 = aaa_img.rotate(0)
        bg_img = bg_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=pp_jpg_1,
            base="cn",
            value=(-200, round(bg_img.height*0.65)),
            top_png_img=pp_png_1,
        )

        pp_jpg_2, pp_png_2 = self.image_one_pic(
            return_orign=True,
            goods_art_no=goods_art_no_list[0],
            name="俯视",
        )
        if self.check_shoe_is_right_by_pixel(im=pp_png_2.im)== False:
            pp_png_2 = pp_png_2.transpose()
            pp_jpg_2 = pp_jpg_2.transpose()
        pp_png_2 = pp_png_2.resize(value=awidth)
        pp_jpg_2 = pp_jpg_2.resize(value=awidth)
        # aaa_img = PictureProcessing("RGBA", (pp_jpg_2.width*1.2, pp_jpg_2.height*1.2), (255,255,255,0))
        #
        # aaa_img = aaa_img.paste_img(top_img=pp_png_2,base="cc", value=(0, 0))
        #
        # pp_png_2 = aaa_img.rotate(0)
        bg_img = bg_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=pp_jpg_2,
            base="cs",
            value=(200, 900),
            top_png_img=pp_png_2,
        )
        return bg_img

    def deal_pic_2(self):

        detailed_images = []

        goods_art_no_list = list(self.data.keys())
        # 背景图
        bg_img = PictureProcessing(r"{}\2.jpg".format(self.root))

        font_hei = ImageFont.truetype(r"resources\ttf\simhei.ttf", 45)

        year  = self.get_text_value("系列名") or "红蜻蜓2025SS云枕系列"
        bg_img.get_text_image_advanced(
            value=(740, 520),
            font=font_hei,
            text=year,
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(75, 69, 107),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )

        pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
                                                goods_art_no=goods_art_no_list[0],
                                                name="俯视",
                                                )
        if self.check_shoe_is_right_by_pixel(im=pp_png_1.im) == False:
            pp_jpg_1 = pp_jpg_1.transpose()
            pp_png_1 = pp_png_1.transpose()
        pp_jpg_1 = pp_jpg_1.resize(value=round(bg_img.width*(850/bg_img.width)))
        pp_png_1 = pp_png_1.resize(value=round(bg_img.width*(850/bg_img.width)))
        pp_jpg_1=pp_jpg_1.rotate_advance(doge=-35,is_crop=False)
        pp_png_1=pp_png_1.rotate_advance(doge=-35,is_crop=False)
        bg_img = bg_img.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1, base="cs",value=(0, 100))

        # pp_jpg_1, pp_png_1 = self.image_one_pic(
        #     return_orign=True,
        #     goods_art_no=goods_art_no_list[0],
        #     name="俯视",
        # )
        # if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)==False:
        #     pp_png_1 = pp_png_1.transpose()
        #     pp_jpg_1 = pp_jpg_1.transpose()
        #
        # aaa_img = PictureProcessing("RGBA", (pp_jpg_1.width*1.2, pp_jpg_1.height*1.2), (255,255,255,0))
        #
        # pp_png_1 = pp_png_1.resize(value=850)
        # pp_jpg_1 = pp_jpg_1.resize(value=850)
        #
        # aaa_img = aaa_img.paste_img(top_img=pp_png_1,base="cc", value=(0, 0))
        #
        # pp_png_1 = aaa_img.rotate(-35)
        #
        # bg_img = bg_img.to_overlay_pic_advance(
        #     mode="pixel",
        #     top_img=pp_png_1,
        #     base="cs",
        #     value=(0, -100),
        #     top_png_img=pp_png_1,
        # )

        detailed_images.append(bg_img)
        return PictureProcessing(im=self.add_pic(detailed_images))

        # return bg_img
    def deal_pic_3(self):

        # 背景图
        bg_img = PictureProcessing(r"{}\3.jpg".format(self.root))

        # sign_img = PictureProcessing(r"{}\3.png".format(self.root))
        # bg_img = bg_img.paste_img(top_img=sign_img,base="cc", value=(0, 0))

        return bg_img

    def deal_pic_4(self):
        detailed_images = []

        goods_art_no_list = list(self.data.keys())
        # 背景图
        bg_img = PictureProcessing(r"{}\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="后跟",
                                                )
        if self.check_shoe_is_right_by_pixel(im=pp_png_1.im) == False:
            pp_jpg_1 = pp_jpg_1.transpose()
            pp_png_1 = pp_png_1.transpose()
        # pp_jpg_1 = pp_jpg_1.resize(value=850)
        # pp_png_1 = pp_png_1.resize(value=850)
        aheight =650
        # 等比计算目标宽度
        awidth = int(pp_jpg_1.width * aheight / pp_jpg_1.height)
        pp_jpg_1 = pp_jpg_1.resize(value=awidth)
        pp_png_1 = pp_png_1.resize(value=awidth)

        pp_jpg_1=pp_jpg_1.rotate_advance(doge=25,is_crop=False)
        pp_png_1=pp_png_1.rotate_advance(doge=25,is_crop=False)
        bg_img = bg_img.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1, base="cs",value=(-250, -240))

        pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
                                                goods_art_no=goods_art_no_list[0],
                                                name="俯视",
                                                )
        if self.check_shoe_is_right_by_pixel(im=pp_png_1.im) == True:
            pp_jpg_1 = pp_jpg_1.transpose()
            pp_png_1 = pp_png_1.transpose()
        pp_jpg_1 = pp_jpg_1.resize(value=round(bg_img.width*(800/bg_img.width)))
        pp_png_1 = pp_png_1.resize(value=round(bg_img.width*(800/bg_img.width)))
        pp_jpg_1=pp_jpg_1.rotate_advance(doge=30,is_crop=False)
        pp_png_1=pp_png_1.rotate_advance(doge=30,is_crop=False)
        bg_img = bg_img.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1, base="cs",value=(220, -250))

        # pp_jpg_1, pp_png_1 = self.image_one_pic(
        #     return_orign=True,
        #     goods_art_no=goods_art_no_list[0],
        #     name="后跟",
        # )
        # if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== False:
        #     pp_png_1 = pp_png_1.transpose()
        # aaa_img = PictureProcessing("RGBA", (pp_jpg_1.width*1.2, pp_jpg_1.height*1.2), (255,255,255,0))
        # pp_png_1 = pp_png_1.resize(value=850)
        # aaa_img = aaa_img.paste_img(top_img=pp_png_1,base="cc", value=(0, 0))
        # pp_png_1 = aaa_img.rotate(15)
        # bg_img = bg_img.to_overlay_pic_advance(
        #     mode="pixel",
        #     top_img=pp_png_1,
        #     base="cs",
        #     value=(-250, 300),
        #     top_png_img=pp_png_1,
        # )
        # pp_jpg_2, pp_png_2 = self.image_one_pic(
        #     return_orign=True,
        #     goods_art_no=goods_art_no_list[0],
        #     name="俯视",
        # )
        # if self.check_shoe_is_right_by_pixel(im=pp_png_2.im):
        #     pp_png_2 = pp_png_2.transpose()
        # pp_png_2 = pp_png_2.resize(value=800)
        # aaa_img = PictureProcessing("RGBA", (pp_jpg_2.width*1.2, pp_jpg_2.height*1.2), (255,255,255,0))
        # aaa_img = aaa_img.paste_img(top_img=pp_png_2,base="cc", value=(0, 0))
        # pp_png_2 = aaa_img.rotate(15)
        # bg_img = bg_img.to_overlay_pic_advance(
        #     mode="pixel",
        #     top_img=pp_png_2,
        #     base="cs",
        #     value=(220, -450),
        #     top_png_img=pp_png_2,
        # )

        detailed_images.append(bg_img)
        return PictureProcessing(im=self.add_pic(detailed_images))
        return bg_img

    def deal_pic_5(self):
        detailed_images = []
        goods_art_no_list = list(self.data.keys())
        # 背景图
        bg_img = PictureProcessing(r"{}\5.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_jpg_1 = pp_jpg_1.resize(value=round(bg_img.width*(850/bg_img.width)))
        pp_png_1 = pp_png_1.resize(value=round(bg_img.width*(850/bg_img.width)))
        pw=pp_png_1.width
        ph=pp_png_1.height
        pp_jpg_1=pp_jpg_1.rotate_advance(doge=22,is_crop=False)
        pp_png_1=pp_png_1.rotate_advance(doge=22,is_crop=False)

        if (ph/pw)>0.8:
            print(555555555551)
            print(ph/pw)
            posy=(-1)*round(bg_img.height*0.12)
        else:
            print(555555555552)
            posy=(-1)*round(bg_img.height*0.16)
        bg_img = bg_img.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1, base="cs",value=(-50,posy ))

        detailed_images.append(bg_img)
        return PictureProcessing(im=self.add_pic(detailed_images))

    def deal_pic_6(self):
        if self.get_text_value("模特图"):
            hh_img = PictureProcessing(r"{}\6.jpg".format(self.root))
            mote_img = PictureProcessing(self.get_text_value("模特图"))
            mote_img = mote_img.resize(value=1400)
            bg_img = PictureProcessing("RGB", (hh_img.width, hh_img.height+mote_img.height), (255,255,255))
            bg_img = bg_img.paste_img(top_img=hh_img,base="nc", value=(0, 0))
            bg_img = bg_img.paste_img(top_img=mote_img,base="nc", value=(0, hh_img.height))
            return bg_img
        else:
            return

    def deal_pic_7(self):
        if self.get_text_value("场景图"):
            hh_img = PictureProcessing(r"{}\7.jpg".format(self.root))
            mote_img = PictureProcessing(self.get_text_value("场景图"))
            mote_img = mote_img.resize(value=1400)
            bg_img = PictureProcessing("RGB", (hh_img.width, hh_img.height+mote_img.height), (255,255,255))
            bg_img = bg_img.paste_img(top_img=hh_img,base="nc", value=(0, 0))
            bg_img = bg_img.paste_img(top_img=mote_img,base="nc", value=(0, hh_img.height))
            return bg_img
        else:
            return

    def deal_pic_8(self):
        # 背景图
        bg_img = PictureProcessing(r"{}\8.jpg".format(self.root))

        return bg_img

    def deal_pic_9(self):
        # 背景图
        bg_img = PictureProcessing(r"{}\9.jpg".format(self.root))
        return bg_img

    def deal_pic_10(self):
        goods_art_no_list = list(self.data.keys())
        # 背景图
        bg_img = PictureProcessing(r"{}\10.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="俯视",
        )

        aheight =650
        # 等比计算目标宽度
        awidth = int(pp_jpg_1.width * aheight / pp_jpg_1.height)

        pp_jpg_1 = pp_jpg_1.resize(value=awidth)
        pp_png_1 = pp_png_1.resize(value=awidth)
        bg_img = bg_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=pp_jpg_1,
            base="cs",
            value=(-40, 1640),
            top_png_img=pp_png_1,
        )
        font_hei = ImageFont.truetype(r"resources\ttf\simhei.ttf", 24)  # 设计理念
        xiemian  = self.get_text_value("商品面料") or "底层牛剖层革\n面层合成革"
        neili = self.get_text_value("商品内里") or "布里"
        xiedian = self.get_text_value("鞋垫") or "猪垫"
        xiedi = self.get_text_value("商品鞋底") or "橡胶"

        bg_img.get_text_image_advanced(
            value=(302, 1648),
            font=font_hei,
            text=xiemian,
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(74, 74, 74),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )
        bg_img.get_text_image_advanced(
            value=(944, 1648),
            font=font_hei,
            text=neili,
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(74, 74, 74),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )
        bg_img.get_text_image_advanced(
            value=(302, 1900),
            font=font_hei,
            text=xiedian,
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(74, 74, 74),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )
        bg_img.get_text_image_advanced(
            value=(944, 1900),
            font=font_hei,
            text=xiedi,
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(74, 74, 74),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )
        itemNo = self.goods_no_value["货号资料"][0]["货号"]
        bg_img.get_text_image_advanced(
            value=(302, 2172),
            font=font_hei,
            text=itemNo,
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(74, 74, 74),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )
        xiekuan = self.get_text_value("鞋宽") or "10.4CM"
        xiechang = self.get_text_value("鞋长") or "26.2CM"
        gengao = self.get_text_value("跟高") or "4CM"
        bg_img.get_text_image_advanced(
            value=(223, 894),
            font=font_hei,
            text="鞋宽"+xiekuan,
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(74, 74, 74),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )
        bg_img.get_text_image_advanced(
            value=(585, 1269),
            font=font_hei,
            text="鞋长"+xiechang,
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(74, 74, 74),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )
        bg_img.get_text_image_advanced(
            value=(1089, 1014),
            font=font_hei,
            text="跟高"+gengao,
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(74, 74, 74),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )

        # 底部三连鞋子带文字

        # font_main = ImageFont.truetype(
        #     r"resources\ttf\puhui\Medium.ttf", 30
        # )
        #
        # length=len(goods_art_no_list)
        # if length==3:
        #     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=250)
        #     pp_png_1 = pp_png_1.resize(value=250)
        #     bg_img = bg_img.to_overlay_pic_advance(
        #         mode="pixel",
        #         top_img=pp_jpg_1,
        #         base="cs",
        #         value=(-320, 366),
        #         top_png_img=pp_png_1,
        #     )
        #
        #     bg_img.get_text_image_advanced(
        #         value=(345, 2520),
        #         font=font_main,
        #         text=self.goods_no_value["货号资料"][0]["颜色名称"],
        #         align="center",
        #         # anchor="ma",
        #         spacing=5,
        #         fill=(0, 0, 0),
        #         return_mode="image",
        #         margins=(0, 0, 0, 0),
        #     )
        #
        #     pp_jpg_1, pp_png_1 = self.image_one_pic(
        #         return_orign=True,
        #         goods_art_no=goods_art_no_list[1],
        #         name="侧视",
        #     )
        #     pp_jpg_1 = pp_jpg_1.resize(value=250)
        #     pp_png_1 = pp_png_1.resize(value=250)
        #     bg_img = bg_img.to_overlay_pic_advance(
        #         mode="pixel",
        #         top_img=pp_jpg_1,
        #         base="cs",
        #         value=(0, 366),
        #         top_png_img=pp_png_1,
        #     )
        #
        #     bg_img.get_text_image_advanced(
        #         value=(655, 2520),
        #         font=font_main,
        #         text=self.goods_no_value["货号资料"][1]["颜色名称"],
        #         align="center",
        #         # anchor="ma",
        #         spacing=5,
        #         fill=(0, 0, 0),
        #         return_mode="image",
        #         margins=(0, 0, 0, 0),
        #     )
        #
        #     pp_jpg_1, pp_png_1 = self.image_one_pic(
        #         return_orign=True,
        #         goods_art_no=goods_art_no_list[2],
        #         name="侧视",
        #     )
        #     pp_jpg_1 = pp_jpg_1.resize(value=250)
        #     pp_png_1 = pp_png_1.resize(value=250)
        #     bg_img = bg_img.to_overlay_pic_advance(
        #         mode="pixel",
        #         top_img=pp_jpg_1,
        #         base="cs",
        #         value=(320, 366),
        #         top_png_img=pp_png_1,
        #     )
        #
        #     bg_img.get_text_image_advanced(
        #         value=(990, 2520),
        #         font=font_main,
        #         text=self.goods_no_value["货号资料"][2]["颜色名称"],
        #         align="center",
        #         # anchor="ma",
        #         spacing=5,
        #         fill=(0, 0, 0),
        #         return_mode="image",
        #         margins=(0, 0, 0, 0),
        #     )
        # elif length==2:
        #     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=250)
        #     pp_png_1 = pp_png_1.resize(value=250)
        #     bg_img = bg_img.to_overlay_pic_advance(
        #         mode="pixel",
        #         top_img=pp_jpg_1,
        #         base="cs",
        #         value=(-320, 366),
        #         top_png_img=pp_png_1,
        #     )
        #
        #     bg_img.get_text_image_advanced(
        #         value=(345, 2520),
        #         font=font_main,
        #         text=self.goods_no_value["货号资料"][0]["颜色名称"],
        #         align="center",
        #         # anchor="ma",
        #         spacing=5,
        #         fill=(0, 0, 0),
        #         return_mode="image",
        #         margins=(0, 0, 0, 0),
        #     )
        #
        #
        #
        #     pp_jpg_1, pp_png_1 = self.image_one_pic(
        #         return_orign=True,
        #         goods_art_no=goods_art_no_list[1],
        #         name="侧视",
        #     )
        #     pp_jpg_1 = pp_jpg_1.resize(value=250)
        #     pp_png_1 = pp_png_1.resize(value=250)
        #     bg_img = bg_img.to_overlay_pic_advance(
        #         mode="pixel",
        #         top_img=pp_jpg_1,
        #         base="cs",
        #         value=(320, 366),
        #         top_png_img=pp_png_1,
        #     )
        #
        #     bg_img.get_text_image_advanced(
        #         value=(990, 2520),
        #         font=font_main,
        #         text=self.goods_no_value["货号资料"][1]["颜色名称"],
        #         align="center",
        #         # anchor="ma",
        #         spacing=5,
        #         fill=(0, 0, 0),
        #         return_mode="image",
        #         margins=(0, 0, 0, 0),
        #     )
        # elif length==1:
        #     pp_jpg_1, pp_png_1 = self.image_one_pic(
        #         return_orign=True,
        #         goods_art_no=goods_art_no_list[1],
        #         name="侧视",
        #     )
        #     pp_jpg_1 = pp_jpg_1.resize(value=250)
        #     pp_png_1 = pp_png_1.resize(value=250)
        #     bg_img = bg_img.to_overlay_pic_advance(
        #         mode="pixel",
        #         top_img=pp_jpg_1,
        #         base="cs",
        #         value=(0, 366),
        #         top_png_img=pp_png_1,
        #     )
        #
        #     bg_img.get_text_image_advanced(
        #         value=(655, 2520),
        #         font=font_main,
        #         text=self.goods_no_value["货号资料"][1]["颜色名称"],
        #         align="center",
        #         # anchor="ma",
        #         spacing=5,
        #         fill=(0, 0, 0),
        #         return_mode="image",
        #         margins=(0, 0, 0, 0),
        #     )

        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=(247, 247, 247))
            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 = bg_img.get_text_image_advanced(font=font_2,
                                                        text="{}".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=3)
        bg_img = bg_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=all_color_pp,
            base="cs",
            value=(0, 250),
            top_png_img=all_color_pp,
        )

        return bg_img
    def deal_pic_11(self):
        goods_art_no_list = list(self.data.keys())
        # 背景图
        header_img = PictureProcessing(r"{}\11-1.jpg".format(self.root))
        bg_img = PictureProcessing("RGBA", (header_img.width, 3575), (255,255,255))
        # 贴顶部
        bg_img = bg_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=header_img,
            base="nc",
            value=(0, 0),
            top_png_img=header_img,
        )

        # item1
        item_img = PictureProcessing("RGBA", (header_img.width, 760), (255,255,255))

        length=len(goods_art_no_list)
        if length==3:
            pp_jpg_1, pp_png_1 = self.image_one_pic(
                return_orign=True,
                goods_art_no=goods_art_no_list[2],
                name="俯视",
            )
            aheight =400
            # 等比计算目标宽度
            awidth = int(pp_jpg_1.width * aheight / pp_jpg_1.height)
            pp_jpg_1 = pp_jpg_1.resize(value=awidth)
            pp_png_1 = pp_png_1.resize(value=awidth)
            item_img = item_img.to_overlay_pic_advance(
                mode="pixel",
                top_img=pp_jpg_1,
                base="cs",
                value=(-60, 300),
                top_png_img=pp_png_1,
            )
        if length>=2:
            pp_jpg_1, pp_png_1 = self.image_one_pic(
                return_orign=True,
                goods_art_no=goods_art_no_list[1],
                name="俯视",
            )
            aheight =400
            # 等比计算目标宽度
            awidth = int(pp_jpg_1.width * aheight / pp_jpg_1.height)
            pp_jpg_1 = pp_jpg_1.resize(value=awidth)
            pp_png_1 = pp_png_1.resize(value=awidth)
            item_img = item_img.to_overlay_pic_advance(
                mode="pixel",
                top_img=pp_jpg_1,
                base="cs",
                value=(0, 260),
                top_png_img=pp_png_1,
            )

        pp_jpg_1, pp_png_1 = self.image_one_pic(
            return_orign=True,
            goods_art_no=goods_art_no_list[0],
            name="俯视",
        )
        aheight =400
        # 等比计算目标宽度
        awidth = int(pp_jpg_1.width * aheight / pp_jpg_1.height)
        pp_jpg_1 = pp_jpg_1.resize(value=awidth)
        pp_png_1 = pp_png_1.resize(value=awidth)
        item_img = item_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=pp_jpg_1,
            base="cs",
            value=(60, 220),
            top_png_img=pp_png_1,
        )

        font_hei = ImageFont.truetype(r"resources\ttf\simhei.ttf", 40)
        item_img.get_text_image_advanced(
            value=(520, 600),
            font=font_hei,
            text="正面45°/FRONT45°",
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(0, 0, 0),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )

        bg_img = bg_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=item_img,
            base="nc",
            value=(0, 534),
            top_png_img=item_img,
        )

        # item2
        item_img = PictureProcessing("RGBA", (header_img.width, 760), (255,255,255))
        pp_jpg_1, pp_png_1 = self.image_one_pic(
            return_orign=True,
            goods_art_no=goods_art_no_list[0],
            name="后跟",
        )
        aheight =400
        # 等比计算目标宽度
        awidth = int(pp_jpg_1.width * aheight / pp_jpg_1.height)
        pp_jpg_1 = pp_jpg_1.resize(value=awidth)
        pp_png_1 = pp_png_1.resize(value=awidth)
        item_img = item_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=pp_jpg_1,
            base="cs",
            value=(0, 240),
            top_png_img=pp_png_1,
        )
        # pp_jpg_1, pp_png_1 = self.image_one_pic(
        #     return_orign=True,
        #     goods_art_no=goods_art_no_list[0],
        #     name="后跟",
        # )
        # aheight =450
        # # 等比计算目标宽度
        # awidth = int(pp_jpg_1.width * aheight / pp_jpg_1.height)
        # pp_jpg_1 = pp_jpg_1.resize(value=awidth)
        # pp_png_1 = pp_png_1.resize(value=awidth)
        # item_img = item_img.to_overlay_pic_advance(
        #     mode="pixel",
        #     top_img=pp_jpg_1,
        #     base="cs",
        #     value=(-60, 220),
        #     top_png_img=pp_png_1,
        # )

        item_img.get_text_image_advanced(
            value=(520, 600),
            font=font_hei,
            text="背面45°/BACK45°",
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(50, 50, 50),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )
        bg_img = bg_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=item_img,
            base="nc",
            value=(0, 534+760),
            top_png_img=item_img,
        )

        # item3
        item_img = PictureProcessing("RGBA", (header_img.width, 760), (255,255,255))
        pp_jpg_1, pp_png_1 = self.image_one_pic(
            return_orign=True,
            goods_art_no=goods_art_no_list[0],
            name="侧视",
        )

        aheight =350
        # 等比计算目标宽度
        awidth = int(pp_jpg_1.width * aheight / pp_jpg_1.height)
        pp_jpg_1 = pp_jpg_1.resize(value=awidth)
        pp_png_1 = pp_png_1.resize(value=awidth)
        item_img = item_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=pp_jpg_1,
            base="cs",
            value=(0, 220),
            top_png_img=pp_png_1,
        )
        item_img.get_text_image_advanced(
            value=(600, 600),
            font=font_hei,
            text="侧面/SIDE",
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(50, 50, 50),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )
        bg_img = bg_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=item_img,
            base="nc",
            value=(0, 534+760*2),
            top_png_img=item_img,
        )

        # item4
        item_img = PictureProcessing("RGBA", (header_img.width, 760), (255,255,255))
        pp_jpg_1, pp_png_1 = self.image_one_pic(
            return_orign=True,
            goods_art_no=goods_art_no_list[0],
            name="内里",
        )


        awidth = 200
        aheight = int(pp_jpg_1.width * awidth / pp_jpg_1.height)


        pp_jpg_1 = pp_jpg_1.resize(value=aheight)
        pp_png_1 = pp_png_1.resize(value=aheight)

        ty=0
        if self.check_shoe_is_right_by_pixel(im=pp_png_1.im) == False:
            pp_jpg_1 = pp_jpg_1.transpose()
            pp_png_1 = pp_png_1.transpose()
            ty=1

        pp_jpg_1=pp_jpg_1.rotate_advance(doge=90,is_crop=False)
        pp_png_1=pp_png_1.rotate_advance(doge=90,is_crop=False)


        if ty==1:
            pp_jpg_1 = pp_jpg_1.transpose()
            pp_png_1 = pp_png_1.transpose()

        item_img = item_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=pp_png_1,
            base="cs",
            value=(0, -70),
            top_png_img=pp_png_1,
        )
        # pp_jpg_1 = pp_jpg_1.transpose()
        # pp_png_1 = pp_png_1.transpose()
        # item_img = item_img.to_overlay_pic_advance(
        #     mode="pixel",
        #     top_img=pp_png_1,
        #     base="cs",
        #     value=(120, -50),
        #     top_png_img=pp_png_1,
        # )

        item_img.get_text_image_advanced(
            value=(600, 600),
            font=font_hei,
            text="顶面/TOP",
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(50, 50, 50),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )
        bg_img = bg_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=item_img,
            base="nc",
            value=(0, 534+760*3),
            top_png_img=item_img,
        )


        return bg_img

    def deal_pic_12(self):
        # 背景图
        bg_img = PictureProcessing(r"{}\12.jpg".format(self.root))
        return bg_img
