"""
步骤：
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-2"


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




        if pp_jpg_1.height > pp_jpg_1.width:
            aheight =550
            # 等比计算目标宽度
            awidth = int(pp_jpg_1.width * aheight / pp_jpg_1.height)
        else:
            awidth = int(pp_jpg_1.width * 0.45)





        pp_jpg_1 = pp_jpg_1.resize(value=awidth)
        pp_png_1 = pp_png_1.resize(value=awidth)
        pp_bg_1 = pp_bg_1.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1, base="cs",value=(-200, 450))
        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_jpg_1 = pp_jpg_1.transpose()
            pp_png_1 = pp_png_1.transpose()



        pp_jpg_1 = pp_jpg_1.resize(value=round(pp_bg_1.width*(800/1080)))
        pp_png_1 = pp_png_1.resize(value=round(pp_bg_1.width*(800/1080)))
        pp_jpg_1=pp_jpg_1.rotate_advance(doge=10,is_crop=False)
        pp_png_1=pp_png_1.rotate_advance(doge=10,is_crop=False)
        pp_bg_1 = pp_bg_1.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1, base="cs",value=(150, -250))
        detailed_images.append(pp_bg_1)
        return PictureProcessing(im=self.add_pic(detailed_images))

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

        font_cc = ImageFont.truetype(r"resources\ttf\simhei.ttf", 80)  # 颜色名
        font_gg = ImageFont.truetype(r"resources\ttf\simhei.ttf", 50)  # 商品名
        yanseming  = self.get_text_value("颜色名") or ""
        shangpinming = self.get_text_value("商品名") or ""

        bg_img.get_text_image_advanced(
            value=(60, 310),
            font=font_cc,
            text="{"+yanseming+"}",
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(141, 86, 32),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )
        bg_img.get_text_image_advanced(
            value=(450, 320),
            font=font_gg,
            text=shangpinming,
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(141, 86, 32),
            return_mode="image",
            margins=(0, 0, 0, 0),
        )

        return bg_img
    def deal_pic_3(self):

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

        font_gg = ImageFont.truetype(r"resources\ttf\simhei.ttf", 50)  # 商品名
        yanseming  = self.get_text_value("颜色名") or ""
        shangpinming = self.get_text_value("商品名") or ""
        # a="{"+yanseming+shangpinming+"}"
        a=""
        bg_img.get_text_image_advanced(
            value=(488, 140),
            font=font_gg,
            text=a,
            align="left",
            # anchor="ma",
            spacing=5,
            fill=(141, 86, 32),
            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) == 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*(650/1080)))
        pp_png_1 = pp_png_1.resize(value=round(bg_img.width*(650/1080)))
        pp_jpg_1=pp_jpg_1.rotate_advance(doge=15,is_crop=False)
        pp_png_1=pp_png_1.rotate_advance(doge=15,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=(50, 1420))

        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*(650/1080)))
        pp_png_1 = pp_png_1.resize(value=round(bg_img.width*(650/1080)))
        pp_jpg_1=pp_jpg_1.rotate_advance(doge=-8,is_crop=False)
        pp_png_1=pp_png_1.rotate_advance(doge=-8,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=(-100, 950))

        # 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_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=650)
        #
        # 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=(50, 400),
        #     top_png_img=pp_png_1,
        # )
        # 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))
        #
        # aaa_img = aaa_img.paste_img(top_img=pp_png_1,base="cc", value=(0, 0))
        #
        # pp_png_1 = aaa_img.rotate(-8)
        # bg_img = bg_img.to_overlay_pic_advance(
        #     mode="pixel",
        #     top_img=pp_png_1,
        #     base="cs",
        #     value=(-100, -140),
        #     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_4(self):
        # 背景图
        bg_img = PictureProcessing(r"{}\4.jpg".format(self.root))
        return bg_img

    def deal_pic_5(self):
        # 背景图
        bg_img = PictureProcessing(r"{}\5.jpg".format(self.root))
        return bg_img
    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=896)
            bg_img = PictureProcessing("RGB", (hh_img.width, hh_img.height+mote_img.height+90), (252,238,225))
            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-1.jpg".format(self.root))
            mote_img = PictureProcessing(self.get_text_value("场景图"))
            mote_img = mote_img.resize(value=896)
            ff_img = PictureProcessing(r"{}\7-2.jpg".format(self.root))
            bg_img = PictureProcessing("RGB", (hh_img.width, hh_img.height+mote_img.height+ff_img.height), (252,238,225))
            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))
            bg_img = bg_img.paste_img(top_img=ff_img,base="nc", value=(0, hh_img.height+mote_img.height))
            return bg_img
        else:
            return
    def deal_pic_8(self):

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

        aaa_img = PictureProcessing("RGBA", (pp_jpg_1.width*1.2, pp_jpg_1.height*1.2), (255,255,255,0))
        if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
            pp_png_1 = pp_png_1.transpose()
            pp_jpg_1 = pp_jpg_1.transpose()

        pp_jpg_1 = pp_jpg_1.resize(value=int(round(bg_img.width * 660 / 1080)))
        pp_png_1 = pp_png_1.resize(value=int(round(bg_img.width * 660 / 1080)))


        pw=pp_png_1.width
        ph=pp_png_1.height

        aaa_img = aaa_img.paste_img(top_img=pp_png_1,base="cc", value=(0, 0))


        pp_png_1 = aaa_img.rotate(15)
        print("811111111111111111")
        print(ph/pw)
        if (ph/pw)>1:
            posy=(-1)*int(round(bg_img.height * 0.27))
        elif (ph/pw)>0.8:
            posy=(-1)*int(round(bg_img.height * 0.225))
        else:
            posy=(-1)*int(round(bg_img.height * 0.20))
        posx=-10

        # posy=int(round(bg_img.height * 0.01))
        # print(posy)

        bg_img = bg_img.to_overlay_pic_advance(
            mode="pixel",
            top_img=pp_png_1,
            base="cc",
            value=(posx, posy),
            top_png_img=pp_png_1,
        )

        bg_img1 = PictureProcessing("RGB", (bg_img.width, 1080), (255,255,255))
        bg_img1 = bg_img1.paste_img(top_img=bg_img,base="nc", value=(0, 0))

        # hover_img = PictureProcessing(r"{}\8-1.png".format(self.root))
        # bg_img = bg_img.to_overlay_pic_advance(
        #     mode="pixel",
        #     top_img=hover_img,
        #     base="nc",
        #     value=(0, -1),
        #     top_png_img=hover_img,
        # )
        return bg_img1

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

        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="俯视",
            )
            if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
                pp_png_1 = pp_png_1.transpose()
                pp_jpg_1 = pp_jpg_1.transpose()
            pp_jpg_1 = pp_jpg_1.resize(value=460)
            pp_png_1 = pp_png_1.resize(value=460)
            bg_img = bg_img.to_overlay_pic_advance(
                mode="pixel",
                top_img=pp_jpg_1,
                base="cs",
                value=(-60, 320),
                top_png_img=pp_png_1,
            )

            if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
                pp_png_1 = pp_png_1.transpose()
                pp_jpg_1 = pp_jpg_1.transpose()

            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=460)
            pp_png_1 = pp_png_1.resize(value=460)
            bg_img = bg_img.to_overlay_pic_advance(
                mode="pixel",
                top_img=pp_jpg_1,
                base="cs",
                value=(0, 280),
                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="俯视",
            )
            if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
                pp_png_1 = pp_png_1.transpose()
                pp_jpg_1 = pp_jpg_1.transpose()
            pp_jpg_1 = pp_jpg_1.resize(value=460)
            pp_png_1 = pp_png_1.resize(value=460)
            bg_img = bg_img.to_overlay_pic_advance(
                mode="pixel",
                top_img=pp_jpg_1,
                base="cs",
                value=(60, 240),
                top_png_img=pp_png_1,
            )

        elif length==2:

            pp_jpg_1, pp_png_1 = self.image_one_pic(
                return_orign=True,
                goods_art_no=goods_art_no_list[1],
                name="俯视",
            )
            if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
                pp_png_1 = pp_png_1.transpose()
                pp_jpg_1 = pp_jpg_1.transpose()
            pp_jpg_1 = pp_jpg_1.resize(value=460)
            pp_png_1 = pp_png_1.resize(value=460)
            bg_img = bg_img.to_overlay_pic_advance(
                mode="pixel",
                top_img=pp_jpg_1,
                base="cs",
                value=(-40, 300),
                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="俯视",
            )
            if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
                pp_png_1 = pp_png_1.transpose()
                pp_jpg_1 = pp_jpg_1.transpose()
            pp_jpg_1 = pp_jpg_1.resize(value=460)
            pp_png_1 = pp_png_1.resize(value=460)
            bg_img = bg_img.to_overlay_pic_advance(
                mode="pixel",
                top_img=pp_jpg_1,
                base="cs",
                value=(40, 260),
                top_png_img=pp_png_1,
            )

        elif length==1:
            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_png_1 = pp_png_1.transpose()
                pp_jpg_1 = pp_jpg_1.transpose()
            pp_jpg_1 = pp_jpg_1.resize(value=460)
            pp_png_1 = pp_png_1.resize(value=460)
            bg_img = bg_img.to_overlay_pic_advance(
                mode="pixel",
                top_img=pp_jpg_1,
                base="cs",
                value=(0, 280),
                top_png_img=pp_png_1,
            )

        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="俯视",
        )
        if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
            pp_png_1 = pp_png_1.transpose()
            pp_jpg_1 = pp_jpg_1.transpose()


        if pp_jpg_1.height > pp_jpg_1.width:
            aheight =350
            # 等比计算目标宽度
            awidth = int(pp_jpg_1.width * aheight / pp_jpg_1.height)
        else:
            if pp_jpg_1.height > (pp_jpg_1.width/2):
                awidth = int(pp_jpg_1.width * 0.13)
            else:
                awidth = int(pp_jpg_1.width * 0.30)


        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=(-15, 2325),
            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=(226, 1326),
            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=(722, 1326),
            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=(226, 1525),
            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=(722, 1525),
            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=(226, 1728),
            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"
        tonggao = self.get_text_value("筒高") or "13.2CM"
        gengao = self.get_text_value("跟高") or "4CM"
        tongziwei = self.get_text_value("筒口围") or "28CM"

        bg_img.get_text_image_advanced(
            value=(270, 770),
            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=(442, 1027),
            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=(770, 734),
            font=font_hei,
            text="筒高"+tonggao,
            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=(787, 875),
            font=font_hei,
            text="跟高"+gengao,
            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=(545, 557),
            font=font_hei,
            text="筒口围"+tongziwei,
            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="侧视",
        #     )
        #     if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
        #         pp_png_1 = pp_png_1.transpose()
        #         pp_jpg_1 = pp_jpg_1.transpose()
        #     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, 1240),
        #         top_png_img=pp_png_1,
        #     )
        #
        #     bg_img.get_text_image_advanced(
        #         value=(190, 2110),
        #         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="侧视",
        #     )
        #     if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
        #         pp_png_1 = pp_png_1.transpose()
        #         pp_jpg_1 = pp_jpg_1.transpose()
        #     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, 1240),
        #         top_png_img=pp_png_1,
        #     )
        #
        #     bg_img.get_text_image_advanced(
        #         value=(510, 2110),
        #         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="侧视",
        #     )
        #     if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
        #         pp_png_1 = pp_png_1.transpose()
        #         pp_jpg_1 = pp_jpg_1.transpose()
        #     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, 1240),
        #         top_png_img=pp_png_1,
        #     )
        #
        #     bg_img.get_text_image_advanced(
        #         value=(830, 2110),
        #         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="侧视",
        #     )
        #     if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
        #         pp_png_1 = pp_png_1.transpose()
        #         pp_jpg_1 = pp_jpg_1.transpose()
        #     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, 1240),
        #         top_png_img=pp_png_1,
        #     )
        #
        #     bg_img.get_text_image_advanced(
        #         value=(190, 2110),
        #         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="侧视",
        #     )
        #     if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
        #         pp_png_1 = pp_png_1.transpose()
        #         pp_jpg_1 = pp_jpg_1.transpose()
        #     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, 1240),
        #         top_png_img=pp_png_1,
        #     )
        #
        #     bg_img.get_text_image_advanced(
        #         value=(830, 2110),
        #         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[0],
        #         name="侧视",
        #     )
        #     if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
        #         pp_png_1 = pp_png_1.transpose()
        #         pp_jpg_1 = pp_jpg_1.transpose()
        #     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, 1240),
        #         top_png_img=pp_png_1,
        #     )
        #
        #     bg_img.get_text_image_advanced(
        #         value=(510, 2110),
        #         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),
        #     )

        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, 1150),
            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, 3440), (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))



        if len(goods_art_no_list)==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)
            if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
                pp_png_1 = pp_png_1.transpose()
                pp_jpg_1 = pp_jpg_1.transpose()
            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 len(goods_art_no_list)>=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)
            if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
                pp_png_1 = pp_png_1.transpose()
                pp_jpg_1 = pp_jpg_1.transpose()
            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)
        if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
            pp_png_1 = pp_png_1.transpose()
            pp_jpg_1 = pp_jpg_1.transpose()
        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", 24)
        item_img.get_text_image_advanced(
            value=(436, 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, 400),
            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, 220),
            top_png_img=pp_png_1,
        )
        font_hei = ImageFont.truetype(r"resources\ttf\simhei.ttf", 24)
        item_img.get_text_image_advanced(
            value=(436, 600),
            font=font_hei,
            text="背面45°/BACK45°",
            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, 400+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="侧视",
        )
        if self.check_shoe_is_right_by_pixel(im=pp_png_1.im)== True:
            pp_png_1 = pp_png_1.transpose()
            pp_jpg_1 = pp_jpg_1.transpose()

        aheight =380
        # 等比计算目标宽度
        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,
        )
        font_hei = ImageFont.truetype(r"resources\ttf\simhei.ttf", 24)
        item_img.get_text_image_advanced(
            value=(500, 600),
            font=font_hei,
            text="侧面/SIDE",
            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, 400+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="内里",
        )



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


        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, -50),
            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,
        # )

        font_hei = ImageFont.truetype(r"resources\ttf\simhei.ttf", 24)
        item_img.get_text_image_advanced(
            value=(500, 600),
            font=font_hei,
            text="顶面/TOP",
            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, 400+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
