detail_xiaosushuoxie5.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. """
  2. 步骤:
  3. 1、整理需要处理的款号图-输出款号图文件夹
  4. 2、整理所有相关的图片作为素材图
  5. 3、按要求进行拼接
  6. """
  7. import os
  8. import settings
  9. from PIL import ImageFont
  10. # from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
  11. # from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
  12. is_test_plugins = False
  13. try:
  14. is_test_plugins = settings.is_test_plugins
  15. except:
  16. is_test_plugins = False
  17. if is_test_plugins:
  18. from custom_plugins.plugins_mode.detail_generate_base import DetailBase
  19. from custom_plugins.plugins_mode.pic_deal import PictureProcessing
  20. else:
  21. from plugins_mode.detail_generate_base import DetailBase
  22. from plugins_mode.pic_deal import PictureProcessing
  23. plugins_name = "详情模板"
  24. company_name_list = ["小苏" ]
  25. template_name = "xiaosushuoxie-5"
  26. class DetailPicGet(DetailBase):
  27. need_view = ["俯视", "侧视", "后跟", "鞋底", "内里"]
  28. root = r"{}\resources\detail_temp\xiaosushuoxie\5".format(os.getcwd())
  29. def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, test=False, excel_data=None,assigned_page_list=None):
  30. super().__init__(goods_no, goods_no_value, out_put_dir, windows=windows, excel_data=excel_data,assigned_page_list=assigned_page_list)
  31. self.template_name = template_name
  32. self.root = r"{}\resources\detail_temp\xiaosushuoxie\5".format(os.getcwd())
  33. print("run xiaosushuoxie-5 ")
  34. self.base_bg_color = (255, 255, 255)
  35. self.base_bg_color_2 = (244, 242, 243)
  36. self.deal_pic_func_list = [
  37. self.deal_pic_1,
  38. self.deal_pic_2,
  39. self.deal_pic_3,
  40. self.deal_pic_4,
  41. self.deal_pic_5,
  42. self.deal_pic_6,
  43. self.deal_pic_7,
  44. self.deal_pic_8,
  45. self.deal_pic_9,
  46. self.deal_pic_10,
  47. self.deal_pic_11,
  48. ]
  49. if test:
  50. # pp = self.generate_font_list_to_pic()
  51. # pp.im.save(r"C:\Users\gymmc\Desktop\细节图示例/字号.png")
  52. # for k, v in self.goods_no_value.items():
  53. # print(k, v)
  54. self.run_test()
  55. else:
  56. self.run_all()
  57. def run_test(self):
  58. detailed_images = []
  59. detailed_images.append(self.deal_pic_1())
  60. detailed_images.append(self.deal_pic_2())
  61. detailed_images.append(self.deal_pic_3())
  62. detailed_images.append(self.deal_pic_4())
  63. detailed_images.append(self.deal_pic_5())
  64. detailed_images.append(self.deal_pic_6())
  65. detailed_images.append(self.deal_pic_7())
  66. detailed_images.append(self.deal_pic_8())
  67. detailed_images.append(self.deal_pic_9())
  68. detailed_images.append(self.deal_pic_10())
  69. detailed_images.append(self.deal_pic_11())
  70. img = self.add_pic(detailed_images)
  71. img.save(r"{}/{}.jpg".format(self.out_put_dir,self.goods_no, format="JPEG"))
  72. # img.show()
  73. # 标题文字展示
  74. def deal_pic_1(self):
  75. pp_bg = PictureProcessing(r"{}\t (1).png".format(self.root))
  76. # -------粘贴文字-------
  77. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 74) # 设计理念
  78. font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 44) # 描述主标题1
  79. font_3 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 44) # 描述副标题1
  80. text_list = []
  81. text_list.append({"text": self.get_text_value("设计理念"),
  82. "font": font_1,
  83. "fill": (47, 44, 51),
  84. "spacing": 50,
  85. })
  86. # 主标题
  87. text_list.append({"text": self.get_text_value("标题"),
  88. "font": font_2,
  89. "fill": (124, 91, 24),
  90. })
  91. text_list.append({"text": self.get_text_value("副标题"),
  92. "font": font_3,
  93. "fill": (55, 55, 55),
  94. })
  95. text_image = self.add_text_list(text_list, spacing=15, base="en")
  96. if text_image:
  97. pp_bg = pp_bg.paste_img(
  98. top_img=text_image,
  99. base="ne",
  100. value=(133, 277))
  101. return pp_bg
  102. # 展示鞋头和后跟
  103. def deal_pic_2(self):
  104. pp_bg = PictureProcessing(r"{}\t (2).png".format(self.root))
  105. goods_art_no_list = list(self.data.keys())
  106. pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
  107. goods_art_no=goods_art_no_list[0],
  108. name="内里",
  109. )
  110. pp_png_1: PictureProcessing
  111. pp_png_1 = pp_png_1.resize(value=1187)
  112. pp_png_1 = pp_png_1.rotate_advance(doge=90)
  113. pp_png_1 = pp_png_1.crop(bbox=(0, 0, pp_png_1.width, 473))
  114. pp_bg = pp_bg.paste_img(top_img=pp_png_1,
  115. value=(349 - pp_png_1.width / 2, 342),
  116. base="sw"
  117. )
  118. pp_jpg_2, pp_png_2 = self.image_one_pic(return_orign=True,
  119. goods_art_no=goods_art_no_list[0],
  120. name="后跟",
  121. )
  122. pp_png_2: PictureProcessing
  123. pp_png_2 = pp_png_2.resize(value=502)
  124. pp_png_2 = pp_png_2.crop(mode="min")
  125. pp_png_2 = pp_png_2.crop(bbox=(0, 0, pp_png_2.width, 473))
  126. pp_bg = pp_bg.paste_img(top_img=pp_png_2,
  127. value=(871 - pp_png_2.width / 2, 342),
  128. base="sw"
  129. )
  130. # 添加标题文字等
  131. # -------粘贴文字-------
  132. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 42) # 特征标题
  133. font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 30) # 特征描述
  134. text_list = []
  135. # 鞋头特征
  136. text_list.append({"text": self.get_text_value("鞋头特征"),
  137. "font": font_1,
  138. "fill": (48, 43, 49),
  139. "spacing": 0,
  140. })
  141. # 主标题
  142. # 鞋头描述
  143. text_list.append({"text": self.get_text_value("鞋头描述"),
  144. "font": font_2,
  145. "fill": (164, 164, 164),
  146. })
  147. text_image = self.add_text_list(text_list, spacing=15, base="nc")
  148. if text_image:
  149. pp_bg = pp_bg.paste_img(
  150. top_img=text_image,
  151. base="nw",
  152. value=(349 - text_image.width / 2, 511))
  153. text_list = []
  154. # 后跟特征
  155. text_list.append({"text": self.get_text_value("后跟特征"),
  156. "font": font_1,
  157. "fill": (48, 43, 49),
  158. "spacing": 0,
  159. })
  160. # 后跟描述
  161. text_list.append({"text": self.get_text_value("后跟描述"),
  162. "font": font_2,
  163. "fill": (164, 164, 164),
  164. })
  165. text_image = self.add_text_list(text_list, spacing=15, base="nc")
  166. if text_image:
  167. pp_bg = pp_bg.paste_img(
  168. top_img=text_image,
  169. base="nw",
  170. value=(871 - text_image.width / 2, 511))
  171. return pp_bg
  172. # 展示鞋头放大图
  173. def deal_pic_3(self):
  174. pp_bg = PictureProcessing(r"{}\t (3).png".format(self.root))
  175. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 70) # 设计理念
  176. font_2 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 46) # 描述主标题1
  177. font_3 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 44) # 描述主标题2
  178. text_list = []
  179. # 鞋头特征
  180. text_list.append({"text": self.get_text_value("设计理念2"),
  181. "font": font_1,
  182. "fill": (3, 3, 2),
  183. "spacing": 40,
  184. })
  185. # 主标题
  186. text_list.append({"text": self.get_text_value("提示2主标题"),
  187. "font": font_2,
  188. "fill": (124, 91, 24),
  189. })
  190. text_list.append({"text": self.get_text_value("提示2副标题"),
  191. "font": font_3,
  192. "fill": (26, 25, 23),
  193. })
  194. text_image = self.add_text_list(text_list, spacing=10, base="nw")
  195. if text_image:
  196. pp_bg = pp_bg.paste_img(
  197. top_img=text_image,
  198. base="nw",
  199. value=(140, 176))
  200. # 粘贴俯视图
  201. goods_art_no_list = list(self.data.keys())
  202. pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
  203. goods_art_no=goods_art_no_list[0],
  204. name="俯视",
  205. )
  206. pp_png_1: PictureProcessing
  207. pp_png_1 = pp_png_1.resize(value=1933)
  208. pp_png_1 = pp_png_1.crop(mode="min")
  209. pp_bg = pp_bg.paste_img(top_img=pp_png_1,
  210. value=(202, 86),
  211. base="sw"
  212. )
  213. return pp_bg
  214. # 展示后跟放大图
  215. def deal_pic_4(self):
  216. pp_bg = PictureProcessing(r"{}\t (4).png".format(self.root))
  217. h = 176
  218. # ===========粘贴文字============
  219. font_2 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 46) # 描述主标题1
  220. font_3 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 44) # 描述主标题2
  221. text_list = []
  222. # 鞋头特征
  223. # 主标题
  224. text_list.append({"text": self.get_text_value("提示3主标题"),
  225. "font": font_2,
  226. "fill": (124, 91, 24),
  227. })
  228. text_list.append({"text": self.get_text_value("提示3副标题"),
  229. "font": font_3,
  230. "fill": (26, 25, 23),
  231. })
  232. text_image = self.add_text_list(text_list, spacing=10, base="ne")
  233. if text_image:
  234. pp_bg = pp_bg.paste_img(
  235. top_img=text_image,
  236. base="ne",
  237. value=(140, h))
  238. # 粘贴侧视图
  239. goods_art_no_list = list(self.data.keys())
  240. pp_jpg, pp_png = self.image_one_pic(return_orign=True,
  241. goods_art_no=goods_art_no_list[0],
  242. name="侧视",
  243. )
  244. pp_jpg = pp_jpg.resize(value=2000)
  245. pp_png = pp_png.resize(value=2000)
  246. if text_image:
  247. h = h + text_image.height
  248. else:
  249. h = h
  250. pp_bg = pp_bg.to_overlay_pic_advance(mode="pixel", top_img=pp_jpg, base="en", value=(100, h),
  251. top_png_img=pp_png)
  252. # 总高
  253. h = h + pp_jpg.height + 50
  254. if h < pp_bg.height:
  255. # 剪裁
  256. pp_bg = pp_bg.crop(bbox=(0, 0, 1200, h))
  257. return pp_bg
  258. # 展示后跟细节卡片
  259. def deal_pic_5(self):
  260. pp_bg = PictureProcessing(r"{}\t (5).png".format(self.root))
  261. # 粘贴侧视图
  262. goods_art_no_list = list(self.data.keys())
  263. pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
  264. goods_art_no=goods_art_no_list[0],
  265. name="侧视",
  266. )
  267. pp_png_1: PictureProcessing
  268. pp_png_1 = pp_png_1.resize(value=1621)
  269. pp_png_1 = pp_png_1.rotate_advance(doge=45)
  270. pp_png_1 = pp_png_1.transpose()
  271. pp_png_1 = pp_png_1.crop(mode="min")
  272. shoe_bg = PictureProcessing("RGB", (448, 464), self.base_bg_color)
  273. shoe_bg = shoe_bg.paste_img(top_img=pp_png_1,
  274. value=(-80, 200),
  275. base="wc"
  276. )
  277. shoe_bg = shoe_bg.radius(circular_pos=(0, 0, 1, 0), value=30)
  278. pp_bg = pp_bg.paste_img(top_img=shoe_bg,
  279. value=(613, 174),
  280. base="nw")
  281. # 添加文字
  282. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 40) # 设计理念
  283. font_2 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 30) # 描述主标题1
  284. text_list = []
  285. text_list.append({"text": self.get_text_value("提示4主标题"),
  286. "font": font_1,
  287. "fill": (10, 7, 6),
  288. })
  289. text_list.append({"text": self.get_text_value("提示4副标题"),
  290. "font": font_2,
  291. "fill": (72, 65, 59),
  292. })
  293. text_image = self.add_text_list(text_list, spacing=38, base="nw")
  294. if text_image:
  295. pp_bg = pp_bg.paste_img(
  296. top_img=text_image,
  297. base="nw",
  298. value=(154, 210))
  299. return pp_bg
  300. # "心动"设计亮点,展示旋转的侧视图
  301. def deal_pic_6(self):
  302. detailed_images = []
  303. pp_bg = PictureProcessing(r"{}\t (6).png".format(self.root))
  304. # 粘贴侧视图
  305. goods_art_no_list = list(self.data.keys())
  306. pp_jpg_1, pp_png_1 = self.image_one_pic(return_orign=True,
  307. goods_art_no=goods_art_no_list[0],
  308. name="侧视",
  309. )
  310. pp_png_1: PictureProcessing
  311. pp_png_1 = pp_png_1.resize(value=2050)
  312. pp_png_1 = pp_png_1.transpose()
  313. pp_png_1 = pp_png_1.rotate_advance(doge=20)
  314. pp_png_1 = pp_png_1.crop(mode="min")
  315. pp_bg = pp_bg.paste_img(top_img=pp_png_1,
  316. value=(-200, 200),
  317. base="ws"
  318. )
  319. # ========添加文字==================
  320. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 70) # 设计理念
  321. text = self.get_text_value("设计理念3")
  322. pp_bg = pp_bg.get_text_image_advanced(
  323. value=(pp_bg.width - 127, pp_bg.height - 43),
  324. font=font_1,
  325. text=text,
  326. anchor="rs",
  327. align="right",
  328. spacing=5,
  329. fill=(109, 107, 109),
  330. return_mode="image",
  331. )
  332. return pp_bg
  333. # 产品展示,展示大图各个细节
  334. def deal_pic_7(self):
  335. detailed_images = []
  336. detailed_images.append(PictureProcessing(r"{}\t (7).png".format(self.root)))
  337. goods_art_no_list = list(self.data.keys())
  338. goods_art_no = goods_art_no_list[0]
  339. # ======展示组合图============
  340. pp_1 = self.get_overlay_pic_from_dict(
  341. goods_art_no=goods_art_no,
  342. color_name="组合",
  343. bg_color=self.base_bg_color_2
  344. )
  345. if pp_1:
  346. pp_1 = pp_1.resize(value=1200)
  347. pp_1 = pp_1.paste_img_invert(
  348. top_img=PictureProcessing("RGB", (1200, pp_1.height + 300), self.base_bg_color_2),
  349. base="cc", )
  350. detailed_images.append(pp_1)
  351. # ======展示鞋面===============
  352. detailed_images.append(PictureProcessing(r"{}\t (9).png".format(self.root)))
  353. pp_2 = self.get_overlay_pic_from_dict(
  354. goods_art_no=goods_art_no,
  355. color_name="俯视",
  356. bg_color=self.base_bg_color_2
  357. )
  358. pp_2: PictureProcessing
  359. pp_2 = pp_2.resize(value=1519)
  360. pp_2 = pp_2.paste_img_invert(top_img=PictureProcessing("RGB", (1200, pp_2.height + 50), self.base_bg_color_2),
  361. base="ws", value=(171, 0))
  362. detailed_images.append(pp_2)
  363. # =======展示后跟=========
  364. detailed_images.append(PictureProcessing(r"{}\t (10).png".format(self.root)))
  365. pp_3 = self.get_overlay_pic_from_dict(
  366. goods_art_no=goods_art_no,
  367. color_name="侧视",
  368. bg_color=self.base_bg_color_2
  369. )
  370. pp_3: PictureProcessing
  371. pp_3 = pp_3.resize(value=1881)
  372. pp_3 = pp_3.paste_img_invert(top_img=PictureProcessing("RGB", (1200, pp_3.height + 200), self.base_bg_color_2),
  373. base="ec", value=(171, 0))
  374. detailed_images.append(pp_3)
  375. # =========展示鞋底============
  376. detailed_images.append(PictureProcessing(r"{}\t (11).png".format(self.root)))
  377. pp_jpg_4, pp_png_4 = self.image_one_pic(return_orign=True,
  378. goods_art_no=goods_art_no,
  379. name="鞋底",
  380. )
  381. pp_png_4: PictureProcessing
  382. pp_png_4 = pp_png_4.resize(value=2380)
  383. pp_png_4 = pp_png_4.rotate_advance(doge=45)
  384. pp_png_4 = pp_png_4.paste_img_invert(
  385. top_img=PictureProcessing("RGB", (1200, pp_png_4.height + 200), self.base_bg_color_2),
  386. base="ws", value=(269, 81))
  387. detailed_images.append(pp_png_4)
  388. return PictureProcessing(im=self.add_pic(detailed_images))
  389. # 功能展示与卖点
  390. def deal_pic_8(self):
  391. detailed_images = []
  392. detailed_images.append(PictureProcessing(r"{}\t (12).png".format(self.root)))
  393. goods_art_no_list = list(self.data.keys())
  394. goods_art_no = goods_art_no_list[0]
  395. color_name_list = ["侧视", "鞋底", "俯视"]
  396. font_1 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 42) # 卖点标题1
  397. font_2 = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 32) # 卖点标题2
  398. font_3 = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 26) # 卖点描述1
  399. # =====卖点1,展示后跟========
  400. for color_name in color_name_list:
  401. bg = PictureProcessing(r"{}\t (13).png".format(self.root))
  402. pp_jpg, pp_png = self.image_one_pic(return_orign=True,
  403. goods_art_no=goods_art_no,
  404. name=color_name,
  405. )
  406. temp_bg = PictureProcessing("RGB", (536, 424), (214, 214, 214))
  407. if color_name == "侧视":
  408. pp_png = pp_png.resize(value=990)
  409. temp_bg = temp_bg.paste_img(top_img=pp_png, base="es")
  410. shoe_paste_base = "wc"
  411. text_1, text_2 = self.get_text_value("卖点1标题", subsection_len=2)
  412. text_3 = self.get_text_value("卖点1介绍")
  413. text_paste_base = "ec"
  414. text_paste_value = (312, 0)
  415. if color_name == "鞋底":
  416. pp_png = pp_png.resize(value=1000)
  417. temp_bg = temp_bg.paste_img(top_img=pp_png, base="wc", value=(0, 0))
  418. shoe_paste_base = "ec"
  419. text_1, text_2 = self.get_text_value("卖点2标题", subsection_len=2)
  420. text_3 = self.get_text_value("卖点2介绍")
  421. text_paste_base = "wc"
  422. text_paste_value = (312, 0)
  423. if color_name == "俯视":
  424. pp_png = pp_png.resize(value=1418)
  425. temp_bg = temp_bg.paste_img(top_img=pp_png, base="cc")
  426. shoe_paste_base = "wc"
  427. text_1, text_2 = self.get_text_value("卖点3标题", subsection_len=2)
  428. text_3 = self.get_text_value("卖点3介绍")
  429. text_paste_base = "ec"
  430. text_paste_value = (312, 0)
  431. # 添加圆角
  432. temp_bg = temp_bg.radius(circular_pos=(1, 1, 1, 1), value=50)
  433. # 粘贴到背景上
  434. temp_bg = temp_bg.paste_img_invert(top_img=bg, base=shoe_paste_base, value=(99, 0))
  435. text_list = []
  436. # 卖点主标题
  437. text_list.append({"text": text_1,
  438. "font": font_1,
  439. "fill": (2, 2, 2),
  440. "spacing": 0,
  441. })
  442. text_list.append({"text": text_2,
  443. "font": font_2,
  444. "fill": (43, 43, 43),
  445. "spacing": 10,
  446. })
  447. # 主标题
  448. text_list.append({"text": text_3,
  449. "font": font_3,
  450. "fill": (165, 165, 165),
  451. })
  452. text_image = self.add_text_list(text_list, spacing=15, base="nc")
  453. if text_image:
  454. temp_bg = temp_bg.paste_img(
  455. top_img=text_image,
  456. base=text_paste_base,
  457. value=(text_paste_value[0] - text_image.width / 2, text_paste_value[1]))
  458. detailed_images.append(temp_bg)
  459. return PictureProcessing(im=self.add_pic(detailed_images))
  460. # 添加尺码表
  461. def deal_pic_9(self):
  462. image_path = r"{}\t (16).png".format(self.root)
  463. return PictureProcessing(image_path)
  464. # 角度展示
  465. def deal_pic_10(self):
  466. detailed_images = []
  467. # 角度展示标题
  468. detailed_images.append(PictureProcessing(r"{}\t (17).png".format(self.root)))
  469. # 添加颜色名称字体
  470. font_color = ImageFont.truetype(r"resources\ttf\puhui\Bold.ttf", 30)
  471. for goods_art_no_dict in self.goods_no_value["货号资料"]:
  472. color_name = goods_art_no_dict["颜色名称"]
  473. goods_art_no = goods_art_no_dict["货号"]
  474. # ====颜色主图
  475. pp_1 = self.get_overlay_pic_from_dict(
  476. goods_art_no=goods_art_no,
  477. color_name="俯视",
  478. bg_color=(255, 255, 255)
  479. )
  480. pp_1: PictureProcessing
  481. pp_1 = pp_1.resize(value=865)
  482. pp_1 = pp_1.paste_img_invert(top_img=PictureProcessing("RGB", (1152, pp_1.height + 100), (255, 255, 255)),
  483. base="sc"
  484. )
  485. # 粘贴颜色名称
  486. pp_1 = pp_1.get_text_image_advanced(
  487. value=(90, 50),
  488. font=font_color,
  489. text=color_name,
  490. spacing=1,
  491. return_mode="image",
  492. )
  493. pp_1 = pp_1.paste_img_invert(top_img=PictureProcessing("RGB", (1200, pp_1.height), (243, 243, 243)),
  494. base="cc"
  495. )
  496. detailed_images.append(pp_1)
  497. # 添加处理各个角度
  498. view_name_list = ["内里", "鞋底", "后跟", "侧视"]
  499. color_pic_list = []
  500. for view_name in view_name_list:
  501. _, pp_png = self.image_one_pic(return_orign=True,
  502. goods_art_no=goods_art_no,
  503. name=view_name,
  504. )
  505. temp_bg = PictureProcessing("RGB", (546, 338), (243, 243, 243))
  506. # if view_name == "内里":
  507. # pp_png = pp_png.resize(base_by_box=(temp_bg.width * 0.9, temp_bg.height * 0.9))
  508. # if view_name == "鞋底":
  509. # pp_png = pp_png.resize(base_by_box=(temp_bg.width * 0.9, temp_bg.height * 0.9))
  510. # if view_name == "后跟":
  511. # pp_png = pp_png.resize(base_by_box=(temp_bg.width * 0.9, temp_bg.height * 0.9))
  512. # if view_name == "侧视":
  513. # pp_png = pp_png.resize(base_by_box=(temp_bg.width * 0.9, temp_bg.height * 0.9))
  514. pp_png = pp_png.resize(base_by_box=(temp_bg.width * 0.9, temp_bg.height * 0.9))
  515. temp_bg = temp_bg.paste_img(top_img=pp_png, base="cc")
  516. temp_bg = temp_bg.radius(value=30)
  517. color_pic_list.append(temp_bg)
  518. # 颜色列表进行等分展示
  519. all_color_pp = PictureProcessing().horizontal_distribution(color_pic_list, bg_width=1114, line_spacing=10,
  520. number_per_row=2)
  521. all_color_pp = all_color_pp.paste_img_invert(
  522. top_img=PictureProcessing("RGB", (1152, all_color_pp.height + 100), (255, 255, 255)), base="cc")
  523. all_color_pp = all_color_pp.paste_img_invert(
  524. top_img=PictureProcessing("RGB", (1200, all_color_pp.height), (243, 243, 243)), base="cc")
  525. detailed_images.append(all_color_pp)
  526. # 添加底部圆弧分割线
  527. b_bg = PictureProcessing("RGB", (1152, 30), (255, 255, 255))
  528. b_bg = b_bg.radius(circular_pos=(0, 0, 1, 1), value=30)
  529. b_bg = b_bg.paste_img_invert(top_img=PictureProcessing("RGB", (1200, b_bg.height + 50), (243, 243, 243)),
  530. base="nc")
  531. detailed_images.append(b_bg)
  532. # return PictureProcessing(im=self.add_pic(detailed_images))
  533. return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
  534. # 添加注意事项
  535. def deal_pic_11(self):
  536. image_path = r"{}\t (21).png".format(self.root)
  537. return PictureProcessing(image_path)