detail_xiaosushuoxie6.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. """
  2. 步骤:
  3. 1、整理需要处理的款号图-输出款号图文件夹
  4. 2、整理所有相关的图片作为素材图
  5. 3、按要求进行拼接
  6. """
  7. import os
  8. from PIL import ImageFont
  9. import sys
  10. import settings
  11. # from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
  12. # from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
  13. is_test_plugins = False
  14. try:
  15. is_test_plugins = settings.is_test_plugins
  16. except:
  17. is_test_plugins = False
  18. if is_test_plugins:
  19. from custom_plugins.plugins_mode.detail_generate_base import DetailBase
  20. from custom_plugins.plugins_mode.pic_deal import PictureProcessing
  21. else:
  22. from plugins_mode.detail_generate_base import DetailBase
  23. from plugins_mode.pic_deal import PictureProcessing
  24. plugins_name = "详情模板"
  25. company_name_list = ["小苏"]
  26. template_name = "xiaosushuoxie-6"
  27. class DetailPicGet(DetailBase):
  28. need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
  29. root = r"{}\resources\detail_temp\xiaosushuoxie\6".format(os.getcwd())
  30. def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False, excel_data=None,
  31. assigned_page_list=None):
  32. super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows, excel_data=excel_data,
  33. assigned_page_list=assigned_page_list)
  34. self.root = r"{}\resources\detail_temp\xiaosushuoxie\6".format(os.getcwd())
  35. print(template_name)
  36. self.template_name = template_name
  37. self.base_bg_color = (228, 196, 147)
  38. # 缩放倍数
  39. self.sf = 16/12
  40. self.deal_pic_func_list = [
  41. self.deal_pic_1,
  42. self.deal_pic_2,
  43. self.deal_pic_3,
  44. self.deal_pic_4,
  45. self.deal_pic_5,
  46. self.deal_pic_6,
  47. self.deal_pic_7,
  48. self.deal_pic_8,
  49. self.deal_pic_9,
  50. ]
  51. # test = True
  52. if test:
  53. # pp_1 = self.generate_font_list_to_pic()
  54. # pp_1.im.save(r"C:\Users\gymmc\Desktop\细节图示例/字号.png")
  55. # for k, v in self.goods_no_value.items():
  56. # print(k, v)
  57. self.run_test()
  58. else:
  59. self.run_all()
  60. def run_test(self):
  61. detailed_images = []
  62. # detailed_images.append(self.deal_pic_1())
  63. # detailed_images.append(self.deal_pic_2())
  64. # detailed_images.append(self.deal_pic_3())
  65. # detailed_images.append(self.deal_pic_4())
  66. # detailed_images.append(self.deal_pic_5())
  67. # detailed_images.append(self.deal_pic_6())
  68. detailed_images.append(self.deal_pic_7())
  69. # detailed_images.append(self.deal_pic_8())
  70. # detailed_images.append(self.deal_pic_9())
  71. img = self.add_pic(detailed_images)
  72. # img.save(r"{}/{}.jpg".format(self.out_put_dir, self.goods_no, format="JPEG"))
  73. if img:
  74. img.show()
  75. def deal_details_beifen(self):
  76. detailed_images = []
  77. self.image_list_append(detailed_images, self.deal_pic_1())
  78. self.image_list_append(detailed_images, self.deal_pic_2())
  79. self.image_list_append(detailed_images, self.deal_pic_3())
  80. self.image_list_append(detailed_images, self.deal_pic_4())
  81. self.image_list_append(detailed_images, self.deal_pic_5())
  82. self.image_list_append(detailed_images, self.deal_pic_6())
  83. self.image_list_append(detailed_images, self.deal_pic_7())
  84. self.image_list_append(detailed_images, self.deal_pic_8())
  85. self.image_list_append(detailed_images, self.deal_pic_9())
  86. return [x for x in detailed_images if x]
  87. # 组合图1
  88. def deal_pic_1(self):
  89. pp_bg = PictureProcessing(r"{}\t (1).jpg".format(self.root))
  90. # -------粘贴文字-------
  91. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 38) # 设计理念
  92. text_list = []
  93. text_list.append({"text": self.get_text_value("设计理念"),
  94. "font": font_1,
  95. "fill": (102, 92, 92),
  96. })
  97. text_image = self.add_text_list(text_list, spacing=15, base="nw")
  98. if text_image:
  99. pp_bg = pp_bg.paste_img(
  100. top_img=text_image,
  101. base="nw",
  102. value=(20*self.sf, 895*self.sf))
  103. # ----粘贴组合图
  104. goods_art_no_list = list(self.data.keys())
  105. goods_art_no = goods_art_no_list[0]
  106. view_list = ["组合", "俯视"]
  107. for view_name in view_list:
  108. pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
  109. goods_art_no=goods_art_no,
  110. name=view_name,
  111. )
  112. if not pp_jpg_1:
  113. continue
  114. pp_jpg_1: PictureProcessing
  115. pp_png_1: PictureProcessing
  116. pp_jpg_1 = pp_jpg_1.resize(base_by_box=(485*self.sf, 588*self.sf))
  117. pp_png_1 = pp_png_1.resize(base_by_box=(485*self.sf, 588*self.sf))
  118. pp_bg = pp_bg.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1,
  119. value=(947*self.sf - pp_jpg_1.width / 2, 888*self.sf - pp_jpg_1.height / 2), base="nw")
  120. break
  121. return pp_bg
  122. # 展示设计理念2和组合2
  123. def deal_pic_2(self):
  124. pp_bg = PictureProcessing(r"{}\t (2).jpg".format(self.root))
  125. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 38) # 设计理念
  126. text_list = []
  127. text_list.append({"text": self.get_text_value("设计理念2"),
  128. "font": font_1,
  129. "fill": (109, 103, 97),
  130. })
  131. text_image = self.add_text_list(text_list, spacing=15, base="nw")
  132. if text_image:
  133. pp_bg = pp_bg.paste_img(
  134. top_img=text_image,
  135. base="nw",
  136. value=(60*self.sf, 141*self.sf))
  137. # ====粘贴组合2或侧视图
  138. goods_art_no_list = list(self.data.keys())
  139. pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
  140. goods_art_no=goods_art_no_list[0],
  141. name="组合2",
  142. )
  143. if not pp_jpg_1:
  144. pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
  145. goods_art_no=goods_art_no_list[0],
  146. name="侧视",
  147. )
  148. pp_jpg_1: PictureProcessing
  149. pp_png_1: PictureProcessing
  150. pp_jpg_1 = pp_jpg_1.resize(base_by_box=(546*self.sf, 592*self.sf))
  151. pp_png_1 = pp_png_1.resize(base_by_box=(546*self.sf, 592*self.sf))
  152. pp_bg = pp_bg.to_overlay_pic_advance(top_img=pp_jpg_1, top_png_img=pp_png_1,
  153. value=(786*self.sf - pp_jpg_1.width / 2, 816*self.sf - pp_jpg_1.height / 2))
  154. return pp_bg
  155. # 亮点解析
  156. def deal_pic_3(self):
  157. detailed_images = []
  158. detailed_images.append(PictureProcessing(r"{}\t (3).jpg".format(self.root)))
  159. goods_art_no_list = list(self.data.keys())
  160. # =====添加内里图
  161. pp_bg_1 = PictureProcessing(r"{}\t (4).jpg".format(self.root))
  162. pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
  163. goods_art_no=goods_art_no_list[0],
  164. name="内里",
  165. )
  166. pp_png_1: PictureProcessing
  167. pp_png_1 = pp_png_1.resize(value=1600*self.sf)
  168. pp_png_1 = pp_png_1.paste_img_invert(top_img=PictureProcessing("RGB", (1200*self.sf, 1061*self.sf), (255, 255, 255)),
  169. base="ws",
  170. value=(-85*self.sf, 0))
  171. # 添加内里描述
  172. _neili_bg = PictureProcessing(r"{}\t (25).png".format(self.root))
  173. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 44) # 内里描述
  174. text_list = [{"text": self.get_text_value("内里特点"),
  175. "font": font_1,
  176. "fill": (110, 110, 110),
  177. }]
  178. text_image = self.add_text_list(text_list, spacing=10, base="nc")
  179. if text_image:
  180. _neili_bg = _neili_bg.paste_img(
  181. top_img=text_image,
  182. base="sc",
  183. value=(0, 69*self.sf))
  184. pp_bg_1 = pp_bg_1.paste_img(top_img=pp_png_1, base="sc", value=(0, 266*self.sf))
  185. pp_bg_1 = pp_bg_1.paste_img(top_img=_neili_bg, base="sc", value=(0, 137*self.sf))
  186. detailed_images.append(pp_bg_1)
  187. # ======添加鞋底图====
  188. pp_2 = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
  189. color_name="鞋底",
  190. bg_color=(255, 255, 255),
  191. )
  192. pp_2 = pp_2.resize(value=1396*self.sf)
  193. pp_bg_2 = PictureProcessing("RGB", (1600, pp_2.height + 80*self.sf), (255, 255, 255))
  194. pp_bg_2 = pp_bg_2.paste_img(top_img=pp_2, base="wc", value=(80*self.sf, 0))
  195. detailed_images.append(pp_bg_2)
  196. # --添加鞋底特点
  197. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 40) # 内里描述
  198. text_list = [{"text": self.get_text_value("鞋底特点"),
  199. "font": font_1,
  200. "fill": (110, 110, 110),
  201. }]
  202. text_image = self.add_text_list(text_list, spacing=10, base="nc")
  203. if text_image:
  204. pp_bg_3 = PictureProcessing("RGB", (1600, text_image.height + 80*self.sf), (255, 255, 255))
  205. pp_bg_3 = pp_bg_3.paste_img(top_img=text_image, base="cc", value=(0, 0))
  206. detailed_images.append(pp_bg_3)
  207. # ---添加鞋子的俯视图,并标注尺寸----------------
  208. pp_bg_4 = PictureProcessing(r"{}\t (6).jpg".format(self.root))
  209. pp_4 = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
  210. color_name="俯视",
  211. bg_color=(255, 255, 255),
  212. )
  213. pp_4 = pp_4.resize(value=332 * 1.8*self.sf)
  214. pp_bg_4 = pp_bg_4.paste_img(top_img=pp_4, base="sc", value=(0, 222*self.sf))
  215. # -添加文字描述等
  216. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 34)
  217. if self.get_text_value("鞋长"):
  218. text = "长:{}".format(self.get_text_value("鞋长"))
  219. text_image = pp_bg_4.get_text_image_advanced(font=font_1,
  220. text=text,
  221. fill=(110, 110, 110),
  222. return_mode="min_image")
  223. pp_bg_4 = pp_bg_4.paste_img(top_img=text_image, base="sc", value=(0, 134*self.sf))
  224. if self.get_text_value("跟高"):
  225. text = "跟高:{}".format(self.get_text_value("跟高"))
  226. text_image = pp_bg_4.get_text_image_advanced(font=font_1,
  227. text=text,
  228. fill=(110, 110, 110),
  229. return_mode="min_image")
  230. pp_bg_4 = pp_bg_4.paste_img(top_img=text_image, base="se", value=(72*self.sf, 404*self.sf))
  231. if self.get_text_value("脚掌围"):
  232. text = "脚掌围:{}".format(self.get_text_value("脚掌围"))
  233. text_image = pp_bg_4.get_text_image_advanced(font=font_1,
  234. text=text,
  235. fill=(110, 110, 110),
  236. return_mode="min_image")
  237. pp_bg_4 = pp_bg_4.paste_img(top_img=text_image, base="sw", value=(179*self.sf, 510*self.sf))
  238. if pp_bg_4.height > pp_4.height + 250*self.sf:
  239. 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))
  240. detailed_images.append(pp_bg_4)
  241. return PictureProcessing(im=self.add_pic(detailed_images))
  242. # 展示产品信息和颜色图
  243. def deal_pic_4(self):
  244. detailed_images = []
  245. pp_bg_1 = PictureProcessing(r"{}\t (7).jpg".format(self.root))
  246. # 粘贴产品信息
  247. # ---添加组合2图片
  248. color_name_list = ["组合2", "组合", "俯视"]
  249. goods_art_no_list = list(self.data.keys())
  250. for color_name in color_name_list:
  251. pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
  252. goods_art_no=goods_art_no_list[0],
  253. name=color_name,
  254. )
  255. if not pp_png_1:
  256. continue
  257. pp_jpg_1: PictureProcessing
  258. pp_png_1: PictureProcessing
  259. pp_jpg_1 = pp_jpg_1.resize(base_by_box=(589*self.sf, 416*self.sf))
  260. pp_png_1 = pp_png_1.resize(base_by_box=(589*self.sf, 416*self.sf))
  261. 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))
  262. break
  263. # ====添加文字信息
  264. text_list = [{"title": "帮面材质:", "get_text": "鞋面材质"},
  265. {"title": "鞋型:", "get_text": "鞋型"},
  266. {"title": "内里材质:", "get_text": "内里材质"},
  267. {"title": "头型:", "get_text": "头型"},
  268. {"title": "大底材质:", "get_text": "鞋底材质"},
  269. {"title": "货号:", "get_text": "款号"},
  270. ]
  271. x, y = 176*self.sf, 779*self.sf
  272. pos_list = [
  273. (x, y),
  274. (x + 592*self.sf, y),
  275. (x, y + 101*self.sf),
  276. (x + 592*self.sf, y + 101*self.sf),
  277. (x, y + 101*self.sf + 101*self.sf),
  278. (x + 592*self.sf, y + 101*self.sf + 101*self.sf),
  279. ]
  280. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Regular.ttf", 40) # 鞋材料信息
  281. n = -1
  282. for text_data in text_list:
  283. text_value = self.get_text_value(text_data["get_text"])
  284. if text_value:
  285. n += 1
  286. text = "{} {}".format(text_data["title"], text_value)
  287. text_image = pp_bg_1.get_text_image_advanced(font=font_1,
  288. text=text,
  289. fill=(0, 0, 0),
  290. return_mode="min_image")
  291. pp_bg_1 = pp_bg_1.paste_img(top_img=text_image, base="nw", value=pos_list[n])
  292. detailed_images.append(pp_bg_1)
  293. # =======添加各个颜色====多余高度需要剪裁
  294. pp_bg_2 = PictureProcessing(r"{}\t (8).jpg".format(self.root))
  295. font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 34) # 颜色名称
  296. color_pic_list_1 = []
  297. color_pic_list_2 = []
  298. for goods_art_no_dict in self.goods_no_value["货号资料"]:
  299. color_name = goods_art_no_dict["颜色名称"]
  300. goods_art_no = goods_art_no_dict["货号"]
  301. pp_jpg, pp_png = self.image_one_pic(return_orign=True,
  302. goods_art_no=goods_art_no,
  303. name="侧视",
  304. )
  305. pp_jpg: PictureProcessing
  306. pp_jpg = pp_jpg.resize(value=390*self.sf)
  307. pp_png = pp_png.resize(value=390*self.sf)
  308. pp_jpg = pp_jpg.paste_img_invert(
  309. top_img=PictureProcessing("RGBA", (pp_jpg.width, pp_jpg.height + 70*self.sf), (255, 255, 255, 0)),
  310. base="nw"
  311. )
  312. pp_png = pp_png.paste_img_invert(
  313. top_img=PictureProcessing("RGBA", (pp_png.width, pp_png.height + 70*self.sf), (255, 255, 255, 0)),
  314. base="nw"
  315. )
  316. text_image = pp_bg_2.get_text_image_advanced(font=font_2,
  317. text="{} / COLOR".format(color_name),
  318. fill=(0, 0, 0),
  319. return_mode="min_image")
  320. pp_jpg = pp_jpg.paste_img(top_img=text_image, base="sc", value=(0, 10*self.sf))
  321. color_pic_list_1.append(pp_jpg)
  322. color_pic_list_2.append(pp_png)
  323. # 颜色列表进行等分展示
  324. all_color_pp_1 = PictureProcessing().horizontal_distribution(color_pic_list_1, bg_width=1114*self.sf, line_spacing=10,
  325. number_per_row=2)
  326. all_color_pp_2 = PictureProcessing().horizontal_distribution(color_pic_list_2, bg_width=1114*self.sf, line_spacing=10,
  327. number_per_row=2)
  328. 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",
  329. value=(0, 131*self.sf))
  330. if pp_bg_2.height > all_color_pp_1.height + 131*self.sf + 50*self.sf:
  331. pp_bg_2 = pp_bg_2.crop(
  332. bbox=(0, 0, pp_bg_2.width, all_color_pp_1.height + 181*self.sf))
  333. detailed_images.append(pp_bg_2)
  334. return PictureProcessing(im=self.add_pic(detailed_images))
  335. # 产品细节
  336. def deal_pic_5(self):
  337. detailed_images = []
  338. detailed_images.append(PictureProcessing(r"{}\t (9).jpg".format(self.root)))
  339. detailed_images.append(PictureProcessing(r"{}\t (10).jpg".format(self.root)))
  340. # ==================俯视图鞋头===============
  341. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 64) # 主标题
  342. font_1_color = (1, 1, 1)
  343. font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 34) # 副标题
  344. font_2_color = (51, 51, 51)
  345. goods_art_no_list = list(self.data.keys())
  346. view_list = ["俯视", "侧视", "内里", "鞋底"]
  347. for index, view_name in enumerate(view_list):
  348. bg = PictureProcessing(r"{}\t (11).jpg".format(self.root))
  349. text_list = []
  350. text_list.append({"text": self.get_text_value("提示{}主标题".format(index + 1)),
  351. "font": font_1,
  352. "fill": font_1_color,
  353. })
  354. # self.get_text_value("提示{}副标题".format(index + 1))
  355. # text = "副标题副标题副标题副标题副标题副标题副标题副标题\n副标题副标题副标题副标题副标题副标题副标题副标题\n副标题\n副标题\n副标题\n副标题\n副标题"
  356. text_list.append({"text": self.get_text_value("提示{}副标题".format(index + 1)),
  357. "font": font_2,
  358. "fill": font_2_color,
  359. })
  360. text_image = self.add_text_list(text_list, spacing=30, base="nc")
  361. if text_image:
  362. bg = bg.paste_img(
  363. top_img=text_image,
  364. base="nc",
  365. value=(0, 0))
  366. bg = bg.crop(bbox=(0, 0, bg.width, text_image.height + 50*self.sf))
  367. detailed_images.append(bg)
  368. # ===粘贴图片
  369. pp_1 = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no_list[0],
  370. color_name=view_name,
  371. bg_color=(255, 255, 255)
  372. )
  373. if view_name == "俯视":
  374. resize_value = 1011*self.sf
  375. paste_img_value = (252*self.sf, 0)
  376. base = "ws"
  377. if view_name == "侧视":
  378. resize_value = 1253*self.sf
  379. paste_img_value = (270*self.sf, 0)
  380. base = "es"
  381. if view_name == "内里":
  382. resize_value = 1539*self.sf
  383. paste_img_value = (0, 0)
  384. base = "ws"
  385. if view_name == "鞋底":
  386. resize_value = 1104*self.sf
  387. paste_img_value = (0, 0)
  388. base = "cc"
  389. pp_1 = pp_1.resize(value=resize_value)
  390. pp_1 = pp_1.paste_img_invert(top_img=PictureProcessing("RGB", (1079*self.sf, 572*self.sf), (255, 255, 255)),
  391. base=base,
  392. value=paste_img_value
  393. )
  394. bg = PictureProcessing(r"{}\t (11).jpg".format(self.root))
  395. bg = bg.paste_img(top_img=pp_1,
  396. base="nc",
  397. value=(0, 0),
  398. )
  399. bg = bg.crop(bbox=(0, 0, bg.width, pp_1.height + 10*self.sf))
  400. detailed_images.append(bg)
  401. detailed_images.append(PictureProcessing(r"{}\t (13).jpg".format(self.root)))
  402. return PictureProcessing(im=self.add_pic(detailed_images))
  403. # 组合图展示
  404. def deal_pic_6(self):
  405. flag = False # 判断是否有组合图
  406. detailed_images = []
  407. pp_bg_1 = PictureProcessing(r"{}\t (15).jpg".format(self.root))
  408. detailed_images.append(pp_bg_1)
  409. goods_art_no_list = list(self.data.keys())
  410. goods_art_no = goods_art_no_list[0]
  411. # 组合图1
  412. pp_bg_2 = PictureProcessing(r"{}\t (16).jpg".format(self.root))
  413. pp_jpg, pp_png = self.image_one_pic(return_orign=True,
  414. goods_art_no=goods_art_no,
  415. name="组合",
  416. )
  417. if pp_jpg:
  418. flag = True
  419. pp_jpg: PictureProcessing
  420. pp_jpg = pp_jpg.resize(base_by_box=(910 * 0.9*self.sf, 800 * 0.9*self.sf))
  421. pp_png = pp_png.resize(base_by_box=(910 * 0.9*self.sf, 800 * 0.9*self.sf))
  422. pp_bg_2 = pp_bg_2.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="cc")
  423. detailed_images.append(pp_bg_2)
  424. # ============组合图2
  425. pp_bg_3 = PictureProcessing(r"{}\t (17).jpg".format(self.root))
  426. pp_jpg, pp_png = self.image_one_pic(return_orign=True,
  427. goods_art_no=goods_art_no,
  428. name="组合2",
  429. )
  430. if pp_jpg:
  431. flag = True
  432. pp_jpg: PictureProcessing
  433. pp_jpg = pp_jpg.resize(base_by_box=(937 * 0.9*self.sf, 827 * 0.9*self.sf))
  434. pp_png = pp_png.resize(base_by_box=(937 * 0.9*self.sf, 827 * 0.9*self.sf))
  435. pp_bg_3 = pp_bg_3.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="cc")
  436. detailed_images.append(pp_bg_3)
  437. # ==========组合图3
  438. pp_bg_4 = PictureProcessing(r"{}\t (18).jpg".format(self.root))
  439. detailed_images.append(pp_bg_4)
  440. pp_bg_5 = PictureProcessing(r"{}\t (19).jpg".format(self.root))
  441. pp_jpg, pp_png = self.image_one_pic(return_orign=True,
  442. goods_art_no=goods_art_no,
  443. name="组合3",
  444. )
  445. if pp_jpg:
  446. flag = True
  447. pp_jpg: PictureProcessing
  448. pp_jpg = pp_jpg.resize(base_by_box=(1062*self.sf, 937*self.sf))
  449. pp_png = pp_png.resize(base_by_box=(1062*self.sf, 937*self.sf))
  450. pp_bg_5 = pp_bg_5.to_overlay_pic_advance(top_img=pp_jpg, top_png_img=pp_png, base="cc")
  451. detailed_images.append(pp_bg_5)
  452. if flag:
  453. return PictureProcessing(im=self.add_pic(detailed_images))
  454. else:
  455. return None
  456. # 各个颜色展示
  457. def deal_pic_7(self):
  458. detailed_images = []
  459. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 36) # 副标题
  460. view_list = ["俯视", "侧视", "后跟", "鞋底"]
  461. bg_color = (241, 239, 240)
  462. for goods_art_no_dict in self.goods_no_value["货号资料"]:
  463. print("523 goods_art_no_dict",goods_art_no_dict)
  464. bg = PictureProcessing(r"{}\t (20).jpg".format(self.root))
  465. # bg.show()
  466. color_name = goods_art_no_dict["颜色名称"]
  467. goods_art_no = goods_art_no_dict["货号"]
  468. # 粘贴颜色名称
  469. if color_name:
  470. text_image = bg.get_text_image_advanced(font=font_1,
  471. text="{}".format(color_name),
  472. fill=(0, 0, 0),
  473. return_mode="min_image")
  474. # text_image.show()
  475. bg = bg.paste_img(top_img=text_image, base="nw", value=(85*self.sf, 35*self.sf))
  476. # bg.show()
  477. # 粘贴图片
  478. for view_name in view_list:
  479. pp = self.get_overlay_pic_from_dict(goods_art_no=goods_art_no,
  480. color_name=view_name,
  481. bg_color=bg_color,
  482. )
  483. if view_name == "俯视":
  484. pp = pp.resize(base_by_box=(779 * 0.8*self.sf, 838 * 0.8*self.sf))
  485. pp = pp.paste_img_invert(top_img=PictureProcessing("RGB", (779*self.sf, 836*self.sf), bg_color), base="cc")
  486. bg = bg.paste_img(top_img=pp, value=(38*self.sf, 152*self.sf))
  487. if view_name == "侧视":
  488. pp = pp.resize(base_by_box=(321*self.sf, 244*self.sf))
  489. pp = pp.paste_img_invert(top_img=PictureProcessing("RGB", (321*self.sf, 244*self.sf), bg_color), base="cc")
  490. bg = bg.paste_img(top_img=pp, value=(844*self.sf, 152*self.sf))
  491. if view_name == "后跟":
  492. pp = pp.resize(base_by_box=(321 * 0.7*self.sf, 278 * 0.9*self.sf))
  493. pp = pp.paste_img_invert(top_img=PictureProcessing("RGB", (321*self.sf, 278*self.sf), bg_color), base="cc")
  494. bg = bg.paste_img(top_img=pp, value=(844*self.sf, 417*self.sf))
  495. if view_name == "鞋底":
  496. pp = pp.resize(base_by_box=(321*self.sf, 270*self.sf))
  497. pp = pp.paste_img_invert(top_img=PictureProcessing("RGB", (321*self.sf, 270*self.sf), bg_color), base="cc")
  498. bg = bg.paste_img(top_img=pp, value=(844*self.sf, 720*self.sf))
  499. detailed_images.append(bg)
  500. return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
  501. # 添加注意事项
  502. def deal_pic_8(self):
  503. detailed_images = []
  504. detailed_images.append(PictureProcessing(r"{}\t (22).jpg".format(self.root)))
  505. return PictureProcessing(im=self.add_pic(detailed_images))
  506. # 添加注意事项
  507. def deal_pic_9(self):
  508. detailed_images = []
  509. detailed_images.append(PictureProcessing(r"{}\t (23).jpg".format(self.root)))
  510. detailed_images.append(PictureProcessing(r"{}\t (24).jpg".format(self.root)))
  511. return PictureProcessing(im=self.add_pic(detailed_images))