detail_xinnuo1.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. """
  2. 步骤:
  3. 1、整理需要处理的款号图-输出款号图文件夹
  4. 2、整理所有相关的图片作为素材图
  5. 3、按要求进行拼接
  6. """
  7. from ast import mod
  8. import os
  9. import settings
  10. from PIL import ImageFont
  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 = "xinnuo-1"
  27. class DetailPicGet(DetailBase):
  28. need_view = ["俯视", "侧视", "后跟", "鞋底", "内里","组合","组合2","组合3"]
  29. root = r"{}\resources\detail_temp\xinnuo\1".format(os.getcwd())
  30. def __init__(
  31. self,
  32. goods_no,
  33. goods_no_value: dict,
  34. out_put_dir,
  35. windows=None,
  36. test=False,
  37. excel_data=None,
  38. assigned_page_list=None,
  39. ):
  40. super().__init__(
  41. goods_no,
  42. goods_no_value,
  43. out_put_dir,
  44. windows=windows,
  45. excel_data=excel_data,
  46. assigned_page_list=assigned_page_list,
  47. )
  48. self.template_name = template_name
  49. self.root = r"{}\resources\detail_temp\xinnuo\1".format(os.getcwd())
  50. print("run xinnuo-1 ")
  51. self.base_bg_color = (255, 255, 255)
  52. self.base_bg_color_2 = (244, 242, 243)
  53. self.deal_pic_func_list = [
  54. self.deal_pic_1,
  55. self.deal_pic_2,
  56. self.deal_pic_3,
  57. self.deal_pic_4,
  58. self.deal_pic_5,
  59. self.deal_pic_6,
  60. self.deal_pic_7,
  61. self.deal_pic_8,
  62. self.deal_pic_9,
  63. self.deal_pic_10,
  64. self.deal_pic_11,
  65. self.deal_pic_13,
  66. self.deal_pic_14,
  67. self.deal_pic_15,
  68. self.deal_pic_16,
  69. self.deal_pic_17,
  70. self.deal_pic_18,
  71. self.deal_pic_19,
  72. self.deal_pic_20,
  73. ]
  74. if test:
  75. # pp = self.generate_font_list_to_pic()
  76. # pp.im.save(r"C:\Users\gymmc\Desktop\细节图示例/字号.png")
  77. # for k, v in self.goods_no_value.items():
  78. # print(k, v)
  79. self.run_test()
  80. else:
  81. self.run_all()
  82. def run_test(self):
  83. detailed_images = []
  84. detailed_images.append(self.deal_pic_1())
  85. detailed_images.append(self.deal_pic_2())
  86. detailed_images.append(self.deal_pic_3())
  87. detailed_images.append(self.deal_pic_4())
  88. detailed_images.append(self.deal_pic_5())
  89. detailed_images.append(self.deal_pic_6())
  90. detailed_images.append(self.deal_pic_7())
  91. detailed_images.append(self.deal_pic_8())
  92. detailed_images.append(self.deal_pic_9())
  93. detailed_images.append(self.deal_pic_10())
  94. detailed_images.append(self.deal_pic_11())
  95. detailed_images.append(self.deal_pic_13())
  96. detailed_images.append(self.deal_pic_14())
  97. detailed_images.append(self.deal_pic_15())
  98. detailed_images.append(self.deal_pic_16())
  99. detailed_images.append(self.deal_pic_17())
  100. detailed_images.append(self.deal_pic_18())
  101. detailed_images.append(self.deal_pic_19())
  102. detailed_images.append(self.deal_pic_20())
  103. img = self.add_pic(detailed_images)
  104. img.save(r"{}/{}.jpg".format(self.out_put_dir, self.goods_no, format="JPEG"))
  105. # img.show()
  106. # 标题文字展示
  107. def deal_pic_1(self):
  108. pp_bg = PictureProcessing(r"{}\1.jpg".format(self.root))
  109. font_main = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 102) # 设计理念
  110. mainTitle = self.get_text_value("主标题")
  111. subTitle = self.get_text_value("副标题")
  112. pp_bg.get_text_image_advanced(
  113. value=(336, 102),
  114. font=font_main,
  115. text=mainTitle,
  116. align="left",
  117. # anchor="ma",
  118. spacing=5,
  119. fill=(60, 40, 29),
  120. return_mode="image",
  121. margins=(0, 0, 0, 0),
  122. )
  123. font_sub = ImageFont.truetype(
  124. r"resources\ttf\puhui\Bold.ttf", 40
  125. ) # 设计理念
  126. pp_bg.get_text_image_advanced(
  127. value=(82, 102),
  128. font=font_sub,
  129. text=subTitle,
  130. align="left",
  131. # anchor="ma",
  132. spacing=5,
  133. fill=(60, 40, 29),
  134. return_mode="image",
  135. margins=(0, 0, 0, 0),
  136. )
  137. return pp_bg
  138. # 展示鞋头和后跟
  139. def deal_pic_2(self):
  140. pp_bg = PictureProcessing(r"{}\2.jpg".format(self.root))
  141. font = ImageFont.truetype(
  142. r"resources\ttf\puhui\Regular.ttf", 24
  143. ) # 设计理念
  144. design_text = self.get_text_value("设计理念")
  145. pp_bg.get_text_image_advanced(
  146. value=(226, 359),
  147. font=font,
  148. text=design_text,
  149. align="center",
  150. # anchor="ma",
  151. spacing=20,
  152. fill=(88, 52, 28),
  153. return_mode="image",
  154. margins=(0, 0, 0, 0),
  155. )
  156. return pp_bg
  157. # 展示鞋头放大图
  158. def deal_pic_3(self):
  159. pp_bg = PictureProcessing(r"{}\3.jpg".format(self.root))
  160. goods_art_no_list = list(self.data.keys())
  161. pp_jpg_1, pp_png_1 = self.image_one_pic(
  162. return_orign=True,
  163. goods_art_no=goods_art_no_list[0],
  164. name="内里",
  165. )
  166. pp_jpg_1 = pp_jpg_1.resize(value=1600)
  167. pp_png_1 = pp_png_1.resize(value=1600)
  168. # pp_bg = pp_bg.paste_img(top_img=shoe_bg, value=(0, 0), base="nw")
  169. pp_bg = pp_bg.to_overlay_pic_advance(
  170. mode="pixel",
  171. top_img=pp_jpg_1,
  172. base="es",
  173. value=(80, 230),
  174. top_png_img=pp_png_1,
  175. )
  176. return pp_bg
  177. # 展示后跟放大图
  178. def deal_pic_4(self):
  179. pp_bg = PictureProcessing(r"{}\4.jpg".format(self.root))
  180. return pp_bg
  181. # 展示后跟细节卡片
  182. def deal_pic_5(self):
  183. pp_bg = PictureProcessing(r"{}\5.jpg".format(self.root))
  184. return pp_bg
  185. # "心动"设计亮点,展示旋转的侧视图
  186. def deal_pic_6(self):
  187. pp_bg = PictureProcessing(r"{}\6.jpg".format(self.root))
  188. goods_art_no_list = list(self.data.keys())
  189. pp_jpg_1, pp_png_1 = self.image_one_pic(
  190. return_orign=True,
  191. goods_art_no=goods_art_no_list[0],
  192. name="俯视",
  193. )
  194. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width/1.4)
  195. pp_png_1 = pp_png_1.resize(value=pp_bg.width / 1.4)
  196. # pp_bg = pp_bg.paste_img(top_img=shoe_bg, value=(0, 0), base="nw")
  197. pp_bg = pp_bg.to_overlay_pic_advance(
  198. mode="pixel",
  199. top_img=pp_jpg_1,
  200. base="center",
  201. value=(0, 0),
  202. top_png_img=pp_png_1,
  203. )
  204. return pp_bg
  205. # 产品展示,帮面等等
  206. def deal_pic_7(self):
  207. pp_bg = PictureProcessing(r"{}\7.jpg".format(self.root))
  208. goods_art_no_list = list(self.data.keys())
  209. pp_jpg_1, pp_png_1 = self.image_one_pic(
  210. return_orign=True,
  211. goods_art_no=goods_art_no_list[0],
  212. name="俯视",
  213. )
  214. pp_jpg_1 = pp_jpg_1.resize(value=500)
  215. pp_png_1 = pp_png_1.resize(value=500)
  216. # pp_bg = pp_bg.paste_img(top_img=shoe_bg, value=(0, 0), base="nw")
  217. pp_bg = pp_bg.to_overlay_pic_advance(
  218. mode="pixel",
  219. top_img=pp_jpg_1,
  220. base="es",
  221. value=(200, 208),
  222. top_png_img=pp_png_1,
  223. )
  224. font = ImageFont.truetype(
  225. r"resources\ttf\puhui\Medium.ttf", 24
  226. ) # 设计理念
  227. font_hei = ImageFont.truetype(r"resources\ttf\simhei.ttf", 24) # 设计理念
  228. bangmian = self.get_text_value("帮面")
  229. neili = self.get_text_value("内里")
  230. xiedi = self.get_text_value("鞋底")
  231. xiedian = self.get_text_value("鞋垫")
  232. xiekuan = self.get_text_value("鞋宽")
  233. banggao = self.get_text_value("帮高")
  234. gengao = self.get_text_value("跟高")
  235. pp_bg.get_text_image_advanced(
  236. value=(230, 346),
  237. font=font,
  238. text=bangmian,
  239. align="left",
  240. # anchor="ma",
  241. spacing=5,
  242. fill=(60, 40, 29),
  243. return_mode="image",
  244. margins=(0, 0, 0, 0),
  245. )
  246. pp_bg.get_text_image_advanced(
  247. value=(551, 346),
  248. font=font,
  249. text=neili,
  250. align="left",
  251. # anchor="ma",
  252. spacing=5,
  253. fill=(60, 40, 29),
  254. return_mode="image",
  255. margins=(0, 0, 0, 0),
  256. )
  257. pp_bg.get_text_image_advanced(
  258. value=(230, 456),
  259. font=font,
  260. text=xiedi,
  261. align="left",
  262. # anchor="ma",
  263. spacing=5,
  264. fill=(60, 40, 29),
  265. return_mode="image",
  266. margins=(0, 0, 0, 0),
  267. )
  268. pp_bg.get_text_image_advanced(
  269. value=(551, 456),
  270. font=font,
  271. text=xiedian,
  272. align="left",
  273. # anchor="ma",
  274. spacing=5,
  275. fill=(60, 40, 29),
  276. return_mode="image",
  277. margins=(0, 0, 0, 0),
  278. )
  279. pp_bg.get_text_image_advanced(
  280. value=(64, 901),
  281. font=font_hei,
  282. text=xiekuan,
  283. align="left",
  284. # anchor="ma",
  285. spacing=5,
  286. fill=(60, 40, 29),
  287. return_mode="image",
  288. margins=(0, 0, 0, 0),
  289. )
  290. pp_bg.get_text_image_advanced(
  291. value=(621, 650),
  292. font=font_hei,
  293. text=banggao,
  294. align="left",
  295. # anchor="ma",
  296. spacing=5,
  297. fill=(60, 40, 29),
  298. return_mode="image",
  299. margins=(0, 0, 0, 0),
  300. )
  301. pp_bg.get_text_image_advanced(
  302. value=(621, 752),
  303. font=font_hei,
  304. text=gengao,
  305. align="left",
  306. # anchor="ma",
  307. spacing=5,
  308. fill=(60, 40, 29),
  309. return_mode="image",
  310. margins=(0, 0, 0, 0),
  311. )
  312. return pp_bg
  313. # 功能展示与卖点
  314. def deal_pic_8(self):
  315. detailed_images = []
  316. pp_bg = PictureProcessing(r"{}\7.jpg".format(self.root))
  317. # detailed_images.append(pp_bg)
  318. goods_art_no_list = list(self.data.keys())
  319. all_color_name = []
  320. bg_color = (253, 250, 242)
  321. text_color = (70, 48, 41)
  322. font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 25)
  323. goods_art_images = []
  324. total_height = 0
  325. for index, goods_art_no in enumerate(goods_art_no_list):
  326. pp_jpg = self.get_overlay_pic_from_dict(
  327. goods_art_no=goods_art_no,
  328. color_name="侧视",
  329. bg_color=bg_color,
  330. )
  331. if pp_jpg is None:
  332. continue
  333. pp_jpg = pp_jpg.resize(value=pp_bg.width/2.5)
  334. color_name = self.goods_no_value["货号资料"][index]["颜色名称"]
  335. all_color_name.append(color_name)
  336. text_bg = PictureProcessing("RGB", (pp_jpg.width, 50), bg_color)
  337. text_bg = text_bg.get_text_image_advanced(
  338. value=(0, 0),
  339. font=font,
  340. text="● {}".format(color_name),
  341. align="center",
  342. # anchor="mm",
  343. spacing=5,
  344. fill=text_color,
  345. return_mode="image",
  346. margins=(0, 0, 0, 0),
  347. )
  348. _bg = PictureProcessing(
  349. "RGB",
  350. (pp_bg.width / 2, pp_jpg.height+200),
  351. bg_color,
  352. )
  353. if (index+1) == 1:
  354. total_height += _bg.height
  355. if (index + 1) % 2 != 0 and (index + 1) != 1:
  356. total_height += _bg.height
  357. _bg = _bg.paste_img(top_img=pp_jpg, base="center")
  358. _bg = _bg.paste_img(
  359. top_img=text_bg, value=(pp_jpg.width / 2, pp_jpg.height+100)
  360. )
  361. goods_art_images.append(_bg)
  362. rows = 2
  363. shoes_bg = PictureProcessing(
  364. ).horizontal_distribution(
  365. pp_list=goods_art_images,
  366. bg_width=pp_bg.width,
  367. margins=(0, 0, 0, 0),
  368. line_spacing=0,
  369. number_per_row=rows,
  370. )
  371. main_bg = PictureProcessing(
  372. "RGB",
  373. (pp_bg.width, total_height),
  374. bg_color,
  375. )
  376. main_bg.paste_img(top_img=shoes_bg)
  377. detailed_images.append(main_bg)
  378. return PictureProcessing(im=self.add_pic(detailed_images))
  379. # 添加尺码表
  380. def deal_pic_9(self):
  381. image_path = r"{}\9.jpg".format(self.root)
  382. return PictureProcessing(image_path)
  383. # 角度展示
  384. def deal_pic_10(self):
  385. detailed_images = []
  386. # 角度展示标题
  387. detailed_images.append(PictureProcessing(r"{}\10.jpg".format(self.root)))
  388. return self.pp_pic_subsection(
  389. PictureProcessing(im=self.add_pic(detailed_images))
  390. )
  391. # 添加注意事项
  392. def deal_pic_11(self):
  393. detailed_images = []
  394. image_path = r"{}\11.jpg".format(self.root)
  395. pp_bg = PictureProcessing(image_path)
  396. goods_art_no_list = list(self.data.keys())
  397. pp_jpg_1, pp_png_1 = self.image_one_pic(
  398. return_orign=True,
  399. goods_art_no=goods_art_no_list[0],
  400. name="俯视",
  401. )
  402. pp_jpg_1 = pp_jpg_1.resize(value=1400)
  403. pp_png_1 = pp_png_1.resize(value=1400)
  404. pp_bg = pp_bg.to_overlay_pic_advance(
  405. mode="pixel",
  406. top_img=pp_jpg_1,
  407. base="nw",
  408. value=(0, pp_bg.height - pp_jpg_1.height),
  409. top_png_img=pp_png_1,
  410. )
  411. font_main = ImageFont.truetype(
  412. r"resources\ttf\puhui\Medium.ttf", 58
  413. ) # 设计理念
  414. mainTitle = self.get_text_value("细节亮点主标题")
  415. subTitle = self.get_text_value("细节亮点副标题")
  416. pp_bg.get_text_image_advanced(
  417. value=(pp_bg.width/2, 219),
  418. font=font_main,
  419. text=mainTitle,
  420. align="center",
  421. anchor="ma",
  422. spacing=5,
  423. fill=(60, 40, 29),
  424. return_mode="image",
  425. margins=(0, 0, 0, 0),
  426. )
  427. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 36) # 设计理念
  428. pp_bg.get_text_image_advanced(
  429. value=(pp_bg.width / 2, 313),
  430. font=font_sub,
  431. text=subTitle,
  432. align="center",
  433. anchor="ma",
  434. spacing=5,
  435. fill=(60, 40, 29),
  436. return_mode="image",
  437. margins=(0, 0, 0, 0),
  438. )
  439. detailed_images.append(pp_bg)
  440. bg_12_image_path = r"{}\12.jpg".format(self.root)
  441. bg_12 = PictureProcessing(bg_12_image_path)
  442. detailed_images.append(bg_12)
  443. return self.pp_pic_subsection(
  444. PictureProcessing(im=self.add_pic(detailed_images))
  445. )
  446. def deal_pic_13(self):
  447. detailed_images = []
  448. image_path = r"{}\13.jpg".format(self.root)
  449. pp_bg = PictureProcessing(image_path)
  450. image_path_1 = r"{}\13_1.png".format(self.root)
  451. pp_bg_1 = PictureProcessing(image_path_1)
  452. font_main = ImageFont.truetype(
  453. r"resources\ttf\puhui\Medium.ttf", 58
  454. ) # 设计理念
  455. pp_bg.get_text_image_advanced(
  456. value=(pp_bg.width / 2, 168),
  457. font=font_main,
  458. text="经典系带",
  459. align="center",
  460. anchor="ma",
  461. spacing=5,
  462. fill=(60, 40, 29),
  463. return_mode="image",
  464. margins=(0, 0, 0, 0),
  465. )
  466. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 36) # 设计理念
  467. pp_bg.get_text_image_advanced(
  468. value=(pp_bg.width / 2, 261),
  469. font=font_sub,
  470. text="松紧自由调节",
  471. align="center",
  472. anchor="ma",
  473. spacing=5,
  474. fill=(60, 40, 29),
  475. return_mode="image",
  476. margins=(0, 0, 0, 0),
  477. )
  478. goods_art_no_list = list(self.data.keys())
  479. pp_jpg_1, pp_png_1 = self.image_one_pic(
  480. return_orign=True,
  481. goods_art_no=goods_art_no_list[0],
  482. name="俯视",
  483. )
  484. pp_jpg_1 = pp_jpg_1.resize(value=1500)
  485. pp_png_1 = pp_png_1.resize(value=1500)
  486. pp_bg = pp_bg.to_overlay_pic_advance(
  487. mode="pixel",
  488. top_img=pp_jpg_1,
  489. base="cs",
  490. value=(0, - pp_jpg_1.height/4),
  491. top_png_img=pp_png_1,
  492. )
  493. pp_bg.paste_img(top_img=pp_bg_1)
  494. detailed_images.append(pp_bg)
  495. return self.pp_pic_subsection(
  496. PictureProcessing(im=self.add_pic(detailed_images))
  497. )
  498. def deal_pic_14(self):
  499. # 场景展示
  500. detailed_images = []
  501. image_path = r"{}\14.jpg".format(self.root)
  502. pp_bg_14 = PictureProcessing(image_path)
  503. goods_art_no_list = list(self.data.keys())
  504. # print("执行14")
  505. pp_jpg_1, pp_png_1 = self.image_one_pic(
  506. return_orign=True,
  507. goods_art_no=goods_art_no_list[0],
  508. name="组合",
  509. )
  510. if pp_jpg_1:
  511. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_14.width)
  512. pp_png_1 = pp_png_1.resize(value=pp_bg_14.width)
  513. pp_bg_14 = pp_bg_14.to_overlay_pic_advance(
  514. mode="pixel",
  515. top_img=pp_jpg_1,
  516. base="cc",
  517. value=(0, 0),
  518. top_png_img=pp_png_1,
  519. )
  520. detailed_images.append(pp_bg_14)
  521. return self.pp_pic_subsection(
  522. PictureProcessing(im=self.add_pic(detailed_images))
  523. )
  524. def deal_pic_15(self):
  525. detailed_images = []
  526. image_path = r"{}\15.jpg".format(self.root)
  527. pp_bg_15 = PictureProcessing(image_path)
  528. goods_art_no_list = list(self.data.keys())
  529. print("执行15")
  530. pp_jpg_1, pp_png_1 = self.image_one_pic(
  531. return_orign=True,
  532. goods_art_no=goods_art_no_list[0],
  533. name="组合2",
  534. )
  535. if pp_jpg_1:
  536. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_15.width)
  537. pp_png_1 = pp_png_1.resize(value=pp_bg_15.width)
  538. pp_bg_15 = pp_bg_15.to_overlay_pic_advance(
  539. mode="pixel",
  540. top_img=pp_jpg_1,
  541. base="cc",
  542. value=(0, 0),
  543. top_png_img=pp_png_1,
  544. )
  545. detailed_images.append(pp_bg_15)
  546. return self.pp_pic_subsection(
  547. PictureProcessing(im=self.add_pic(detailed_images))
  548. )
  549. def deal_pic_16(self):
  550. detailed_images = []
  551. image_path = r"{}\16.jpg".format(self.root)
  552. pp_bg_16 = PictureProcessing(image_path)
  553. goods_art_no_list = list(self.data.keys())
  554. print("执行16")
  555. pp_jpg_1, pp_png_1 = self.image_one_pic(
  556. return_orign=True,
  557. goods_art_no=goods_art_no_list[0],
  558. name="组合3",
  559. )
  560. if pp_jpg_1:
  561. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_16.width)
  562. pp_png_1 = pp_png_1.resize(value=pp_bg_16.width)
  563. pp_bg_16 = pp_bg_16.to_overlay_pic_advance(
  564. mode="pixel",
  565. top_img=pp_jpg_1,
  566. base="cc",
  567. value=(0, 0),
  568. top_png_img=pp_png_1,
  569. )
  570. detailed_images.append(pp_bg_16)
  571. return self.pp_pic_subsection(
  572. PictureProcessing(im=self.add_pic(detailed_images))
  573. )
  574. def deal_pic_17(self):
  575. # 产品细节
  576. image_path = r"{}\17.jpg".format(self.root)
  577. image_path_1 = r"{}\17_1.png".format(self.root)
  578. detailed_images = []
  579. pp_bg_1 = PictureProcessing(image_path_1)
  580. pp_bg = PictureProcessing(image_path)
  581. goods_art_no_list = list(self.data.keys())
  582. pp_jpg_1, pp_png_1 = self.image_one_pic(
  583. return_orign=True,
  584. goods_art_no=goods_art_no_list[0],
  585. name="俯视",
  586. )
  587. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width+100)
  588. pp_png_1 = pp_png_1.resize(value=pp_bg.width + 100)
  589. pp_bg = pp_bg.to_overlay_pic_advance(
  590. mode="pixel",
  591. top_img=pp_jpg_1,
  592. base="cs",
  593. value=(0, 0),
  594. top_png_img=pp_png_1,
  595. )
  596. mainTitle = self.get_text_value("艺-主标题")
  597. subTitle = self.get_text_value("艺-副标题")
  598. font_main = ImageFont.truetype(
  599. r"resources\ttf\puhui\Medium.ttf", 30
  600. ) # 设计理念
  601. pp_bg.get_text_image_advanced(
  602. value=(113, 545),
  603. font=font_main,
  604. text=mainTitle,
  605. align="left",
  606. # anchor="ma",
  607. spacing=5,
  608. fill=(60, 40, 29),
  609. return_mode="image",
  610. margins=(0, 0, 0, 0),
  611. )
  612. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
  613. pp_bg.get_text_image_advanced(
  614. value=(113, 602),
  615. font=font_sub,
  616. text=subTitle,
  617. align="left",
  618. # anchor="ma",
  619. spacing=5,
  620. fill=(60, 40, 29),
  621. return_mode="image",
  622. margins=(0, 0, 0, 0),
  623. )
  624. pp_bg.paste_img(top_img=pp_bg_1)
  625. detailed_images.append(pp_bg)
  626. return self.pp_pic_subsection(
  627. PictureProcessing(im=self.add_pic(detailed_images))
  628. )
  629. def deal_pic_18(self):
  630. image_path = r"{}\18.jpg".format(self.root)
  631. image_path_1 = r"{}\18_1.png".format(self.root)
  632. detailed_images = []
  633. pp_bg_1 = PictureProcessing(image_path_1)
  634. pp_bg = PictureProcessing(image_path)
  635. goods_art_no_list = list(self.data.keys())
  636. pp_jpg_1, pp_png_1 = self.image_one_pic(
  637. return_orign=True,
  638. goods_art_no=goods_art_no_list[0],
  639. name="侧视",
  640. )
  641. pp_jpg_1 = pp_jpg_1.resize(value=1400)
  642. pp_png_1 = pp_png_1.resize(value=1400)
  643. pp_bg = pp_bg.to_overlay_pic_advance(
  644. mode="pixel",
  645. top_img=pp_jpg_1,
  646. base="cs",
  647. value=(-pp_jpg_1.width/3, 0),
  648. top_png_img=pp_png_1,
  649. )
  650. mainTitle = self.get_text_value("跟-主标题")
  651. subTitle = self.get_text_value("跟-副标题")
  652. gengao = self.get_text_value("跟高")
  653. font_main = ImageFont.truetype(
  654. r"resources\ttf\puhui\Medium.ttf", 30
  655. ) # 设计理念
  656. pp_bg.get_text_image_advanced(
  657. value=(441, 220),
  658. font=font_main,
  659. text=mainTitle,
  660. align="right",
  661. # anchor="rs",
  662. spacing=5,
  663. fill=(60, 40, 29),
  664. return_mode="image",
  665. margins=(0, 0, 0, 0),
  666. )
  667. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
  668. pp_bg.get_text_image_advanced(
  669. value=(441, 272),
  670. font=font_sub,
  671. text=subTitle,
  672. align="right",
  673. # anchor="ls",
  674. spacing=5,
  675. fill=(60, 40, 29),
  676. return_mode="image",
  677. margins=(0, 0, 0, 0),
  678. )
  679. pp_bg.get_text_image_advanced(
  680. value=(605, 648),
  681. font=font_main,
  682. text=gengao,
  683. align="right",
  684. # anchor="ls",
  685. spacing=5,
  686. fill=(60, 40, 29),
  687. return_mode="image",
  688. margins=(0, 0, 0, 0),
  689. )
  690. pp_bg.paste_img(top_img=pp_bg_1)
  691. detailed_images.append(pp_bg)
  692. return self.pp_pic_subsection(
  693. PictureProcessing(im=self.add_pic(detailed_images))
  694. )
  695. def deal_pic_19(self):
  696. detailed_images = []
  697. image_path = r"{}\19.jpg".format(self.root)
  698. pp_bg = PictureProcessing(image_path)
  699. # 鞋底
  700. goods_art_no_list = list(self.data.keys())
  701. pp_jpg_1, pp_png_1 = self.image_one_pic(
  702. return_orign=True,
  703. goods_art_no=goods_art_no_list[0],
  704. name="鞋底",
  705. )
  706. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width)
  707. pp_png_1 = pp_png_1.resize(value=pp_bg.width)
  708. pp_bg = pp_bg.to_overlay_pic_advance(
  709. mode="pixel",
  710. top_img=pp_jpg_1,
  711. base="center",
  712. value=(0, 200),
  713. top_png_img=pp_png_1,
  714. )
  715. mainTitle = self.get_text_value("底-主标题")
  716. subTitle = self.get_text_value("底-副标题")
  717. font_main = ImageFont.truetype(
  718. r"resources\ttf\puhui\Medium.ttf", 30
  719. ) # 设计理念
  720. pp_bg.get_text_image_advanced(
  721. value=(114, 259),
  722. font=font_main,
  723. text=mainTitle,
  724. align="left",
  725. # anchor="rs",
  726. spacing=5,
  727. fill=(60, 40, 29),
  728. return_mode="image",
  729. margins=(0, 0, 0, 0),
  730. )
  731. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
  732. pp_bg.get_text_image_advanced(
  733. value=(114, 311),
  734. font=font_sub,
  735. text=subTitle,
  736. align="left",
  737. # anchor="ls",
  738. spacing=5,
  739. fill=(60, 40, 29),
  740. return_mode="image",
  741. margins=(0, 0, 0, 0),
  742. )
  743. # return PictureProcessing(image_path)
  744. detailed_images.append(pp_bg)
  745. return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
  746. def deal_pic_20(self):
  747. detailed_images = []
  748. bg_20 = PictureProcessing(r"{}\20.jpg".format(self.root))
  749. bg_21 = PictureProcessing(r"{}\21.jpg".format(self.root))
  750. bg_22 = PictureProcessing(r"{}\22.jpg".format(self.root))
  751. detailed_images.append(bg_20)
  752. detailed_images.append(bg_21)
  753. detailed_images.append(bg_22)
  754. return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
  755. if __name__ == "__main__":
  756. d = DetailPicGet(
  757. goods_no="test",
  758. goods_no_value={},
  759. out_put_dir="./output/xinnuo-1",
  760. test=True,
  761. )
  762. d.run_test()