| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962 |
- """
- 步骤:
- 1、整理需要处理的款号图-输出款号图文件夹
- 2、整理所有相关的图片作为素材图
- 3、按要求进行拼接
- """
- from ast import mod
- import os
- import settings
- from PIL import ImageFont
- # from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
- # from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
- is_test_plugins = False
- try:
- is_test_plugins = settings.is_test_plugins
- except:
- is_test_plugins = False
- if is_test_plugins:
- from custom_plugins.plugins_mode.detail_generate_base import DetailBase
- from custom_plugins.plugins_mode.pic_deal import PictureProcessing
- else:
- from plugins_mode.detail_generate_base import DetailBase
- from plugins_mode.pic_deal import PictureProcessing
- plugins_name = "详情模板"
- company_name_list = ["信诺"]
- template_name = "xinnuo-1"
- class DetailPicGet(DetailBase):
- need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
- root = r"{}\resources\detail_temp\xinnuo\1".format(os.getcwd())
- def __init__(
- self,
- goods_no,
- goods_no_value: dict,
- out_put_dir,
- windows=None,
- test=False,
- excel_data=None,
- assigned_page_list=None,
- ):
- super().__init__(
- goods_no,
- goods_no_value,
- out_put_dir,
- windows=windows,
- excel_data=excel_data,
- assigned_page_list=assigned_page_list,
- )
- self.template_name = template_name
- self.root = r"{}\resources\detail_temp\xinnuo\1".format(os.getcwd())
- print("run xinnuo-1 ")
- self.base_bg_color = (255, 255, 255)
- self.base_bg_color_2 = (244, 242, 243)
- self.deal_pic_func_list = [
- self.deal_pic_1,
- self.deal_pic_2,
- self.deal_pic_3,
- self.deal_pic_4,
- self.deal_pic_5,
- self.deal_pic_6,
- self.deal_pic_7,
- self.deal_pic_8,
- self.deal_pic_9,
- self.deal_pic_10,
- self.deal_pic_11,
- self.deal_pic_13,
- self.deal_pic_17,
- self.deal_pic_18,
- self.deal_pic_19,
- self.deal_pic_20,
- self.deal_pic_21,
- ]
- if test:
- # pp = self.generate_font_list_to_pic()
- # pp.im.save(r"C:\Users\gymmc\Desktop\细节图示例/字号.png")
- # for k, v in self.goods_no_value.items():
- # print(k, v)
- self.run_test()
- else:
- self.run_all()
- def run_test(self):
- detailed_images = []
- detailed_images.append(self.deal_pic_1())
- detailed_images.append(self.deal_pic_2())
- detailed_images.append(self.deal_pic_3())
- detailed_images.append(self.deal_pic_4())
- detailed_images.append(self.deal_pic_5())
- detailed_images.append(self.deal_pic_6())
- detailed_images.append(self.deal_pic_7())
- detailed_images.append(self.deal_pic_8())
- detailed_images.append(self.deal_pic_9())
- detailed_images.append(self.deal_pic_10())
- detailed_images.append(self.deal_pic_11())
- detailed_images.append(self.deal_pic_13())
- detailed_images.append(self.deal_pic_17())
- detailed_images.append(self.deal_pic_18())
- detailed_images.append(self.deal_pic_19())
- detailed_images.append(self.deal_pic_20())
- detailed_images.append(self.deal_pic_21())
- img = self.add_pic(detailed_images)
- img.save(r"{}/{}.jpg".format(self.out_put_dir, self.goods_no, format="JPEG"))
- img.show()
- # 标题文字展示
- def deal_pic_1(self):
- pp_bg = PictureProcessing(r"{}\1.jpg".format(self.root),1600)
- font_main = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 102) # 设计理念
- mainTitle = self.get_text_value("主标题")
- subTitle = self.get_text_value("副标题")
- pp_bg.get_text_image_advanced(
- value=(336, 95),
- font=font_main,
- text=mainTitle,
- align="left",
- # anchor="ma",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- font_sub = ImageFont.truetype(
- r"resources\ttf\puhui\Bold.ttf", 40
- ) # 设计理念
- pp_bg.get_text_image_advanced(
- value=(82, 95),
- font=font_sub,
- text=subTitle,
- align="left",
- # anchor="ma",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- goods_art_no_list = list(self.data.keys())
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=goods_art_no_list[0],
- name="俯视",
- )
- 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=pp_bg.width/1.1)
- pp_png_1 = pp_png_1.resize(value=pp_bg.width / 1.1)
- pp_bg = pp_bg.to_overlay_pic_advance(
- top_img=pp_jpg_1, top_png_img=pp_png_1, base="cs", value=(-50, 190)
- )
- pp_bg = pp_bg.to_overlay_pic_advance(
- top_img=pp_jpg_1, top_png_img=pp_png_1, base="cs", value=(50, 130)
- )
- return pp_bg
- # 展示鞋头和后跟
- def deal_pic_2(self):
- pp_bg = PictureProcessing(r"{}\2.jpg".format(self.root), 1600)
- font = ImageFont.truetype(
- r"resources\ttf\puhui\Regular.ttf", 24
- ) # 设计理念
- design_text = self.get_text_value("设计理念")
- text_bg = PictureProcessing("RGBA", (pp_bg.width, 200), (255,255,255,0))
- text_bg = text_bg.get_text_image_advanced(
- value=(0, 0),
- font=font,
- text=design_text,
- align="center",
- spacing=20,
- fill=(88, 52, 28),
- return_mode="min_image",
- )
- pp_bg = pp_bg.paste_img(top_img=text_bg, base="nc", value=(0, 359))
- 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 == None:
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=goods_art_no_list[0],
- name="俯视",
- )
- pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width)
- pp_png_1 = pp_png_1.resize(value=pp_bg.width)
- pp_bg = pp_bg.to_overlay_pic_advance(
- top_img=pp_jpg_1, top_png_img=pp_png_1, base="cs", value=(0, 315)
- )
- return pp_bg
- # 展示鞋头放大图
- def deal_pic_3(self):
- pp_bg = PictureProcessing(r"{}\3.jpg".format(self.root),1600)
- goods_art_no_list = list(self.data.keys())
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=goods_art_no_list[0],
- name="内里",
- )
- pp_jpg_1 = pp_jpg_1.resize(value=1600)
- pp_png_1 = pp_png_1.resize(value=1600)
- # pp_bg = pp_bg.paste_img(top_img=shoe_bg, value=(0, 0), base="nw")
- pp_bg = pp_bg.to_overlay_pic_advance(
- mode="pixel",
- top_img=pp_jpg_1,
- base="sw",
- value=(-pp_bg.width - 100, 280),
- top_png_img=pp_png_1,
- )
- return pp_bg
- # 展示后跟放大图
- def deal_pic_4(self):
- pp_bg = PictureProcessing(r"{}\4.jpg".format(self.root))
- return pp_bg
- # 展示后跟细节卡片
- def deal_pic_5(self):
- pp_bg = PictureProcessing(r"{}\5.jpg".format(self.root))
- return pp_bg
- # "心动"设计亮点,展示旋转的侧视图
- def deal_pic_6(self):
- pp_bg = PictureProcessing(r"{}\6.jpg".format(self.root))
- goods_art_no_list = list(self.data.keys())
- goods_art = goods_art_no_list[0]
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=goods_art,
- name="组合2",
- )
- if pp_jpg_1 == None:
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=goods_art,
- name="俯视",
- )
- pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width/1.4)
- pp_png_1 = pp_png_1.resize(value=pp_bg.width / 1.4)
- # pp_bg = pp_bg.paste_img(top_img=shoe_bg, value=(0, 0), base="nw")
- pp_bg = pp_bg.to_overlay_pic_advance(
- mode="pixel",
- top_img=pp_jpg_1,
- base="center",
- value=(0, 0),
- top_png_img=pp_png_1,
- )
- return pp_bg
- # 产品展示,帮面等等
- def deal_pic_7(self):
- pp_bg = PictureProcessing(r"{}\7.jpg".format(self.root))
- goods_art_no_list = list(self.data.keys())
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=goods_art_no_list[0],
- name="俯视",
- )
- pp_jpg_1 = pp_jpg_1.resize(value=500)
- pp_png_1 = pp_png_1.resize(value=500)
- # pp_bg = pp_bg.paste_img(top_img=shoe_bg, value=(0, 0), base="nw")
- pp_bg = pp_bg.to_overlay_pic_advance(
- mode="pixel",
- top_img=pp_jpg_1,
- base="sw",
- value=(123, 237),
- top_png_img=pp_png_1,
- )
- font = ImageFont.truetype(
- r"resources\ttf\puhui\Medium.ttf", 24
- ) # 设计理念
- font_hei = ImageFont.truetype(r"resources\ttf\simhei.ttf", 24) # 设计理念
- bangmian = self.get_text_value("帮面")
- neili = self.get_text_value("内里")
- xiedi = self.get_text_value("鞋底")
- xiedian = self.get_text_value("鞋垫")
- xiekuan = self.get_text_value("鞋宽")
- banggao = self.get_text_value("帮高")
- gengao = self.get_text_value("跟高")
- pp_bg.get_text_image_advanced(
- value=(230, 351),
- font=font,
- text=bangmian,
- align="left",
- # anchor="ma",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- pp_bg.get_text_image_advanced(
- value=(551, 351),
- font=font,
- text=neili,
- align="left",
- # anchor="ma",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- pp_bg.get_text_image_advanced(
- value=(230, 461),
- font=font,
- text=xiedi,
- align="left",
- # anchor="ma",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- pp_bg.get_text_image_advanced(
- value=(551, 461),
- font=font,
- text=xiedian,
- align="left",
- # anchor="ma",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- pp_bg.get_text_image_advanced(
- value=(64, 901),
- font=font_hei,
- text=f"鞋宽\n{xiekuan}",
- align="left",
- # anchor="ma",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- pp_bg.get_text_image_advanced(
- value=(621, 650),
- font=font_hei,
- text=f"帮高\n{banggao}",
- align="left",
- # anchor="ma",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- pp_bg.get_text_image_advanced(
- value=(621, 752),
- font=font_hei,
- text=f"跟高\n{gengao}",
- align="left",
- # anchor="ma",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- return pp_bg
- # 功能展示与卖点
- def deal_pic_8(self):
- detailed_images = []
- pp_bg = PictureProcessing(r"{}\7.jpg".format(self.root))
- pp_bg_circle = PictureProcessing(r"{}\bg_circle.png".format(self.root))
- # detailed_images.append(pp_bg)
- goods_art_no_list = list(self.data.keys())
- all_color_name = []
- bg_color = (254, 249, 245)
- text_color = (70, 48, 41)
- font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 25)
- goods_art_images = []
- total_height = 0
- for index, goods_art_no in enumerate(goods_art_no_list):
- pp_jpg,pp_png = self.image_one_pic(
- goods_art_no=goods_art_no,
- name="侧视",
- return_orign=True,
- )
- if pp_jpg is None:
- continue
- pp_jpg = pp_jpg.resize(value=pp_bg.width / 2.5)
- pp_png = pp_png.resize(value=pp_bg.width / 2.5)
- color_name = self.goods_no_value["货号资料"][index]["颜色名称"]
- all_color_name.append(color_name)
- text_bg = PictureProcessing("RGBA", (pp_jpg.width, 50), (255,255,255,0))
- text_bg = text_bg.get_text_image_advanced(
- value=(0, 0),
- font=font,
- text="● {}".format(color_name),
- align="center",
- # anchor="mm",
- spacing=5,
- fill=text_color,
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- _bg = PictureProcessing(
- "RGB",
- (pp_bg.width / 2, pp_jpg.height+200),
- bg_color,
- )
- pp_bg_circle = pp_bg_circle.resize(value=_bg.width/2)
- _bg.paste_img(top_img=pp_bg_circle, base="center")
- if (index+1) == 1:
- total_height += _bg.height
- if (index + 1) % 2 != 0 and (index + 1) != 1:
- total_height += _bg.height
- _bg = _bg.to_overlay_pic_advance(top_img=pp_jpg,top_png_img=pp_png, base="center")
- _bg = _bg.paste_img(
- top_img=text_bg, value=(pp_jpg.width / 2, pp_jpg.height+100)
- )
- goods_art_images.append(_bg)
- rows = 2
- shoes_bg = PictureProcessing(
- ).horizontal_distribution(
- pp_list=goods_art_images,
- bg_width=pp_bg.width,
- margins=(0, 0, 0, 0),
- line_spacing=0,
- number_per_row=rows,
- )
- main_bg = PictureProcessing(
- "RGB",
- (pp_bg.width, total_height),
- bg_color,
- )
- main_bg.paste_img(top_img=shoes_bg)
- detailed_images.append(main_bg)
- return PictureProcessing(im=self.add_pic(detailed_images))
- # 添加尺码表
- def deal_pic_9(self):
- image_path = r"{}\9.jpg".format(self.root)
- return PictureProcessing(image_path)
- # 角度展示
- def deal_pic_10(self):
- detailed_images = []
- image_path = r"{}\10.jpg".format(self.root)
- pp_bg = PictureProcessing(image_path,1600)
- pp_arrow = PictureProcessing(r"{}\arrow.png".format(self.root))
- goods_art_no_list = list(self.data.keys())
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=goods_art_no_list[0],
- name="俯视",
- )
- pp_jpg_1 = pp_jpg_1.resize(value=1400)
- pp_png_1 = pp_png_1.resize(value=1400)
- bg_circl = PictureProcessing("RGB", (300, 300), (239, 208, 177))
- bg_circl_paste = PictureProcessing("RGB", (290, 290), (239, 208, 177))
- bg_circl_paste.paste_img(top_img=pp_jpg_1, base="center")
- bg_circl_paste = bg_circl_paste.radius(value=145, circular_pos=(1, 1, 1, 1))
- bg_circl = bg_circl.radius(value=150, circular_pos=(1, 1, 1, 1))
- bg_circl = bg_circl.paste_img(top_img=bg_circl_paste, base="center")
- bg_circl = bg_circl.paste_img(top_img=pp_arrow, base="nc")
- pp_bg = pp_bg.paste_img(top_img=bg_circl, base="nw", value=(63, 493))
- pp_bg = pp_bg.to_overlay_pic_advance(
- mode="pixel",
- top_img=pp_jpg_1,
- base="nw",
- value=(0, pp_bg.height - pp_jpg_1.height),
- top_png_img=pp_png_1,
- )
- font_main = ImageFont.truetype(
- r"resources\ttf\puhui\Medium.ttf", 58
- ) # 设计理念
- mainTitle = self.get_text_value("细节亮点主标题")
- subTitle = self.get_text_value("细节亮点副标题")
- pp_bg.get_text_image_advanced(
- value=(pp_bg.width / 2, 219),
- font=font_main,
- text=mainTitle,
- align="center",
- anchor="ma",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 36) # 设计理念
- pp_bg.get_text_image_advanced(
- value=(pp_bg.width / 2, 313),
- font=font_sub,
- text=subTitle,
- align="center",
- anchor="ma",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- detailed_images.append(pp_bg)
- return self.pp_pic_subsection(
- PictureProcessing(im=self.add_pic(detailed_images))
- )
- # 添加注意事项
- def deal_pic_11(self):
- """
- bg_12_image_path = r"{}\12.jpg".format(self.root)
- bg_12 = PictureProcessing(bg_12_image_path)
- detailed_images.append(bg_12)
- """
- detailed_images = []
- image_path = r"{}\11.png".format(self.root)
- pp_bg = PictureProcessing(image_path, 1600)
- pp_bg_backend = PictureProcessing(
- "RGB", (pp_bg.width, pp_bg.height), (245, 235, 226)
- )
- goods_art_no_list = list(self.data.keys())
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=goods_art_no_list[0],
- name="俯视",
- )
- pp_jpg_1 = pp_jpg_1.resize(value=2000)
- pp_png_1 = pp_png_1.resize(value=2000)
- pp_bg_backend = pp_bg_backend.to_overlay_pic_advance(
- mode="pixel",
- top_img=pp_jpg_1,
- base="cs",
- value=(0, -50),
- top_png_img=pp_png_1,
- )
- font_main = ImageFont.truetype(
- r"resources\ttf\puhui\Medium.ttf", 58
- ) # 设计理念
- pp_bg_backend.get_text_image_advanced(
- value=(pp_bg.width / 2, 219),
- font=font_main,
- text="经 典 系 带",
- align="center",
- anchor="ma",
- spacing=5,
- fill=(107, 70, 61),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 36) # 设计理念
- pp_bg_backend.get_text_image_advanced(
- value=(pp_bg.width / 2, 313),
- font=font_sub,
- text="松 紧 自 由 调 节",
- align="center",
- anchor="ma",
- spacing=5,
- fill=(107, 70, 61),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- pp_bg_backend.paste_img(top_img=pp_bg,base="center")
- detailed_images.append(pp_bg_backend)
- # bg_12_image_path = r"{}\12.jpg".format(self.root)
- # bg_12 = PictureProcessing(bg_12_image_path)
- # detailed_images.append(bg_12)
- return self.pp_pic_subsection(
- PictureProcessing(im=self.add_pic(detailed_images))
- )
- def deal_pic_13(self):
- detailed_images = []
- image_path = r"{}\12.jpg".format(self.root)
- pp_bg = PictureProcessing(image_path,1600)
- detailed_images.append(pp_bg)
- radius_top = PictureProcessing(
- "RGB", (pp_bg.width * 0.75, 40), (255, 255, 255)
- ).radius(value=30, circular_pos=(1, 1, 0, 0))
- radius_top_bg = PictureProcessing("RGB", (pp_bg.width, 40), (253, 246, 237))
- image_list = ["俯视","侧视","后跟"]
- for item in image_list:
- pp_bg_background = PictureProcessing(
- "RGB", (pp_bg.width, 800), (253, 246, 237)
- )
- pp_bg_radius = PictureProcessing(
- "RGB", (pp_bg.width * 0.85, 800), (255, 255, 255)
- )
- radius_top_bg = radius_top_bg.paste_img(top_img=radius_top, base="cc")
- detailed_images.append(radius_top_bg)
- 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=item,
- )
- if item =="俯视":
- 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=pp_bg_radius.width / 1.3)
- pp_png_1 = pp_png_1.resize(value=pp_bg_radius.width / 1.3)
- pp_bg_radius = pp_bg_radius.to_overlay_pic_advance(
- top_img=pp_jpg_1, top_png_img=pp_png_1, base="cc", value=(-50, 0)
- )
- pp_bg_radius = pp_bg_radius.to_overlay_pic_advance(
- top_img=pp_jpg_1, top_png_img=pp_png_1, base="cc", value=(50, 60)
- )
- if item == "侧视":
- 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=pp_bg_radius.width / 1.3)
- pp_png_1 = pp_png_1.resize(value=pp_bg_radius.width / 1.3)
- pp_bg_radius = pp_bg_radius.to_overlay_pic_advance(
- top_img=pp_jpg_1, top_png_img=pp_png_1, base="cc", value=(60, 0)
- )
- pp_bg_radius = pp_bg_radius.to_overlay_pic_advance(
- top_img=pp_jpg_1, top_png_img=pp_png_1, base="cc", value=(-60, 0)
- )
- if item == "后跟":
- pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_radius.width / 2.3)
- pp_png_1 = pp_png_1.resize(value=pp_bg_radius.width / 2.3)
- pp_jpg_1 = pp_jpg_1.transpose()
- pp_png_1 = pp_png_1.transpose()
- pp_bg_radius = pp_bg_radius.to_overlay_pic_advance(
- top_img=pp_jpg_1, top_png_img=pp_png_1, base="cc", value=(130, 0)
- )
- pp_jpg_1 = pp_jpg_1.transpose()
- pp_png_1 = pp_png_1.transpose()
- pp_bg_radius = pp_bg_radius.to_overlay_pic_advance(
- top_img=pp_jpg_1, top_png_img=pp_png_1, base="cc", value=(-130, 0)
- )
- pp_bg_radius = pp_bg_radius.radius(value=30, circular_pos=(1, 1, 1, 1))
- pp_bg_background.paste_img(top_img=pp_bg_radius, base="cc", value=(0, 0))
- detailed_images.append(pp_bg_background)
- radius_bottom = PictureProcessing(
- "RGB", (pp_bg.width * 0.75, 40), (255, 255, 255)
- ).radius(value=30, circular_pos=(0, 0, 1, 1))
- radius_bottom_bg = PictureProcessing("RGB", (pp_bg.width, 40), (253, 246, 237))
- radius_bottom_bg = radius_bottom_bg.paste_img(top_img=radius_bottom, base="cc")
- detailed_images.append(radius_bottom_bg)
- detailed_images.append(
- PictureProcessing("RGB", (pp_bg.width, 50), (253, 246, 237))
- )
- return self.pp_pic_subsection(
- PictureProcessing(im=self.add_pic(detailed_images))
- )
- def deal_pic_17(self):
- # 产品细节
- image_path = r"{}\17.jpg".format(self.root)
- image_path_1 = r"{}\17_1.png".format(self.root)
- detailed_images = []
- pp_bg_1 = PictureProcessing(image_path_1)
- pp_bg = PictureProcessing(image_path)
- goods_art_no_list = list(self.data.keys())
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=goods_art_no_list[0],
- name="俯视",
- )
- pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width+100)
- pp_png_1 = pp_png_1.resize(value=pp_bg.width + 100)
- pp_bg = pp_bg.to_overlay_pic_advance(
- mode="pixel",
- top_img=pp_jpg_1,
- base="cs",
- value=(0, 0),
- top_png_img=pp_png_1,
- )
- mainTitle = self.get_text_value("艺-主标题")
- subTitle = self.get_text_value("艺-副标题")
- font_main = ImageFont.truetype(
- r"resources\ttf\puhui\Medium.ttf", 30
- ) # 设计理念
- pp_bg.get_text_image_advanced(
- value=(113, 545),
- font=font_main,
- text=mainTitle,
- align="left",
- # anchor="ma",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
- pp_bg.get_text_image_advanced(
- value=(113, 602),
- font=font_sub,
- text=subTitle,
- align="left",
- # anchor="ma",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- pp_bg.paste_img(top_img=pp_bg_1)
- detailed_images.append(pp_bg)
- return self.pp_pic_subsection(
- PictureProcessing(im=self.add_pic(detailed_images))
- )
- def deal_pic_18(self):
- image_path = r"{}\18.jpg".format(self.root)
- image_path_1 = r"{}\18_1.png".format(self.root)
- detailed_images = []
- pp_bg_1 = PictureProcessing(image_path_1)
- pp_bg = PictureProcessing(image_path)
- goods_art_no_list = list(self.data.keys())
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=goods_art_no_list[0],
- name="侧视",
- )
- pp_jpg_1 = pp_jpg_1.resize(value=1400)
- pp_png_1 = pp_png_1.resize(value=1400)
- pp_bg = pp_bg.to_overlay_pic_advance(
- mode="pixel",
- top_img=pp_jpg_1,
- base="cs",
- value=(-pp_jpg_1.width/3, 0),
- top_png_img=pp_png_1,
- )
- mainTitle = self.get_text_value("跟-主标题")
- subTitle = self.get_text_value("跟-副标题")
- gengao = self.get_text_value("跟高")
- font_main = ImageFont.truetype(
- r"resources\ttf\puhui\Medium.ttf", 30
- ) # 设计理念
- pp_bg.get_text_image_advanced(
- value=(441, 220),
- font=font_main,
- text=mainTitle,
- align="right",
- # anchor="rs",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
- pp_bg.get_text_image_advanced(
- value=(441, 272),
- font=font_sub,
- text=subTitle,
- align="right",
- # anchor="ls",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- pp_bg.get_text_image_advanced(
- value=(605, 648),
- font=font_main,
- text=gengao,
- align="right",
- # anchor="ls",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- pp_bg.paste_img(top_img=pp_bg_1)
- detailed_images.append(pp_bg)
- return self.pp_pic_subsection(
- PictureProcessing(im=self.add_pic(detailed_images))
- )
- def deal_pic_19(self):
- detailed_images = []
- image_path = r"{}\19.jpg".format(self.root)
- pp_bg = PictureProcessing(image_path)
- # 鞋底
- goods_art_no_list = list(self.data.keys())
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=goods_art_no_list[0],
- name="鞋底",
- )
- pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width)
- pp_png_1 = pp_png_1.resize(value=pp_bg.width)
- pp_bg = pp_bg.to_overlay_pic_advance(
- mode="pixel",
- top_img=pp_jpg_1,
- base="center",
- value=(0, 200),
- top_png_img=pp_png_1,
- )
- mainTitle = self.get_text_value("底-主标题")
- subTitle = self.get_text_value("底-副标题")
- font_main = ImageFont.truetype(
- r"resources\ttf\puhui\Medium.ttf", 30
- ) # 设计理念
- pp_bg.get_text_image_advanced(
- value=(114, 259),
- font=font_main,
- text=mainTitle,
- align="left",
- # anchor="rs",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
- pp_bg.get_text_image_advanced(
- value=(114, 311),
- font=font_sub,
- text=subTitle,
- align="left",
- # anchor="ls",
- spacing=5,
- fill=(60, 40, 29),
- return_mode="image",
- margins=(0, 0, 0, 0),
- )
- # return PictureProcessing(image_path)
- detailed_images.append(pp_bg)
- return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
- def deal_pic_20(self):
- detailed_images = []
- font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 30) # 设计理念
- pp_bg = PictureProcessing(r"{}\20.jpg".format(self.root))
- detailed_images.append(pp_bg)
- goods_art_no_list = list(self.data.keys())
- for item in goods_art_no_list:
- radius_top_bg = PictureProcessing(
- "RGB", (pp_bg.width, 1048), (253, 246, 237)
- )
- bg_radius = PictureProcessing(
- "RGB",
- (pp_bg.width * 0.85, radius_top_bg.height * 0.85),
- (255, 255, 255),
- )
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=item,
- name="俯视",
- )
- pp_jpg_1 = pp_jpg_1.resize(value=bg_radius.width/1.3)
- pp_png_1 = pp_png_1.resize(value=bg_radius.width /1.3)
- bg_radius = bg_radius.to_overlay_pic_advance(
- top_img=pp_jpg_1, top_png_img=pp_png_1, base="nc",value=(0,150)
- )
- bg_radius = bg_radius.radius(value=30)
- text_bg = PictureProcessing(
- "RGBA", (pp_jpg_1.width, 50), (255, 255, 255, 0)
- )
- text_bg = text_bg.get_text_image_advanced(
- value=(0, 0),
- font=font,
- text="斜面展示",
- align="center",
- # anchor="mm",
- spacing=5,
- fill=(70, 45, 36),
- return_mode="min_image",
- margins=(0, 0, 0, 0),
- )
- _bg = PictureProcessing(
- "RGBA",
- (pp_bg.width / 2, pp_png_1.height + 200),
- (255, 255, 255,0),
- )
- _bg.paste_img(top_img=text_bg, base="center")
- bg_radius.paste_img(top_img=_bg, base="center")
- radius_top_bg = radius_top_bg.paste_img(top_img=bg_radius, base="center")
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=item,
- name="内里",
- )
- pp_jpg_1 = pp_jpg_1.resize(value=bg_radius.width / 2)
- pp_png_1 = pp_png_1.resize(value=bg_radius.width / 2)
- bg_radius = bg_radius.to_overlay_pic_advance(
- top_img=pp_jpg_1, top_png_img=pp_png_1, base="sw", value=(0, 150)
- )
- bg_radius = bg_radius.radius(value=30)
- text_bg = PictureProcessing(
- "RGBA", (pp_jpg_1.width, 50), (255, 255, 255, 0)
- )
- text_bg = text_bg.get_text_image_advanced(
- value=(0, 0),
- font=font,
- text="鞋面展示",
- align="center",
- # anchor="mm",
- spacing=5,
- fill=(70, 45, 36),
- return_mode="min_image",
- margins=(0, 0, 0, 0),
- )
- _bg = PictureProcessing(
- "RGBA",
- (pp_bg.width / 2, pp_png_1.height + 150),
- (255, 255, 255, 0),
- )
- _bg.paste_img(top_img=text_bg, base="center")
- bg_radius.paste_img(top_img=_bg, base="sw",value=(-50,-20))
- radius_top_bg = radius_top_bg.paste_img(top_img=bg_radius, base="center")
- pp_jpg_1, pp_png_1 = self.image_one_pic(
- return_orign=True,
- goods_art_no=item,
- name="鞋底",
- )
- pp_jpg_1 = pp_jpg_1.resize(value=bg_radius.width / 2)
- pp_png_1 = pp_png_1.resize(value=bg_radius.width / 2)
- bg_radius = bg_radius.to_overlay_pic_advance(
- top_img=pp_jpg_1, top_png_img=pp_png_1, base="es", value=(0, 150)
- )
- bg_radius = bg_radius.radius(value=30)
- text_bg = PictureProcessing(
- "RGBA", (pp_jpg_1.width, 50), (255, 255, 255, 0)
- )
- text_bg = text_bg.get_text_image_advanced(
- value=(0, 0),
- font=font,
- text="鞋面展示",
- align="center",
- # anchor="mm",
- spacing=5,
- fill=(70, 45, 36),
- return_mode="min_image",
- margins=(0, 0, 0, 0),
- )
- _bg = PictureProcessing(
- "RGBA",
- (pp_bg.width / 2, pp_png_1.height + 150),
- (255, 255, 255, 0),
- )
- _bg.paste_img(top_img=text_bg, base="center")
- bg_radius.paste_img(top_img=_bg, base="es", value=(-50, -20))
- radius_top_bg = radius_top_bg.paste_img(top_img=bg_radius, base="center")
- detailed_images.append(radius_top_bg)
- return self.pp_pic_subsection(
- PictureProcessing(im=self.add_pic(detailed_images))
- )
- def deal_pic_21(self):
- detailed_images = []
- bg_21 = PictureProcessing(r"{}\21.jpg".format(self.root))
- detailed_images.append(bg_21)
- return self.pp_pic_subsection(
- PictureProcessing(im=self.add_pic(detailed_images))
- )
- if __name__ == "__main__":
- d = DetailPicGet(
- goods_no="test",
- goods_no_value={},
- out_put_dir="./output/xinnuo-1",
- test=True,
- )
- d.run_test()
|