"""
步骤：
1、整理需要处理的款号图-输出款号图文件夹
2、整理所有相关的图片作为素材图
3、按要求进行拼接
"""
import os
from PIL import ImageFont
import sys
import settings

# from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
# from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
is_test_plugins = False
try:
    is_test_plugins = settings.is_test_plugins
except:
    is_test_plugins = False

if is_test_plugins:
    from custom_plugins.plugins_mode.detail_generate_base import DetailBase
    from custom_plugins.plugins_mode.pic_deal import PictureProcessing
else:
    from plugins_mode.detail_generate_base import DetailBase
    from plugins_mode.pic_deal import PictureProcessing

plugins_name = "详情模板"
company_name_list = ["小苏"]
template_name = "xiaosushuoxie-6"


class DetailPicGet(DetailBase):
    need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
    root = r"{}\resources\detail_temp\xiaosushuoxie\6".format(os.getcwd())

    def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False, excel_data=None,
                 assigned_page_list=None):

        super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows, excel_data=excel_data,
                         assigned_page_list=assigned_page_list)
        self.root = r"{}\resources\detail_temp\xiaosushuoxie\6".format(os.getcwd())
        print(template_name)
        self.template_name = template_name
        self.base_bg_color = (228, 196, 147)
        # 缩放倍数
        self.sf = 16/12
        self.deal_pic_func_list = [
            self.deal_pic_1,
            self.deal_pic_2,
            self.deal_pic_3,
            self.deal_pic_4,
            self.deal_pic_5,
            self.deal_pic_6,
            self.deal_pic_7,
            self.deal_pic_8,
            self.deal_pic_9,
        ]
        # test = True
        if test:
            # pp_1 = self.generate_font_list_to_pic()
            # pp_1.im.save(r"C:\Users\gymmc\Desktop\细节图示例/字号.png")
            # for k, v in self.goods_no_value.items():
            #     print(k, v)
            self.run_test()
        else:
            self.run_all()

    def run_test(self):
        detailed_images = []
        # detailed_images.append(self.deal_pic_1())
        # detailed_images.append(self.deal_pic_2())
        # detailed_images.append(self.deal_pic_3())
        # detailed_images.append(self.deal_pic_4())
        # detailed_images.append(self.deal_pic_5())
        # detailed_images.append(self.deal_pic_6())
        detailed_images.append(self.deal_pic_7())
        # detailed_images.append(self.deal_pic_8())
        # detailed_images.append(self.deal_pic_9())
        img = self.add_pic(detailed_images)
        # img.save(r"{}/{}.jpg".format(self.out_put_dir, self.goods_no, format="JPEG"))
        if img:
            img.show()

    def deal_details_beifen(self):
        detailed_images = []
        self.image_list_append(detailed_images, self.deal_pic_1())
        self.image_list_append(detailed_images, self.deal_pic_2())
        self.image_list_append(detailed_images, self.deal_pic_3())
        self.image_list_append(detailed_images, self.deal_pic_4())
        self.image_list_append(detailed_images, self.deal_pic_5())
        self.image_list_append(detailed_images, self.deal_pic_6())
        self.image_list_append(detailed_images, self.deal_pic_7())
        self.image_list_append(detailed_images, self.deal_pic_8())
        self.image_list_append(detailed_images, self.deal_pic_9())
        return [x for x in detailed_images if x]

    # 组合图1
    def deal_pic_1(self):
        pp_bg = PictureProcessing(r"{}\t (1).jpg".format(self.root))

        # -------粘贴文字-------
        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 38)  # 设计理念
        text_list = []
        text_list.append({"text": self.get_text_value("设计理念"),
                          "font": font_1,
                          "fill": (102, 92, 92),
                          })
        text_image = self.add_text_list(text_list, spacing=15, base="nw")
        if text_image:
            pp_bg = pp_bg.paste_img(
                top_img=text_image,
                base="nw",
                value=(20*self.sf, 895*self.sf))

        # ----粘贴组合图
        goods_art_no_list = list(self.data.keys())
        goods_art_no = goods_art_no_list[0]
        view_list = ["组合", "俯视"]
        for view_name in view_list:
            pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
                                                    goods_art_no=goods_art_no,
                                                    name=view_name,
                                                    )
            if not pp_jpg_1:
                continue
            pp_jpg_1: PictureProcessing
            pp_png_1: PictureProcessing
            pp_jpg_1 = pp_jpg_1.resize(base_by_box=(485*self.sf, 588*self.sf))
            pp_png_1 = pp_png_1.resize(base_by_box=(485*self.sf, 588*self.sf))
            pp_bg = pp_bg.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1,
                                                 value=(947*self.sf - pp_jpg_1.width / 2, 888*self.sf - pp_jpg_1.height / 2), base="nw")
            break

        return pp_bg

    # 展示设计理念2和组合2
    def deal_pic_2(self):
        pp_bg = PictureProcessing(r"{}\t (2).jpg".format(self.root))
        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 38)  # 设计理念

        text_list = []
        text_list.append({"text": self.get_text_value("设计理念2"),
                          "font": font_1,
                          "fill": (109, 103, 97),
                          })
        text_image = self.add_text_list(text_list, spacing=15, base="nw")
        if text_image:
            pp_bg = pp_bg.paste_img(
                top_img=text_image,
                base="nw",
                value=(60*self.sf, 141*self.sf))

        # ====粘贴组合2或侧视图
        goods_art_no_list = list(self.data.keys())
        pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
                                                goods_art_no=goods_art_no_list[0],
                                                name="组合2",
                                                )
        if not pp_jpg_1:
            pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
                                                    goods_art_no=goods_art_no_list[0],
                                                    name="侧视",
                                                    )
        pp_jpg_1: PictureProcessing
        pp_png_1: PictureProcessing
        pp_jpg_1 = pp_jpg_1.resize(base_by_box=(546*self.sf, 592*self.sf))
        pp_png_1 = pp_png_1.resize(base_by_box=(546*self.sf, 592*self.sf))

        pp_bg = pp_bg.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1,
                                             value=(786*self.sf - pp_jpg_1.width / 2, 816*self.sf - pp_jpg_1.height / 2))

        return pp_bg

    # 亮点解析
    def deal_pic_3(self):
        detailed_images = []
        detailed_images.append(PictureProcessing(r"{}\t (3).jpg".format(self.root)))
        goods_art_no_list = list(self.data.keys())

        # =====添加内里图
        pp_bg_1 = PictureProcessing(r"{}\t (4).jpg".format(self.root))
        pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
                                                goods_art_no=goods_art_no_list[0],
                                                name="内里",
                                                )
        pp_png_1: PictureProcessing
        pp_png_1 = pp_png_1.resize(value=1600*self.sf)
        pp_png_1 = pp_png_1.paste_img_invert(top_img=PictureProcessing("RGB", (1200*self.sf, 1061*self.sf), (255, 255, 255)),
                                             base="ws",
                                             value=(-85*self.sf, 0))

        # 添加内里描述
        _neili_bg = PictureProcessing(r"{}\t (25).png".format(self.root))
        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 44)  # 内里描述
        text_list = [{"text": self.get_text_value("内里特点"),
                      "font": font_1,
                      "fill": (110, 110, 110),
                      }]
        text_image = self.add_text_list(text_list, spacing=10, base="nc")
        if text_image:
            _neili_bg = _neili_bg.paste_img(
                top_img=text_image,
                base="sc",
                value=(0, 69*self.sf))
        pp_bg_1 = pp_bg_1.paste_img(top_img=pp_png_1, base="sc", value=(0, 266*self.sf))
        pp_bg_1 = pp_bg_1.paste_img(top_img=_neili_bg, base="sc", value=(0, 137*self.sf))
        detailed_images.append(pp_bg_1)

        # ======添加鞋底图====
        pp_2 = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
                                              color_name="鞋底",
                                              bg_color=(255, 255, 255),
                                              )
        pp_2 = pp_2.resize(value=1396*self.sf)
        pp_bg_2 = PictureProcessing("RGB", (1600, pp_2.height + 80*self.sf), (255, 255, 255))
        pp_bg_2 = pp_bg_2.paste_img(top_img=pp_2, base="wc", value=(80*self.sf, 0))
        detailed_images.append(pp_bg_2)

        # --添加鞋底特点
        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 40)  # 内里描述
        text_list = [{"text": self.get_text_value("鞋底特点"),
                      "font": font_1,
                      "fill": (110, 110, 110),
                      }]
        text_image = self.add_text_list(text_list, spacing=10, base="nc")
        if text_image:
            pp_bg_3 = PictureProcessing("RGB", (1600, text_image.height + 80*self.sf), (255, 255, 255))
            pp_bg_3 = pp_bg_3.paste_img(top_img=text_image, base="cc", value=(0, 0))
            detailed_images.append(pp_bg_3)

        # ---添加鞋子的俯视图，并标注尺寸----------------
        pp_bg_4 = PictureProcessing(r"{}\t (6).jpg".format(self.root))
        pp_4 = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
                                              color_name="俯视",
                                              bg_color=(255, 255, 255),
                                              )
        pp_4 = pp_4.resize(value=332 * 1.8*self.sf)
        pp_bg_4 = pp_bg_4.paste_img(top_img=pp_4, base="sc", value=(0, 222*self.sf))
        # -添加文字描述等
        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 34)
        if self.get_text_value("鞋长"):
            text = "长:{}".format(self.get_text_value("鞋长"))
            text_image = pp_bg_4.get_text_image_advanced(font=font_1,
                                                         text=text,
                                                         fill=(110, 110, 110),
                                                         return_mode="min_image")
            pp_bg_4 = pp_bg_4.paste_img(top_img=text_image, base="sc", value=(0, 134*self.sf))
        if self.get_text_value("跟高"):
            text = "跟高:{}".format(self.get_text_value("跟高"))
            text_image = pp_bg_4.get_text_image_advanced(font=font_1,
                                                         text=text,
                                                         fill=(110, 110, 110),
                                                         return_mode="min_image")
            pp_bg_4 = pp_bg_4.paste_img(top_img=text_image, base="se", value=(72*self.sf, 404*self.sf))
        if self.get_text_value("脚掌围"):
            text = "脚掌围:{}".format(self.get_text_value("脚掌围"))
            text_image = pp_bg_4.get_text_image_advanced(font=font_1,
                                                         text=text,
                                                         fill=(110, 110, 110),
                                                         return_mode="min_image")
            pp_bg_4 = pp_bg_4.paste_img(top_img=text_image, base="sw", value=(179*self.sf, 510*self.sf))
        if pp_bg_4.height > pp_4.height + 250*self.sf:
            pp_bg_4 = pp_bg_4.crop(bbox=(0, pp_bg_4.height - pp_4.height - 250*self.sf, pp_bg_4.width, pp_bg_4.height))

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

    # 展示产品信息和颜色图
    def deal_pic_4(self):
        detailed_images = []

        pp_bg_1 = PictureProcessing(r"{}\t (7).jpg".format(self.root))

        # 粘贴产品信息
        # ---添加组合2图片
        color_name_list = ["组合2", "组合", "俯视"]

        goods_art_no_list = list(self.data.keys())

        for color_name in color_name_list:
            pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
                                                    goods_art_no=goods_art_no_list[0],
                                                    name=color_name,
                                                    )
            if not pp_png_1:
                continue

            pp_jpg_1: PictureProcessing
            pp_png_1: PictureProcessing

            pp_jpg_1 = pp_jpg_1.resize(base_by_box=(589*self.sf, 416*self.sf))
            pp_png_1 = pp_png_1.resize(base_by_box=(589*self.sf, 416*self.sf))
            pp_bg_1 = pp_bg_1.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1, base="nc", value=(0, 257*self.sf))
            break

        # ====添加文字信息
        text_list = [{"title": "帮面材质:", "get_text": "鞋面材质"},
                     {"title": "鞋型:", "get_text": "鞋型"},
                     {"title": "内里材质:", "get_text": "内里材质"},
                     {"title": "头型:", "get_text": "头型"},
                     {"title": "大底材质:", "get_text": "鞋底材质"},
                     {"title": "货号:", "get_text": "款号"},
                     ]
        x, y = 176*self.sf, 779*self.sf
        pos_list = [
            (x, y),
            (x + 592*self.sf, y),
            (x, y + 101*self.sf),
            (x + 592*self.sf, y + 101*self.sf),
            (x, y + 101*self.sf + 101*self.sf),
            (x + 592*self.sf, y + 101*self.sf + 101*self.sf),
        ]
        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Regular.ttf", 40)  # 鞋材料信息

        n = -1
        for text_data in text_list:
            text_value = self.get_text_value(text_data["get_text"])
            if text_value:
                n += 1
                text = "{}  {}".format(text_data["title"], text_value)
                text_image = pp_bg_1.get_text_image_advanced(font=font_1,
                                                             text=text,
                                                             fill=(0, 0, 0),
                                                             return_mode="min_image")
                pp_bg_1 = pp_bg_1.paste_img(top_img=text_image, base="nw", value=pos_list[n])

        detailed_images.append(pp_bg_1)
        # =======添加各个颜色====多余高度需要剪裁
        pp_bg_2 = PictureProcessing(r"{}\t (8).jpg".format(self.root))

        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 34)  # 颜色名称
        color_pic_list_1 = []
        color_pic_list_2 = []
        for goods_art_no_dict in self.goods_no_value["货号资料"]:
            color_name = goods_art_no_dict["颜色名称"]
            goods_art_no = goods_art_no_dict["货号"]

            pp_jpg, pp_png = self.image_one_pic(return_orign=True,
                                                goods_art_no=goods_art_no,
                                                name="侧视",
                                                )
            pp_jpg: PictureProcessing
            pp_jpg = pp_jpg.resize(value=390*self.sf)
            pp_png = pp_png.resize(value=390*self.sf)

            pp_jpg = pp_jpg.paste_img_invert(
                top_img=PictureProcessing("RGBA", (pp_jpg.width, pp_jpg.height + 70*self.sf), (255, 255, 255, 0)),
                base="nw"
            )
            pp_png = pp_png.paste_img_invert(
                top_img=PictureProcessing("RGBA", (pp_png.width, pp_png.height + 70*self.sf), (255, 255, 255, 0)),
                base="nw"
            )

            text_image = pp_bg_2.get_text_image_advanced(font=font_2,
                                                         text="{} / COLOR".format(color_name),
                                                         fill=(0, 0, 0),
                                                         return_mode="min_image")

            pp_jpg = pp_jpg.paste_img(top_img=text_image, base="sc", value=(0, 10*self.sf))
            color_pic_list_1.append(pp_jpg)
            color_pic_list_2.append(pp_png)

        # 颜色列表进行等分展示
        all_color_pp_1 = PictureProcessing().horizontal_distribution(color_pic_list_1, bg_width=1114*self.sf, line_spacing=10,
                                                                     number_per_row=2)
        all_color_pp_2 = PictureProcessing().horizontal_distribution(color_pic_list_2, bg_width=1114*self.sf, line_spacing=10,
                                                                     number_per_row=2)

        pp_bg_2 = pp_bg_2.to_overlay_pic_advance(top_img=all_color_pp_1, top_png_img=all_color_pp_2, base="nc",
                                                 value=(0, 131*self.sf))

        if pp_bg_2.height > all_color_pp_1.height + 131*self.sf + 50*self.sf:
            pp_bg_2 = pp_bg_2.crop(
                bbox=(0, 0, pp_bg_2.width, all_color_pp_1.height + 181*self.sf))

        detailed_images.append(pp_bg_2)

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

    # 产品细节
    def deal_pic_5(self):
        detailed_images = []
        detailed_images.append(PictureProcessing(r"{}\t (9).jpg".format(self.root)))
        detailed_images.append(PictureProcessing(r"{}\t (10).jpg".format(self.root)))

        # ==================俯视图鞋头===============
        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 64)  # 主标题
        font_1_color = (1, 1, 1)
        font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 34)  # 副标题
        font_2_color = (51, 51, 51)
        goods_art_no_list = list(self.data.keys())

        view_list = ["俯视", "侧视", "内里", "鞋底"]
        for index, view_name in enumerate(view_list):
            bg = PictureProcessing(r"{}\t (11).jpg".format(self.root))
            text_list = []
            text_list.append({"text": self.get_text_value("提示{}主标题".format(index + 1)),
                              "font": font_1,
                              "fill": font_1_color,
                              })
            # self.get_text_value("提示{}副标题".format(index + 1))
            # text = "副标题副标题副标题副标题副标题副标题副标题副标题\n副标题副标题副标题副标题副标题副标题副标题副标题\n副标题\n副标题\n副标题\n副标题\n副标题"
            text_list.append({"text": self.get_text_value("提示{}副标题".format(index + 1)),
                              "font": font_2,
                              "fill": font_2_color,
                              })
            text_image = self.add_text_list(text_list, spacing=30, base="nc")
            if text_image:
                bg = bg.paste_img(
                    top_img=text_image,
                    base="nc",
                    value=(0, 0))
                bg = bg.crop(bbox=(0, 0, bg.width, text_image.height + 50*self.sf))
                detailed_images.append(bg)

            # ===粘贴图片
            pp_1 = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
                                                  color_name=view_name,
                                                  bg_color=(255, 255, 255)
                                                  )

            if view_name == "俯视":
                resize_value = 1011*self.sf
                paste_img_value = (252*self.sf, 0)
                base = "ws"
            if view_name == "侧视":
                resize_value = 1253*self.sf
                paste_img_value = (270*self.sf, 0)
                base = "es"
            if view_name == "内里":
                resize_value = 1539*self.sf
                paste_img_value = (0, 0)
                base = "ws"
            if view_name == "鞋底":
                resize_value = 1104*self.sf
                paste_img_value = (0, 0)
                base = "cc"

            pp_1 = pp_1.resize(value=resize_value)

            pp_1 = pp_1.paste_img_invert(top_img=PictureProcessing("RGB", (1079*self.sf, 572*self.sf), (255, 255, 255)),
                                         base=base,
                                         value=paste_img_value
                                         )

            bg = PictureProcessing(r"{}\t (11).jpg".format(self.root))
            bg = bg.paste_img(top_img=pp_1,
                              base="nc",
                              value=(0, 0),
                              )
            bg = bg.crop(bbox=(0, 0, bg.width, pp_1.height + 10*self.sf))
            detailed_images.append(bg)

        detailed_images.append(PictureProcessing(r"{}\t (13).jpg".format(self.root)))
        return PictureProcessing(im=self.add_pic(detailed_images))

    # 组合图展示
    def deal_pic_6(self):
        flag = False  # 判断是否有组合图
        detailed_images = []
        pp_bg_1 = PictureProcessing(r"{}\t (15).jpg".format(self.root))
        detailed_images.append(pp_bg_1)
        goods_art_no_list = list(self.data.keys())
        goods_art_no = goods_art_no_list[0]

        # 组合图1
        pp_bg_2 = PictureProcessing(r"{}\t (16).jpg".format(self.root))
        pp_jpg, pp_png = self.image_one_pic(return_orign=True,
                                            goods_art_no=goods_art_no,
                                            name="组合",
                                            )
        if pp_jpg:
            flag = True
            pp_jpg: PictureProcessing
            pp_jpg = pp_jpg.resize(base_by_box=(910 * 0.9*self.sf, 800 * 0.9*self.sf))
            pp_png = pp_png.resize(base_by_box=(910 * 0.9*self.sf, 800 * 0.9*self.sf))
            pp_bg_2 = pp_bg_2.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="cc")
            detailed_images.append(pp_bg_2)

        # ============组合图2
        pp_bg_3 = PictureProcessing(r"{}\t (17).jpg".format(self.root))
        pp_jpg, pp_png = self.image_one_pic(return_orign=True,
                                            goods_art_no=goods_art_no,
                                            name="组合2",
                                            )
        if pp_jpg:
            flag = True
            pp_jpg: PictureProcessing
            pp_jpg = pp_jpg.resize(base_by_box=(937 * 0.9*self.sf, 827 * 0.9*self.sf))
            pp_png = pp_png.resize(base_by_box=(937 * 0.9*self.sf, 827 * 0.9*self.sf))
            pp_bg_3 = pp_bg_3.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="cc")
            detailed_images.append(pp_bg_3)

        # ==========组合图3
        pp_bg_4 = PictureProcessing(r"{}\t (18).jpg".format(self.root))
        detailed_images.append(pp_bg_4)
        pp_bg_5 = PictureProcessing(r"{}\t (19).jpg".format(self.root))
        pp_jpg, pp_png = self.image_one_pic(return_orign=True,
                                            goods_art_no=goods_art_no,
                                            name="组合3",
                                            )
        if pp_jpg:
            flag = True
            pp_jpg: PictureProcessing
            pp_jpg = pp_jpg.resize(base_by_box=(1062*self.sf, 937*self.sf))
            pp_png = pp_png.resize(base_by_box=(1062*self.sf, 937*self.sf))
            pp_bg_5 = pp_bg_5.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="cc")
            detailed_images.append(pp_bg_5)

        if flag:
            return PictureProcessing(im=self.add_pic(detailed_images))
        else:
            return None

    # 各个颜色展示
    def deal_pic_7(self):
        detailed_images = []

        font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 36)  # 副标题
        view_list = ["俯视", "侧视", "后跟", "鞋底"]
        bg_color = (241, 239, 240)
        for goods_art_no_dict in self.goods_no_value["货号资料"]:
            print("523   goods_art_no_dict",goods_art_no_dict)
            bg = PictureProcessing(r"{}\t (20).jpg".format(self.root))
            # bg.show()
            color_name = goods_art_no_dict["颜色名称"]
            goods_art_no = goods_art_no_dict["货号"]

            # 粘贴颜色名称
            if color_name:
                text_image = bg.get_text_image_advanced(font=font_1,
                                                        text="{}".format(color_name),
                                                        fill=(0, 0, 0),
                                                        return_mode="min_image")
                # text_image.show()
                bg = bg.paste_img(top_img=text_image, base="nw", value=(85*self.sf, 35*self.sf))
                # bg.show()
            # 粘贴图片
            for view_name in view_list:
                pp = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no,
                                                    color_name=view_name,
                                                    bg_color=bg_color,
                                                    )
                if view_name == "俯视":
                    pp = pp.resize(base_by_box=(779 * 0.8*self.sf, 838 * 0.8*self.sf))
                    pp = pp.paste_img_invert(top_img=PictureProcessing("RGB", (779*self.sf, 836*self.sf), bg_color), base="cc")
                    bg = bg.paste_img(top_img=pp, value=(38*self.sf, 152*self.sf))
                if view_name == "侧视":
                    pp = pp.resize(base_by_box=(321*self.sf, 244*self.sf))
                    pp = pp.paste_img_invert(top_img=PictureProcessing("RGB", (321*self.sf, 244*self.sf), bg_color), base="cc")
                    bg = bg.paste_img(top_img=pp, value=(844*self.sf, 152*self.sf))

                if view_name == "后跟":
                    pp = pp.resize(base_by_box=(321 * 0.7*self.sf, 278 * 0.9*self.sf))
                    pp = pp.paste_img_invert(top_img=PictureProcessing("RGB", (321*self.sf, 278*self.sf), bg_color), base="cc")
                    bg = bg.paste_img(top_img=pp, value=(844*self.sf, 417*self.sf))
                if view_name == "鞋底":
                    pp = pp.resize(base_by_box=(321*self.sf, 270*self.sf))
                    pp = pp.paste_img_invert(top_img=PictureProcessing("RGB", (321*self.sf, 270*self.sf), bg_color), base="cc")
                    bg = bg.paste_img(top_img=pp, value=(844*self.sf, 720*self.sf))
            detailed_images.append(bg)
        return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))

    # 添加注意事项
    def deal_pic_8(self):
        detailed_images = []
        detailed_images.append(PictureProcessing(r"{}\t (22).jpg".format(self.root)))
        return PictureProcessing(im=self.add_pic(detailed_images))

    # 添加注意事项
    def deal_pic_9(self):
        detailed_images = []
        detailed_images.append(PictureProcessing(r"{}\t (23).jpg".format(self.root)))
        detailed_images.append(PictureProcessing(r"{}\t (24).jpg".format(self.root)))
        return PictureProcessing(im=self.add_pic(detailed_images))
