| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630 |
- """
- 步骤:
- 1、整理需要处理的款号图-输出款号图文件夹
- 2、整理所有相关的图片作为素材图
- 3、按要求进行拼接
- """
- import os
- import settings
- from PIL import ImageFont
- # from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
- # from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
- try:
- is_test_plugins = settings.is_test_plugins
- except:
- is_test_plugins = False
- if is_test_plugins:
- from custom_plugins.plugins_mode.detail_generate_base import DetailBase
- from custom_plugins.plugins_mode.pic_deal import PictureProcessing
- else:
- from plugins_mode.detail_generate_base import DetailBase
- from plugins_mode.pic_deal import PictureProcessing
- from PIL import Image, ImageDraw
- plugins_name = "详情模板"
- company_name_list = ["小苏"]
- template_name = "xiaosushuoxie-7"
- class DetailPicGet(DetailBase):
- need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
- root = r"{}\resources\detail_temp\xiaosushuoxie\7".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\7".format(os.getcwd())
- self.template_name = template_name
- self.base_bg_color = (236, 226, 211)
- self.white_bg_color = (255, 255, 255)
- self.black_bg_color = (0, 0, 0)
- self.deal_pic_func_list = [
- self.deal_pic_1,
- self.deal_pic_2,
- self.deal_pic_3,
- self.deal_pic_4,
- self.deal_pic_5,
- self.deal_pic_6,
- self.deal_pic_7,
- self.deal_pic_8,
- self.deal_pic_9,
- self.deal_pic_10,
- self.deal_pic_11,
- ]
- if test:
- self.run_test()
- else:
- self.run_all()
- def run_test(self):
- detailed_images = []
- detailed_images.append(self.deal_pic_1())
- detailed_images.append(self.deal_pic_2())
- detailed_images.append(self.deal_pic_3())
- detailed_images.append(self.deal_pic_4())
- detailed_images.append(self.deal_pic_5())
- detailed_images.append(self.deal_pic_6())
- detailed_images.append(self.deal_pic_7())
- detailed_images.append(self.deal_pic_8())
- detailed_images.append(self.deal_pic_9())
- detailed_images.append(self.deal_pic_10())
- detailed_images.append(self.deal_pic_11())
- img = self.add_pic(detailed_images)
- img.save(r"{}/{}.jpg".format(self.out_put_dir,self.goods_no, format="JPEG"))
- def deal_pic_1(self):
- """ 制作主图 """
- detailed_images = []
- pp_bg = PictureProcessing(r"{}\first_bg.png".format(self.root))
- # -------粘贴文字-------
- mainTitle = self.get_text_value("主标题")
- subTitle = self.get_text_value("副标题")
- signTitle = self.get_text_value("签名")
- fontMain = ImageFont.truetype(r"resources\ttf\DOUYINSANSBOLD.ttf", 240)
- fontSub = ImageFont.truetype(r"resources\ttf\puhui\Regular.ttf", 40)
- fontSign = ImageFont.truetype(r"resources\ttf\puhui\en\Bold.otf", 40)
- main_text_bg = PictureProcessing("RGBA", (pp_bg.width, 500), (255, 255, 255,0))
- main_text_bg = main_text_bg.get_text_image_advanced(
- value=(0, 0),
- font=fontMain,
- text=mainTitle,
- align="center",
- fill=self.white_bg_color,
- spacing=5,
- return_mode="min_image",
- )
- # 副标题
- sub_text_bg = PictureProcessing("RGBA", (pp_bg.width, 500), (255, 255, 255,0))
- sub_text_bg = sub_text_bg.get_text_image_advanced(
- value=(0, 0),
- font=fontSub,
- text=subTitle,
- align="center",
- fill=self.white_bg_color,
- spacing=5,
- return_mode="min_image",
- )
- # 签名
- sign_text_bg = PictureProcessing("RGBA", (pp_bg.width, 500), (255, 255, 255,0))
- sign_text_bg = sign_text_bg.get_text_image_advanced(
- value=(0, 0),
- font=fontSign,
- text=signTitle,
- align="center",
- fill=self.white_bg_color,
- spacing=5,
- return_mode="min_image",
- )
- pp_bg = pp_bg.paste_img(top_img=main_text_bg,value=(0,208),base='nc')
- pp_bg = pp_bg.paste_img(top_img=sub_text_bg,value=(0,470),base='nc')
- pp_bg = pp_bg.paste_img(top_img=sign_text_bg,value=(0,57),base='nc')
- bottom_bg = PictureProcessing(
- r"{}\bolang.png".format(
- self.root
- )
- )
- pp_bg.paste_img(top_img=bottom_bg, value=(0, 0),base='cs')
- detailed_images.append(pp_bg)
- return PictureProcessing(im=self.add_pic(detailed_images))
- def deal_pic_2(self):
- """
- 细节解析
- """
- # 文字排列
- detailed_images = []
- top_bg = PictureProcessing(
- r"{}\bolang.png".format(
- self.root
- )
- )
- # detailed_images.append(top_bg)
- designText1 = self.get_text_value("设计理念1")
- designText2 = self.get_text_value("设计理念2")
- designText3 = self.get_text_value("设计理念3")
- fontSub = ImageFont.truetype(r"resources\ttf\puhui\Regular.ttf", 60)
- centerDesign = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 65)
- first_text_bg = PictureProcessing("RGB", (top_bg.width, 90), self.white_bg_color)
- first_text_bg = first_text_bg.get_text_image_advanced(
- value=(0, 0),
- font=fontSub,
- text=designText1,
- align="center",
- fill=self.black_bg_color,
- return_mode="min_image",
- )
- temp_text_bg = PictureProcessing("RGB", (top_bg.width, 90), self.white_bg_color)
- temp_text_bg = temp_text_bg.paste_img(top_img=first_text_bg,value=(0,0),base='cc')
- detailed_images.append(temp_text_bg)
- second_text_bg = PictureProcessing("RGB", (top_bg.width, 90), self.white_bg_color)
- second_text_bg = second_text_bg.get_text_image_advanced(
- value=(0, 0),
- font=centerDesign,
- text=designText2,
- align="center",
- fill=self.black_bg_color,
- return_mode="min_image",
- )
- temp_text_bg = PictureProcessing("RGB", (top_bg.width, 90), self.white_bg_color)
- temp_text_bg = temp_text_bg.paste_img(top_img=second_text_bg,value=(0,0),base='cc')
- detailed_images.append(temp_text_bg)
- third_text_bg = PictureProcessing("RGB", (top_bg.width, 90), self.white_bg_color)
- third_text_bg = third_text_bg.get_text_image_advanced(
- value=(0, 0),
- font=fontSub,
- text=designText3,
- align="center",
- fill=self.black_bg_color,
- return_mode="min_image",
- )
- temp_text_bg = PictureProcessing("RGB", (top_bg.width, 90), self.white_bg_color)
- temp_text_bg = temp_text_bg.paste_img(top_img=third_text_bg,value=(0,0),base='cc')
- detailed_images.append(temp_text_bg)
- temp_text_bg = PictureProcessing("RGB", (top_bg.width, 90), self.white_bg_color)
- detailed_images.append(temp_text_bg)
- # 卡片
- pp_list_1 = []
- font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 60)
- fontEN = ImageFont.truetype(r"resources\ttf\puhui\en\Medium.otf", 30)
- goods_art_no_list = list(self.data.keys())
- pp_jpg = self.get_overlay_pic_from_dict(
- goods_art_no=goods_art_no_list[0],
- color_name="俯视",
- bg_color=self.white_bg_color,
- )
- pp_jpg = pp_jpg.resize(value=840)
- text_array = [{"title":self.get_text_value("鞋跟描述")
- ,"bottom":"Comfortable heel","position":(-200, 0)},
- {"title":self.get_text_value("鞋头描述"),
- "position":(200, 0),"bottom":"Versatile Upper"}]
- for index, item in enumerate(text_array):
- text_bg = PictureProcessing("RGBA", (440, 200), (255, 255, 255,0))
- text_bg = text_bg.get_text_image_advanced(
- value=(0, 0),
- font=font,
- text="{}".format(item["title"]),
- align="center",
- spacing=15,
- fill=(255, 255, 255),
- return_mode="min_image",
- margins=(10, 5, 0, 0),
- max_len_one_line=6
- )
- _bg = PictureProcessing("RGB", (520, 880), (208, 186, 162))
- _bg = _bg.radius(circular_pos=(1, 1, 1, 1), value=60)
- _bg = _bg.paste_img(top_img=text_bg, value=(0, 50),base='nc')
- text_bottome = PictureProcessing("RGBA", (440, 200), (255, 255, 255,0))
- text_bottome = text_bottome.get_text_image_advanced(
- value=(0, 0),
- font=fontEN,
- text="{}".format(item["bottom"]),
- align="center",
- spacing=15,
- fill=(255, 255, 255),
- return_mode="min_image",
- margins=(10, 5, 0, 0),
- )
- _bg = _bg.paste_img(top_img=text_bottome, value=(0, 50),base='cs')
- # 第一张图
- first_imageBg = PictureProcessing("RGB", (420, 600), self.white_bg_color)
- first_imageBg.paste_img(top_img=pp_jpg, value=item["position"], base='cc')
- _bg = _bg.paste_img(top_img=first_imageBg, value=(0, 0),base='cc')
- pp_list_1.append(_bg)
- rows = 2
- shoes_bg = PictureProcessing().horizontal_distribution(
- pp_list=pp_list_1,
- bg_width=top_bg.width,
- margins=(0, 0, 50, 50),
- line_spacing=60,
- number_per_row=rows,
- )
- detailed_images.append(shoes_bg)
-
- temp_text_bg = PictureProcessing("RGB", (top_bg.width, 90), self.white_bg_color)
- detailed_images.append(temp_text_bg)
- return PictureProcessing(im=self.add_pic(detailed_images))
- def deal_pic_3(self):
- detailed_images = []
- pp_bg = PictureProcessing(
- r"{}\template_4.jpg".format(
- self.root
- )
- )
- _bg = PictureProcessing("RGB", (pp_bg.width*0.8, pp_bg.height*0.8), self.white_bg_color)
- _bg = _bg.radius(circular_pos=(1, 1, 1, 1), value=60)
- font1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 100)
- font2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 50)
- text_bg = PictureProcessing("RGB", (440, 200), (255, 255, 255))
- text1 = self.get_text_value("面料FAB1")
- if not text1:
- text1 = "轻盈透气"
- text_bg = text_bg.get_text_image_advanced(
- value=(0, 0),
- font=font1,
- text=text1,
- align="left",
- spacing=5,
- fill=(194, 189, 167),
- return_mode="min_image",
- )
- _bg.paste_img(top_img=text_bg, value=(50, 40),base='nw')
- # text2
- text2 = self.get_text_value("面料FAB2")
- if not text2:
- text2 = "(软弹不易累脚)"
- text_bg2 = PictureProcessing("RGB", (440, 200), (255, 255, 255))
- text_bg2 = text_bg2.get_text_image_advanced(
- value=(0, 0),
- font=font2,
- text=text2,
- align="left",
- spacing=5,
- fill=(194, 189, 167),
- return_mode="min_image",
- )
- _bg.paste_img(top_img=text_bg2, value=(50, 140),base='en')
- pp_bg = pp_bg.paste_img(top_img=_bg, value=(0, 0),base='cc')
- detailed_images.append(pp_bg)
- return PictureProcessing(im=self.add_pic(detailed_images))
- def deal_pic_4(self):
- # =============设计理念================
- detail_images = []
- top_bg = PictureProcessing(r"{}\template_5.jpg".format(self.root))
- goods_art_no_list = list(self.data.keys())
- pp_jpg, pp_png = self.image_one_pic(return_orign=True,
- goods_art_no=goods_art_no_list[0],
- name="俯视",
- )
- pp_jpg = pp_jpg.resize(value=round(top_bg.width*0.8))
- pp_png = pp_png.resize(value=round(top_bg.width*0.8))
- top_bg = top_bg.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="cc",value=(0, 0))
- #
- textTitle1 = self.get_text_value("材质FAB1")
- textTitle2 = self.get_text_value("材质FAB2")
- font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 100)
- font2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 60)
- font3 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 50)
- titleBg = PictureProcessing("RGB", (top_bg.width, 200), (255, 255, 255))
- titleBg = titleBg.get_text_image_advanced(
- value=(0, 0),
- font=font,
- text=textTitle1,
- align="left",
- spacing=5,
- fill=(53, 49, 48),
- return_mode="min_image",
- )
- top_bg.paste_img(top_img=titleBg, value=(0, 100),base='nc')
- text_bg2 = PictureProcessing("RGB", (top_bg.width, 200), (255, 255, 255))
- text_bg2 = titleBg.get_text_image_advanced(
- value=(0, 0),
- font=font2,
- text=textTitle2,
- align="left",
- spacing=5,
- fill=(53, 49, 48),
- return_mode="min_image",
- )
- top_bg.paste_img(top_img=text_bg2, value=(0, 230),base='nc')
- textTitle3 = self.get_text_value("材质FAB3")
- text_bg3 = PictureProcessing("RGB", (top_bg.width, 200), (255, 255, 255))
- text_bg3 = text_bg3.get_text_image_advanced(
- value=(0, 0),
- font=font3,
- text=textTitle3,
- align="center",
- spacing=5,
- fill=(53, 49, 48),
- return_mode="min_image",
- max_len_one_line=4
- )
- top_bg.paste_img(top_img=text_bg3, value=(154, 1325),base='nw')
- textTitle4 = self.get_text_value("材质FAB4")
- text_bg4 = PictureProcessing("RGB", (top_bg.width, 200), (255, 255, 255))
- text_bg4 = text_bg4.get_text_image_advanced(
- value=(0, 0),
- font=font3,
- text=textTitle4,
- align="center",
- spacing=5,
- fill=(53, 49, 48),
- return_mode="min_image",
- max_len_one_line=4
- )
- top_bg.paste_img(top_img=text_bg4, value=(0, 1325),base='nc')
- textTitle5 = self.get_text_value("材质FAB5")
- text_bg5 = PictureProcessing("RGB", (top_bg.width, 200), (255, 255, 255))
- text_bg5 = text_bg5.get_text_image_advanced(
- value=(0, 0),
- font=font3,
- text=textTitle5,
- align="center",
- spacing=5,
- fill=(53, 49, 48),
- return_mode="min_image",
- max_len_one_line=4
- )
- top_bg.paste_img(top_img=text_bg5, value=(154, 1325),base='en')
- detail_images.append(top_bg)
- return PictureProcessing(im=self.add_pic(detail_images))
- def deal_pic_5(self):
- detailed_images = []
- goods_art_no_list = list(self.data.keys())
- top_bg = PictureProcessing(
- r"{}\template_6.jpg".format(
- self.root
- )
- )
- detailed_images.append(top_bg)
- return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
- def deal_pic_6(self):
- detailed_images = []
- goods_art_no_list = list(self.data.keys())
- top_bg = PictureProcessing(
- r"{}\template_7.jpg".format(
- self.root
- )
- )
- detailed_images.append(top_bg)
- shoesBg = PictureProcessing("RGB", (top_bg.width, 600), self.white_bg_color)
- pp_jpg = self.get_overlay_pic_from_dict(
- goods_art_no=goods_art_no_list[0],
- color_name="俯视",
- bg_color=self.white_bg_color,
- )
- _, pp_png = self.image_one_pic(return_orign=True,
- goods_art_no=goods_art_no_list[0],
- name="俯视",
- )
- pp_png = pp_png.resize(value=(600))
- pp_jpg = pp_jpg.resize(value=(600))
- hengxian = PictureProcessing(
- r"{}\hengxian.png".format(
- self.root
- )
- )
- shuxian = PictureProcessing(
- r"{}\shuxian.png".format(
- self.root
- )
- )
- bbox = pp_png.get_im().getbbox()
- cropped_img = pp_png.get_im().crop(bbox)
- hengxian = hengxian.resize(value=(cropped_img.width))
- shuxian = shuxian.resize(value=(cropped_img.height),base='high')
- shoesBg.paste_img(top_img=pp_jpg, value=(0, 0),base='cc')
- shoesBg.paste_img(top_img=hengxian, value=(0, 80),base='cs')
- shoesBg.paste_img(top_img=shuxian, value=((shoesBg.width/2- pp_png.width/2), 0),base='ec')
- xiechang = self.get_text_value("鞋长")
- banggao = self.get_text_value("帮高")
- gen_gao = self.get_text_value("跟高")
- xiezhang_kuan = self.get_text_value("鞋掌宽")
- size_font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 30)
-
- xiechang_bg = PictureProcessing("RGBA", (shoesBg.width, 500), (255, 255, 255,0))
- xiechang_bg = xiechang_bg.get_text_image_advanced(
- value=(0, 0),
- font=size_font,
- text=xiechang,
- align="center",
- fill=self.black_bg_color,
- spacing=5,
- return_mode="min_image",
- )
- shoesBg.paste_img(top_img=xiechang_bg, value=(0, 50),base='cs')
-
-
- banggao_bg = PictureProcessing("RGBA", (shoesBg.width, 500), (255, 255, 255,0))
- banggao_bg = banggao_bg.get_text_image_advanced(
- value=(0, 0),
- font=size_font,
- text=banggao,
- align="center",
- fill=self.black_bg_color,
- spacing=5,
- return_mode="min_image",
- )
- shoesBg.paste_img(top_img=banggao_bg,value=((shoesBg.width/2- pp_png.width/2)-140, int(shoesBg.height*0.33)),base='en')
-
- gen_gao_bg = PictureProcessing("RGBA", (shoesBg.width, 500), (255, 255, 255,0))
- gen_gao_bg = gen_gao_bg.get_text_image_advanced(
- value=(0, 0),
- font=size_font,
- text=gen_gao,
- align="center",
- fill=self.black_bg_color,
- spacing=5,
- return_mode="min_image",
- )
- shoesBg.paste_img(top_img=gen_gao_bg,value=((shoesBg.width/2- pp_png.width/2)-140, int(shoesBg.height*0.33)),base='es')
-
-
- xiezhang_kuan_bg = PictureProcessing("RGBA", (shoesBg.width, 500), (255, 255, 255,0))
- xiezhang_kuan_bg = xiezhang_kuan_bg.get_text_image_advanced(
- value=(0, 0),
- font=size_font,
- text=xiezhang_kuan,
- align="center",
- fill=self.black_bg_color,
- spacing=5,
- return_mode="min_image",
- )
- shoesBg.paste_img(top_img=xiezhang_kuan_bg,value=((shoesBg.width/2- pp_png.width/2), int(shoesBg.height*0.33)),base='nw')
-
- detailed_images.append(shoesBg)
- text_bg5 = PictureProcessing("RGB", (top_bg.width, 100), (255, 255, 255))
- detailed_images.append(text_bg5)
- return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
- def deal_pic_7(self):
- detailed_images = []
- top_bg = PictureProcessing(r"{}\template_6.jpg".format(self.root))
- attiribute = PictureProcessing("RGB", (top_bg.width, 300), (255, 255, 255))
- x_position = top_bg.width*0.15
- text_array = [
- {"text":"品牌","position":(x_position,50),"default":"小苏",'base':'nw'},
- {"text":"货号","position":(x_position,50),"default":"未填写",'base':'en'},
- {"text":"鞋面","position":(x_position,120),"default":"未填写",'base':'nw'},
- {"text":"内里","position":(x_position,120),"default":"未填写",'base':'en'},
- {"text":"鞋垫","position":(x_position,190),"default":"未填写",'base':'nw'},
- {"text":"鞋底","position":(x_position,190),"default":"未填写",'base':'en'},
- ]
- size_font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 40)
- for item in text_array:
- text_flag = item["text"]
- position = item["position"]
- default = item["default"]
- base = item["base"]
- text_value = self.get_text_value(item["text"])
- if not text_value:
- text_value = default
- gen_gao_bg = PictureProcessing("RGBA", (top_bg.width, 500), (255, 255, 255,0))
- gen_gao_bg = gen_gao_bg.get_text_image_advanced(
- value=(0, 0),
- font=size_font,
- text=f"【{text_flag}】:{text_value}",
- align="center",
- fill=self.black_bg_color,
- spacing=5,
- return_mode="min_image",
- )
- attiribute.paste_img(top_img=gen_gao_bg, value=position,base=base)
- bottom = PictureProcessing(r"{}\bottom.jpg".format(self.root))
- detailed_images.append(attiribute)
- detailed_images.append(bottom)
- return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
- def deal_pic_8(self):
- detailed_images = []
- top_bg = PictureProcessing(r"{}\template_10.jpg".format(self.root))
- detailed_images.append(top_bg)
- bg_bottom = PictureProcessing("RGB", (top_bg.width, 100), (255, 255, 255))
- detailed_images.append(bg_bottom)
- # ==========添加颜色===================
- pp_list_1 = []
- font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 25)
- goods_art_no_list = list(self.data.keys())
- all_color_name = []
- for index, goods_art_no in enumerate(goods_art_no_list):
- pp_jpg = self.get_overlay_pic_from_dict(
- goods_art_no=goods_art_no,
- color_name="俯视",
- bg_color=self.white_bg_color,
- )
- if pp_jpg is None:
- continue
- pp_jpg = pp_jpg.resize(value=440)
- color_name = self.goods_no_value["货号资料"][index]["颜色名称"]
- all_color_name.append(color_name)
- text_bg = PictureProcessing("RGB", (440, 200), self.white_bg_color)
- text_bg = text_bg.get_text_image_advanced(
- value=(220, 10),
- font=font,
- text="{}".format(color_name),
- align="center",
- anchor="mm",
- spacing=5,
- fill=(55, 55, 55),
- return_mode="min_image_high",
- margins=(10, 5, 0, 0)
- )
- # text_bg.show()
- _bg = PictureProcessing("RGB", (440, pp_jpg.height + text_bg.height), self.white_bg_color)
- _bg = _bg.paste_img(top_img=pp_jpg)
- _bg = _bg.paste_img(top_img=text_bg, value=(0, pp_jpg.height))
- pp_list_1.append(_bg)
- rows = 2
- shoes_bg = PictureProcessing().horizontal_distribution(
- pp_list=pp_list_1,
- bg_width=1200,
- margins=(0, 0, 40, 40),
- line_spacing=60,
- number_per_row=rows,
- )
- detailed_images.append(shoes_bg)
- bg_bottom = PictureProcessing("RGB", (top_bg.width, 100), (255, 255, 255))
- detailed_images.append(bg_bottom)
- return PictureProcessing(im=self.add_pic(detailed_images))
- def deal_pic_9(self):
- detailed_images = []
- goods_art_no_list = list(self.data.keys())
- top_bg = PictureProcessing(r"{}\template_12.jpg".format(self.root))
- detailed_images.append(top_bg)
- # 鞋头
- _bg = PictureProcessing("RGB", (top_bg.width, 600), self.white_bg_color)
- radius_react = PictureProcessing("RGB", (top_bg.width*0.9, 600), (214, 190, 166))
- radius_react = radius_react.radius(circular_pos=(1, 1, 1, 1), value=60)
- _, pp_png = self.image_one_pic(return_orign=True,goods_art_no=goods_art_no_list[0],name="内里")
- pp_png = pp_png.resize(value=round(top_bg.width*1.5))
- pp_png = pp_png.rotate(doge=-120)
- # _bg = _bg.paste_img(top_img=pp_png, value=(0, 0),base='cc')
- radius_react.paste_img(top_img=pp_png, value=(0, 0),base='cc')
- detailed_images.append(radius_react)
- line = PictureProcessing("RGB", (top_bg.width, 100), self.white_bg_color)
- detailed_images.append(line)
- # 鞋跟
- _bg = PictureProcessing("RGB", (top_bg.width, 600), self.white_bg_color)
- radius_react = PictureProcessing("RGB", (top_bg.width*0.9, 600), (214, 190, 166))
- radius_react = radius_react.radius(circular_pos=(1, 1, 1, 1), value=60)
- _bg = _bg.paste_img(top_img=radius_react, value=(0, 0),base='cc')
- detailed_images.append(_bg)
- line = PictureProcessing("RGB", (top_bg.width, 100), self.white_bg_color)
- detailed_images.append(line)
- # 鞋底
- _bg = PictureProcessing("RGB", (top_bg.width, 600), self.white_bg_color)
- radius_react = PictureProcessing("RGB", (top_bg.width*0.9, 600), (214, 190, 166))
- radius_react = radius_react.radius(circular_pos=(1, 1, 1, 1), value=60)
- _bg = _bg.paste_img(top_img=radius_react, value=(0, 0),base='cc')
- pp_jpg, pp_png = self.image_one_pic(return_orign=True,goods_art_no=goods_art_no_list[0],name="俯视")
- pp_jpg = pp_jpg.resize(value=round(top_bg.width*0.8))
- pp_png = pp_png.resize(value=round(top_bg.width*0.8))
- top_bg = top_bg.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="cc",value=(0, 0))
- detailed_images.append(_bg)
- line = PictureProcessing("RGB", (top_bg.width, 100), self.white_bg_color)
- detailed_images.append(line)
- # 鞋底
- return PictureProcessing(im=self.add_pic(detailed_images))
- def deal_pic_10(self):
- # template_15.jpg
- # 模特展示
- top_bg = PictureProcessing(r"{}\template_15.jpg".format(self.root))
- detailed_images = []
- detailed_images.append(top_bg)
- return PictureProcessing(im=self.add_pic(detailed_images))
- def deal_pic_11(self):
- detailed_images = []
- detailed_images.append(PictureProcessing(r"{}\template_22.jpg".format(self.root)))
- return PictureProcessing(im=self.add_pic(detailed_images))
- def get_font_render_size(self, text, font, canvas_size=(2048, 2048)):
- canvas = Image.new('RGB', canvas_size)
- draw = ImageDraw.Draw(canvas)
- draw.text((0, 0), text, font=font, fill=(55, 55, 55))
- bbox = canvas.getbbox()
- # 宽高
- size = (bbox[2] - bbox[0], bbox[3] - bbox[1])
- return size
|