detail_xinnuo1.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  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. pp_jpg_1, pp_png_1 = self.image_one_pic(
  530. return_orign=True,
  531. goods_art_no=goods_art_no_list[0],
  532. name="组合2",
  533. )
  534. if pp_jpg_1:
  535. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_15.width)
  536. pp_png_1 = pp_png_1.resize(value=pp_bg_15.width)
  537. pp_bg_15 = pp_bg_15.to_overlay_pic_advance(
  538. mode="pixel",
  539. top_img=pp_jpg_1,
  540. base="cc",
  541. value=(0, 0),
  542. top_png_img=pp_png_1,
  543. )
  544. detailed_images.append(pp_bg_15)
  545. return self.pp_pic_subsection(
  546. PictureProcessing(im=self.add_pic(detailed_images))
  547. )
  548. def deal_pic_16(self):
  549. detailed_images = []
  550. image_path = r"{}\16.jpg".format(self.root)
  551. pp_bg_16 = PictureProcessing(image_path)
  552. goods_art_no_list = list(self.data.keys())
  553. print("执行16")
  554. pp_jpg_1, pp_png_1 = self.image_one_pic(
  555. return_orign=True,
  556. goods_art_no=goods_art_no_list[0],
  557. name="组合3",
  558. )
  559. if pp_jpg_1:
  560. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_16.width)
  561. pp_png_1 = pp_png_1.resize(value=pp_bg_16.width)
  562. pp_bg_16 = pp_bg_16.to_overlay_pic_advance(
  563. mode="pixel",
  564. top_img=pp_jpg_1,
  565. base="cc",
  566. value=(0, 0),
  567. top_png_img=pp_png_1,
  568. )
  569. detailed_images.append(pp_bg_16)
  570. return self.pp_pic_subsection(
  571. PictureProcessing(im=self.add_pic(detailed_images))
  572. )
  573. def deal_pic_17(self):
  574. # 产品细节
  575. image_path = r"{}\17.jpg".format(self.root)
  576. image_path_1 = r"{}\17_1.png".format(self.root)
  577. detailed_images = []
  578. pp_bg_1 = PictureProcessing(image_path_1)
  579. pp_bg = PictureProcessing(image_path)
  580. goods_art_no_list = list(self.data.keys())
  581. pp_jpg_1, pp_png_1 = self.image_one_pic(
  582. return_orign=True,
  583. goods_art_no=goods_art_no_list[0],
  584. name="俯视",
  585. )
  586. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width+100)
  587. pp_png_1 = pp_png_1.resize(value=pp_bg.width + 100)
  588. pp_bg = pp_bg.to_overlay_pic_advance(
  589. mode="pixel",
  590. top_img=pp_jpg_1,
  591. base="cs",
  592. value=(0, 0),
  593. top_png_img=pp_png_1,
  594. )
  595. mainTitle = self.get_text_value("艺-主标题")
  596. subTitle = self.get_text_value("艺-副标题")
  597. font_main = ImageFont.truetype(
  598. r"resources\ttf\puhui\Medium.ttf", 30
  599. ) # 设计理念
  600. pp_bg.get_text_image_advanced(
  601. value=(113, 545),
  602. font=font_main,
  603. text=mainTitle,
  604. align="left",
  605. # anchor="ma",
  606. spacing=5,
  607. fill=(60, 40, 29),
  608. return_mode="image",
  609. margins=(0, 0, 0, 0),
  610. )
  611. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
  612. pp_bg.get_text_image_advanced(
  613. value=(113, 602),
  614. font=font_sub,
  615. text=subTitle,
  616. align="left",
  617. # anchor="ma",
  618. spacing=5,
  619. fill=(60, 40, 29),
  620. return_mode="image",
  621. margins=(0, 0, 0, 0),
  622. )
  623. pp_bg.paste_img(top_img=pp_bg_1)
  624. detailed_images.append(pp_bg)
  625. return self.pp_pic_subsection(
  626. PictureProcessing(im=self.add_pic(detailed_images))
  627. )
  628. def deal_pic_18(self):
  629. image_path = r"{}\18.jpg".format(self.root)
  630. image_path_1 = r"{}\18_1.png".format(self.root)
  631. detailed_images = []
  632. pp_bg_1 = PictureProcessing(image_path_1)
  633. pp_bg = PictureProcessing(image_path)
  634. goods_art_no_list = list(self.data.keys())
  635. pp_jpg_1, pp_png_1 = self.image_one_pic(
  636. return_orign=True,
  637. goods_art_no=goods_art_no_list[0],
  638. name="侧视",
  639. )
  640. pp_jpg_1 = pp_jpg_1.resize(value=1400)
  641. pp_png_1 = pp_png_1.resize(value=1400)
  642. pp_bg = pp_bg.to_overlay_pic_advance(
  643. mode="pixel",
  644. top_img=pp_jpg_1,
  645. base="cs",
  646. value=(-pp_jpg_1.width/3, 0),
  647. top_png_img=pp_png_1,
  648. )
  649. mainTitle = self.get_text_value("跟-主标题")
  650. subTitle = self.get_text_value("跟-副标题")
  651. gengao = self.get_text_value("跟高")
  652. font_main = ImageFont.truetype(
  653. r"resources\ttf\puhui\Medium.ttf", 30
  654. ) # 设计理念
  655. pp_bg.get_text_image_advanced(
  656. value=(441, 220),
  657. font=font_main,
  658. text=mainTitle,
  659. align="right",
  660. # anchor="rs",
  661. spacing=5,
  662. fill=(60, 40, 29),
  663. return_mode="image",
  664. margins=(0, 0, 0, 0),
  665. )
  666. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
  667. pp_bg.get_text_image_advanced(
  668. value=(441, 272),
  669. font=font_sub,
  670. text=subTitle,
  671. align="right",
  672. # anchor="ls",
  673. spacing=5,
  674. fill=(60, 40, 29),
  675. return_mode="image",
  676. margins=(0, 0, 0, 0),
  677. )
  678. pp_bg.get_text_image_advanced(
  679. value=(605, 648),
  680. font=font_main,
  681. text=gengao,
  682. align="right",
  683. # anchor="ls",
  684. spacing=5,
  685. fill=(60, 40, 29),
  686. return_mode="image",
  687. margins=(0, 0, 0, 0),
  688. )
  689. pp_bg.paste_img(top_img=pp_bg_1)
  690. detailed_images.append(pp_bg)
  691. return self.pp_pic_subsection(
  692. PictureProcessing(im=self.add_pic(detailed_images))
  693. )
  694. def deal_pic_19(self):
  695. detailed_images = []
  696. image_path = r"{}\19.jpg".format(self.root)
  697. pp_bg = PictureProcessing(image_path)
  698. # 鞋底
  699. goods_art_no_list = list(self.data.keys())
  700. pp_jpg_1, pp_png_1 = self.image_one_pic(
  701. return_orign=True,
  702. goods_art_no=goods_art_no_list[0],
  703. name="鞋底",
  704. )
  705. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width)
  706. pp_png_1 = pp_png_1.resize(value=pp_bg.width)
  707. pp_bg = pp_bg.to_overlay_pic_advance(
  708. mode="pixel",
  709. top_img=pp_jpg_1,
  710. base="center",
  711. value=(0, 200),
  712. top_png_img=pp_png_1,
  713. )
  714. mainTitle = self.get_text_value("底-主标题")
  715. subTitle = self.get_text_value("底-副标题")
  716. font_main = ImageFont.truetype(
  717. r"resources\ttf\puhui\Medium.ttf", 30
  718. ) # 设计理念
  719. pp_bg.get_text_image_advanced(
  720. value=(114, 259),
  721. font=font_main,
  722. text=mainTitle,
  723. align="left",
  724. # anchor="rs",
  725. spacing=5,
  726. fill=(60, 40, 29),
  727. return_mode="image",
  728. margins=(0, 0, 0, 0),
  729. )
  730. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
  731. pp_bg.get_text_image_advanced(
  732. value=(114, 311),
  733. font=font_sub,
  734. text=subTitle,
  735. align="left",
  736. # anchor="ls",
  737. spacing=5,
  738. fill=(60, 40, 29),
  739. return_mode="image",
  740. margins=(0, 0, 0, 0),
  741. )
  742. # return PictureProcessing(image_path)
  743. detailed_images.append(pp_bg)
  744. return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
  745. def deal_pic_20(self):
  746. detailed_images = []
  747. bg_20 = PictureProcessing(r"{}\20.jpg".format(self.root))
  748. bg_21 = PictureProcessing(r"{}\21.jpg".format(self.root))
  749. bg_22 = PictureProcessing(r"{}\22.jpg".format(self.root))
  750. detailed_images.append(bg_20)
  751. detailed_images.append(bg_21)
  752. detailed_images.append(bg_22)
  753. return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
  754. if __name__ == "__main__":
  755. d = DetailPicGet(
  756. goods_no="test",
  757. goods_no_value={},
  758. out_put_dir="./output/xinnuo-1",
  759. test=True,
  760. )
  761. d.run_test()