|
|
@@ -0,0 +1,288 @@
|
|
|
+"""
|
|
|
+步骤:
|
|
|
+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 = "qingyangyizhan-2"
|
|
|
+# "俯视", "侧视", "后跟", "鞋底", "内里" 组合,组合2
|
|
|
+
|
|
|
+class DetailPicGet(DetailBase):
|
|
|
+ need_view = ["俯视", "侧视", "后跟", "鞋底"]
|
|
|
+ root = r"{}\resources\detail_temp\qingyangyizhan\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\qingyangyizhan\2".format(os.getcwd())
|
|
|
+ print(f"run {template_name} ")
|
|
|
+ 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_5,
|
|
|
+ self.deal_pic_6,
|
|
|
+ self.deal_pic_6_1,
|
|
|
+ self.deal_pic_7,
|
|
|
+ ]
|
|
|
+
|
|
|
+ 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_5())
|
|
|
+ detailed_images.append(self.deal_pic_6())
|
|
|
+ detailed_images.append(self.deal_pic_6_1())
|
|
|
+ detailed_images.append(self.deal_pic_7())
|
|
|
+
|
|
|
+ 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):
|
|
|
+ detailed_images = []
|
|
|
+ pp_bg = PictureProcessing(r"{}\1.jpg".format(self.root),1600)
|
|
|
+ pp_bg2 = PictureProcessing(r"{}\2.jpg".format(self.root),1600)
|
|
|
+ pp_bg2_1 = PictureProcessing(r"{}\3.jpg".format(self.root),1600)
|
|
|
+ pp_bg2_2 = PictureProcessing(r"{}\4.jpg".format(self.root),1600)
|
|
|
+ pp_bg3 = PictureProcessing(r"{}\5.jpg".format(self.root),1600)
|
|
|
+ detailed_images.append(pp_bg)
|
|
|
+ detailed_images.append(pp_bg2)
|
|
|
+ detailed_images.append(pp_bg2_1)
|
|
|
+ detailed_images.append(pp_bg2_2)
|
|
|
+ goods_art_no_list = list(self.data.keys())
|
|
|
+ _, pp_png_1 = self.image_one_pic(
|
|
|
+ return_orign=True,
|
|
|
+ goods_art_no=goods_art_no_list[0],
|
|
|
+ name="鞋底",
|
|
|
+ )
|
|
|
+ pp_png_1 = pp_png_1.resize(value=pp_bg3.width/3)
|
|
|
+ pp_bg3 = pp_bg3.paste_img(top_img=pp_png_1, base="cc", value=(0, -30))
|
|
|
+ detailed_images.append(pp_bg3)
|
|
|
+ return PictureProcessing(im=self.add_pic(detailed_images))
|
|
|
+
|
|
|
+ # 展示鞋头和后跟
|
|
|
+ def deal_pic_2(self):
|
|
|
+ detailed_images = []
|
|
|
+ pp_bg = PictureProcessing(r"{}\6.jpg".format(self.root), 1600)
|
|
|
+ pp_bg_1 = PictureProcessing(r"{}\7.jpg".format(self.root), 1600)
|
|
|
+ pp_bg_2 = PictureProcessing(r"{}\8.jpg".format(self.root), 1600)
|
|
|
+ pp_bg_special_bg = PictureProcessing(r"{}\special_bg.png".format(self.root), 1600)
|
|
|
+ pp_bg_special_text = PictureProcessing(r"{}\special_bottom.png".format(self.root), 1600)
|
|
|
+ goods_art_no_list = list(self.data.keys())
|
|
|
+ _, pp_png_1 = self.image_one_pic(
|
|
|
+ return_orign=True,
|
|
|
+ goods_art_no=goods_art_no_list[0],
|
|
|
+ name="鞋底",
|
|
|
+ )
|
|
|
+ pp_bg5 = PictureProcessing(
|
|
|
+ "RGB", (pp_bg.width,pp_bg_special_bg.height), (255, 255, 255, 255)
|
|
|
+ )
|
|
|
+ pp_bg5 = pp_bg5.paste_img(top_img=pp_bg_special_bg, base="cc", value=(0, 0))
|
|
|
+ product_past_canvas = PictureProcessing(
|
|
|
+ "RGBA", (pp_bg.width, pp_png_1.height/2), (255, 255, 255, 0)
|
|
|
+ )
|
|
|
+ # pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width)
|
|
|
+ pp_png_1 = pp_png_1.crop(mode="min")
|
|
|
+ pp_png_1 = pp_png_1.resize(value=pp_bg.width/2)
|
|
|
+ product_past_canvas = product_past_canvas.paste_img(top_img=pp_png_1, base="nc", value=(0, -100))
|
|
|
+ # product_past_canvas = product_past_canvas.rotate(doge=-100)
|
|
|
+ pp_bg5 = pp_bg5.paste_img(top_img=product_past_canvas, base="nc", value=(0, 0))
|
|
|
+ pp_bg5 = pp_bg5.paste_img(top_img=pp_bg_special_text, base="cs", value=(0, 0))
|
|
|
+ detailed_images.append(pp_bg)
|
|
|
+ detailed_images.append(pp_bg_1)
|
|
|
+ detailed_images.append(pp_bg_2)
|
|
|
+ detailed_images.append(pp_bg5)
|
|
|
+ return PictureProcessing(im=self.add_pic(detailed_images))
|
|
|
+
|
|
|
+ # 展示鞋头放大图
|
|
|
+ def deal_pic_3(self):
|
|
|
+ detailed_images = []
|
|
|
+ pp_bg = PictureProcessing(r"{}\6.jpg".format(self.root), 1600)
|
|
|
+ detailed_images.append(pp_bg)
|
|
|
+ return PictureProcessing(im=self.add_pic(detailed_images))
|
|
|
+
|
|
|
+ # 展示后跟放大图
|
|
|
+ def deal_pic_4(self):
|
|
|
+ detailed_images = []
|
|
|
+ pp_bg = PictureProcessing(r"{}\10.jpg".format(self.root))
|
|
|
+ goods_art_no_list = list(self.data.keys())
|
|
|
+ _, pp_png_1 = self.image_one_pic(
|
|
|
+ return_orign=True,
|
|
|
+ goods_art_no=goods_art_no_list[0],
|
|
|
+ name="俯视",
|
|
|
+ )
|
|
|
+ product_past_canvas = PictureProcessing(
|
|
|
+ "RGBA", (pp_bg.width*1.5, pp_png_1.height*1.5 + 350), (255, 255, 255, 0)
|
|
|
+ )
|
|
|
+ pp_png_1 = pp_png_1.crop(mode="min")
|
|
|
+ pp_png_1 = pp_png_1.resize(value=pp_bg.width*3)
|
|
|
+ product_past_canvas = product_past_canvas.paste_img(top_img=pp_png_1, base="cc", value=(0, 0))
|
|
|
+ product_past_canvas = product_past_canvas.rotate(doge=-105)
|
|
|
+ pp_bg = pp_bg.paste_img(top_img=product_past_canvas, base="cc", value=(100,50))
|
|
|
+ detailed_images.append(pp_bg)
|
|
|
+ return PictureProcessing(im=self.add_pic(detailed_images))
|
|
|
+
|
|
|
+ # 展示后跟细节卡片
|
|
|
+ def deal_pic_5(self):
|
|
|
+ detailed_images = []
|
|
|
+ pp_bg = PictureProcessing(r"{}\10.jpg".format(self.root))
|
|
|
+ goods_art_no_list = list(self.data.keys())
|
|
|
+ _, pp_png_1 = self.image_one_pic(
|
|
|
+ return_orign=True,
|
|
|
+ goods_art_no=goods_art_no_list[0],
|
|
|
+ name="俯视",
|
|
|
+ )
|
|
|
+ product_past_canvas = PictureProcessing(
|
|
|
+ "RGBA", (pp_bg.width*2, pp_png_1.height*2 + 350), (255, 255, 255, 0)
|
|
|
+ )
|
|
|
+ pp_png_1 = pp_png_1.resize(value=pp_bg.width*1.4)
|
|
|
+ product_past_canvas = product_past_canvas.paste_img(top_img=pp_png_1, base="cc", value=(0, 0))
|
|
|
+ product_past_canvas =product_past_canvas.rotate(doge=-95)
|
|
|
+ pp_bg = pp_bg.paste_img(top_img=product_past_canvas, base="cc", value=(-130, 130))
|
|
|
+ detailed_images.append(pp_bg)
|
|
|
+ return PictureProcessing(im=self.add_pic(detailed_images))
|
|
|
+
|
|
|
+ # "心动"设计亮点,展示旋转的侧视图
|
|
|
+ def deal_pic_6(self):
|
|
|
+ detailed_images = []
|
|
|
+ pp_bg = PictureProcessing(r"{}\11.jpg".format(self.root))
|
|
|
+ pp_bg1 = PictureProcessing(r"{}\12.jpg".format(self.root))
|
|
|
+ pp_bg2 = PictureProcessing(r"{}\13.jpg".format(self.root))
|
|
|
+ detailed_images.append(pp_bg)
|
|
|
+ detailed_images.append(pp_bg1)
|
|
|
+ detailed_images.append(pp_bg2)
|
|
|
+ return PictureProcessing(im=self.add_pic(detailed_images))
|
|
|
+ def deal_pic_6_1(self):
|
|
|
+ detailed_images = []
|
|
|
+ pp_bg = PictureProcessing(r"{}\14.jpg".format(self.root))
|
|
|
+ pp_bg1 = PictureProcessing(r"{}\15.jpg".format(self.root))
|
|
|
+ goods_art_no_list = list(self.data.keys())
|
|
|
+ _, pp_png_1 = self.image_one_pic(
|
|
|
+ return_orign=True,
|
|
|
+ goods_art_no=goods_art_no_list[0],
|
|
|
+ name="鞋底",
|
|
|
+ )
|
|
|
+ product_past_canvas = PictureProcessing(
|
|
|
+ "RGBA", (pp_bg.width*2, pp_png_1.height*2 + 350), (255, 255, 255, 0)
|
|
|
+ )
|
|
|
+ pp_png_1 = pp_png_1.resize(value=pp_bg.width/3.8)
|
|
|
+ product_past_canvas = product_past_canvas.paste_img(top_img=pp_png_1, base="cc", value=(0, 0))
|
|
|
+ product_past_canvas =product_past_canvas.rotate(doge=-8)
|
|
|
+ pp_bg = pp_bg.paste_img(top_img=product_past_canvas, base="cc", value=(0, 150))
|
|
|
+ detailed_images.append(pp_bg)
|
|
|
+ detailed_images.append(pp_bg1)
|
|
|
+ return PictureProcessing(im=self.add_pic(detailed_images))
|
|
|
+ # 产品展示,帮面等等
|
|
|
+ def deal_pic_7(self):
|
|
|
+ detailed_images = []
|
|
|
+ pp_bg = PictureProcessing(r"{}\16.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_png_1 = pp_png_1.resize(value=pp_bg.width*1.1)
|
|
|
+ # pp_jpg_1 = pp_jpg_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="cc", value=(0, 0))
|
|
|
+ product_past_canvas = PictureProcessing(
|
|
|
+ "RGBA", (pp_bg.width*3, pp_png_1.height*3 + 350), (255, 255, 255, 0)
|
|
|
+ )
|
|
|
+ # pp_png_1 = pp_png_1.resize(value=pp_bg.width/3.8)
|
|
|
+ product_past_canvas = product_past_canvas.paste_img(top_img=pp_png_1, base="cc", value=(0, 0))
|
|
|
+ product_past_canvas =product_past_canvas.rotate(doge=-86)
|
|
|
+ pp_bg = pp_bg.paste_img(top_img=product_past_canvas, base="cc", value=(0, 70))
|
|
|
+ detailed_images.append(pp_bg)
|
|
|
+ return PictureProcessing(im=self.add_pic(detailed_images))
|
|
|
+
|
|
|
+ # 功能展示与卖点
|
|
|
+ def deal_pic_8(self):
|
|
|
+ detailed_images = []
|
|
|
+ pp_bg = PictureProcessing(r"{}\10.jpg".format(self.root))
|
|
|
+ goods_art_no_list = list(self.data.keys())
|
|
|
+ goods_art = goods_art_no_list[0]
|
|
|
+ _, pp_png_1 = self.image_one_pic(
|
|
|
+ return_orign=True,
|
|
|
+ goods_art_no=goods_art,
|
|
|
+ name="内里",
|
|
|
+ )
|
|
|
+ pp_png_1 = pp_png_1.crop(mode="min")
|
|
|
+ pp_png_1 = pp_png_1.resize(value=300)
|
|
|
+ desc_title_text_bg = PictureProcessing(
|
|
|
+ "RGB", (342, 268), (255, 255, 255, 0)
|
|
|
+ )
|
|
|
+ desc_title_text_bg = desc_title_text_bg.paste_img(
|
|
|
+ mode="pixel",
|
|
|
+ top_img=pp_png_1,
|
|
|
+ base="cc",
|
|
|
+ value=(0, 0),
|
|
|
+ )
|
|
|
+ # desc_title_text_bg = desc_title_text_bg.rotate(doge=150)
|
|
|
+ # desc_title_text_bg = desc_title_text_bg.crop(mode="min")
|
|
|
+ desc_title_text_bg = desc_title_text_bg.radius(value=30)
|
|
|
+ pp_bg.paste_img(
|
|
|
+ mode="pixel",
|
|
|
+ top_img=desc_title_text_bg,
|
|
|
+ base="en",
|
|
|
+ value=(62, 746),
|
|
|
+ )
|
|
|
+ detailed_images.append(pp_bg)
|
|
|
+ return PictureProcessing(im=self.add_pic(detailed_images))
|
|
|
+
|
|
|
+ # 添加尺码表
|
|
|
+ def deal_pic_9(self):
|
|
|
+ image_path = r"{}\11.jpg".format(self.root)
|
|
|
+ return PictureProcessing(image_path)
|