detail_xinnuo1.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  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="ne",
  173. value=(100, 0),
  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="ne",
  221. value=(200, 578),
  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. print("高度:", total_height)
  358. _bg = _bg.paste_img(top_img=pp_jpg, base="center")
  359. _bg = _bg.paste_img(
  360. top_img=text_bg, value=(pp_jpg.width / 2, pp_jpg.height+100)
  361. )
  362. goods_art_images.append(_bg)
  363. rows = 2
  364. shoes_bg = PictureProcessing(
  365. ).horizontal_distribution(
  366. pp_list=goods_art_images,
  367. bg_width=pp_bg.width,
  368. margins=(0, 0, 0, 0),
  369. line_spacing=0,
  370. number_per_row=rows,
  371. )
  372. main_bg = PictureProcessing(
  373. "RGB",
  374. (pp_bg.width, total_height),
  375. bg_color,
  376. )
  377. main_bg.paste_img(top_img=shoes_bg)
  378. detailed_images.append(main_bg)
  379. return PictureProcessing(im=self.add_pic(detailed_images))
  380. # 添加尺码表
  381. def deal_pic_9(self):
  382. image_path = r"{}\9.jpg".format(self.root)
  383. return PictureProcessing(image_path)
  384. # 角度展示
  385. def deal_pic_10(self):
  386. detailed_images = []
  387. # 角度展示标题
  388. detailed_images.append(PictureProcessing(r"{}\10.jpg".format(self.root)))
  389. return self.pp_pic_subsection(
  390. PictureProcessing(im=self.add_pic(detailed_images))
  391. )
  392. # 添加注意事项
  393. def deal_pic_11(self):
  394. detailed_images = []
  395. image_path = r"{}\11.jpg".format(self.root)
  396. pp_bg = PictureProcessing(image_path)
  397. goods_art_no_list = list(self.data.keys())
  398. pp_jpg_1, pp_png_1 = self.image_one_pic(
  399. return_orign=True,
  400. goods_art_no=goods_art_no_list[0],
  401. name="俯视",
  402. )
  403. pp_jpg_1 = pp_jpg_1.resize(value=1400)
  404. pp_png_1 = pp_png_1.resize(value=1400)
  405. pp_bg = pp_bg.to_overlay_pic_advance(
  406. mode="pixel",
  407. top_img=pp_jpg_1,
  408. base="nw",
  409. value=(0, pp_bg.height - pp_jpg_1.height),
  410. top_png_img=pp_png_1,
  411. )
  412. font_main = ImageFont.truetype(
  413. r"resources\ttf\puhui\Medium.ttf", 58
  414. ) # 设计理念
  415. mainTitle = self.get_text_value("细节亮点主标题")
  416. subTitle = self.get_text_value("细节亮点副标题")
  417. pp_bg.get_text_image_advanced(
  418. value=(pp_bg.width/2, 219),
  419. font=font_main,
  420. text=mainTitle,
  421. align="center",
  422. anchor="ma",
  423. spacing=5,
  424. fill=(60, 40, 29),
  425. return_mode="image",
  426. margins=(0, 0, 0, 0),
  427. )
  428. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 36) # 设计理念
  429. pp_bg.get_text_image_advanced(
  430. value=(pp_bg.width / 2, 313),
  431. font=font_sub,
  432. text=subTitle,
  433. align="center",
  434. anchor="ma",
  435. spacing=5,
  436. fill=(60, 40, 29),
  437. return_mode="image",
  438. margins=(0, 0, 0, 0),
  439. )
  440. detailed_images.append(pp_bg)
  441. bg_12_image_path = r"{}\12.jpg".format(self.root)
  442. bg_12 = PictureProcessing(bg_12_image_path)
  443. detailed_images.append(bg_12)
  444. return self.pp_pic_subsection(
  445. PictureProcessing(im=self.add_pic(detailed_images))
  446. )
  447. def deal_pic_13(self):
  448. detailed_images = []
  449. image_path = r"{}\13.jpg".format(self.root)
  450. pp_bg = PictureProcessing(image_path)
  451. image_path_1 = r"{}\13_1.png".format(self.root)
  452. pp_bg_1 = PictureProcessing(image_path_1)
  453. font_main = ImageFont.truetype(
  454. r"resources\ttf\puhui\Medium.ttf", 58
  455. ) # 设计理念
  456. pp_bg.get_text_image_advanced(
  457. value=(pp_bg.width / 2, 168),
  458. font=font_main,
  459. text="经典系带",
  460. align="center",
  461. anchor="ma",
  462. spacing=5,
  463. fill=(60, 40, 29),
  464. return_mode="image",
  465. margins=(0, 0, 0, 0),
  466. )
  467. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 36) # 设计理念
  468. pp_bg.get_text_image_advanced(
  469. value=(pp_bg.width / 2, 261),
  470. font=font_sub,
  471. text="松紧自由调节",
  472. align="center",
  473. anchor="ma",
  474. spacing=5,
  475. fill=(60, 40, 29),
  476. return_mode="image",
  477. margins=(0, 0, 0, 0),
  478. )
  479. goods_art_no_list = list(self.data.keys())
  480. pp_jpg_1, pp_png_1 = self.image_one_pic(
  481. return_orign=True,
  482. goods_art_no=goods_art_no_list[0],
  483. name="俯视",
  484. )
  485. pp_jpg_1 = pp_jpg_1.resize(value=1500)
  486. pp_png_1 = pp_png_1.resize(value=1500)
  487. pp_bg = pp_bg.to_overlay_pic_advance(
  488. mode="pixel",
  489. top_img=pp_jpg_1,
  490. base="cs",
  491. value=(0, - pp_jpg_1.height/4),
  492. top_png_img=pp_png_1,
  493. )
  494. pp_bg.paste_img(top_img=pp_bg_1)
  495. detailed_images.append(pp_bg)
  496. return self.pp_pic_subsection(
  497. PictureProcessing(im=self.add_pic(detailed_images))
  498. )
  499. def deal_pic_14(self):
  500. # 场景展示
  501. detailed_images = []
  502. image_path = r"{}\14.jpg".format(self.root)
  503. pp_bg_14 = PictureProcessing(image_path)
  504. goods_art_no_list = list(self.data.keys())
  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. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_14.width)
  511. pp_png_1 = pp_png_1.resize(value=pp_bg_14.width)
  512. pp_bg_14 = pp_bg_14.to_overlay_pic_advance(
  513. mode="pixel",
  514. top_img=pp_jpg_1,
  515. base="cc",
  516. value=(0, 0),
  517. top_png_img=pp_png_1,
  518. )
  519. detailed_images.append(pp_bg_14)
  520. return self.pp_pic_subsection(
  521. PictureProcessing(im=self.add_pic(detailed_images))
  522. )
  523. def deal_pic_15(self):
  524. detailed_images = []
  525. image_path = r"{}\15.jpg".format(self.root)
  526. pp_bg_15 = PictureProcessing(image_path)
  527. goods_art_no_list = list(self.data.keys())
  528. pp_jpg_1, pp_png_1 = self.image_one_pic(
  529. return_orign=True,
  530. goods_art_no=goods_art_no_list[0],
  531. name="组合2",
  532. )
  533. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_15.width)
  534. pp_png_1 = pp_png_1.resize(value=pp_bg_15.width)
  535. pp_bg_15 = pp_bg_15.to_overlay_pic_advance(
  536. mode="pixel",
  537. top_img=pp_jpg_1,
  538. base="cc",
  539. value=(0, 0),
  540. top_png_img=pp_png_1,
  541. )
  542. detailed_images.append(pp_bg_15)
  543. return self.pp_pic_subsection(
  544. PictureProcessing(im=self.add_pic(detailed_images))
  545. )
  546. def deal_pic_16(self):
  547. detailed_images = []
  548. image_path = r"{}\16.jpg".format(self.root)
  549. pp_bg_16 = PictureProcessing(image_path)
  550. goods_art_no_list = list(self.data.keys())
  551. pp_jpg_1, pp_png_1 = self.image_one_pic(
  552. return_orign=True,
  553. goods_art_no=goods_art_no_list[0],
  554. name="组合3",
  555. )
  556. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_16.width)
  557. pp_png_1 = pp_png_1.resize(value=pp_bg_16.width)
  558. pp_bg_16 = pp_bg_16.to_overlay_pic_advance(
  559. mode="pixel",
  560. top_img=pp_jpg_1,
  561. base="cc",
  562. value=(0, 0),
  563. top_png_img=pp_png_1,
  564. )
  565. detailed_images.append(pp_bg_16)
  566. return self.pp_pic_subsection(
  567. PictureProcessing(im=self.add_pic(detailed_images))
  568. )
  569. def deal_pic_17(self):
  570. # 产品细节
  571. image_path = r"{}\17.jpg".format(self.root)
  572. image_path_1 = r"{}\17_1.png".format(self.root)
  573. detailed_images = []
  574. pp_bg_1 = PictureProcessing(image_path_1)
  575. pp_bg = PictureProcessing(image_path)
  576. goods_art_no_list = list(self.data.keys())
  577. pp_jpg_1, pp_png_1 = self.image_one_pic(
  578. return_orign=True,
  579. goods_art_no=goods_art_no_list[0],
  580. name="俯视",
  581. )
  582. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width+100)
  583. pp_png_1 = pp_png_1.resize(value=pp_bg.width + 100)
  584. pp_bg = pp_bg.to_overlay_pic_advance(
  585. mode="pixel",
  586. top_img=pp_jpg_1,
  587. base="cs",
  588. value=(0, 0),
  589. top_png_img=pp_png_1,
  590. )
  591. mainTitle = self.get_text_value("艺-主标题")
  592. subTitle = self.get_text_value("艺-副标题")
  593. font_main = ImageFont.truetype(
  594. r"resources\ttf\puhui\Medium.ttf", 30
  595. ) # 设计理念
  596. pp_bg.get_text_image_advanced(
  597. value=(113, 545),
  598. font=font_main,
  599. text=mainTitle,
  600. align="left",
  601. # anchor="ma",
  602. spacing=5,
  603. fill=(60, 40, 29),
  604. return_mode="image",
  605. margins=(0, 0, 0, 0),
  606. )
  607. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
  608. pp_bg.get_text_image_advanced(
  609. value=(113, 602),
  610. font=font_sub,
  611. text=subTitle,
  612. align="left",
  613. # anchor="ma",
  614. spacing=5,
  615. fill=(60, 40, 29),
  616. return_mode="image",
  617. margins=(0, 0, 0, 0),
  618. )
  619. pp_bg.paste_img(top_img=pp_bg_1)
  620. detailed_images.append(pp_bg)
  621. return self.pp_pic_subsection(
  622. PictureProcessing(im=self.add_pic(detailed_images))
  623. )
  624. def deal_pic_18(self):
  625. image_path = r"{}\18.jpg".format(self.root)
  626. image_path_1 = r"{}\18_1.png".format(self.root)
  627. detailed_images = []
  628. pp_bg_1 = PictureProcessing(image_path_1)
  629. pp_bg = PictureProcessing(image_path)
  630. goods_art_no_list = list(self.data.keys())
  631. pp_jpg_1, pp_png_1 = self.image_one_pic(
  632. return_orign=True,
  633. goods_art_no=goods_art_no_list[0],
  634. name="侧视",
  635. )
  636. pp_jpg_1 = pp_jpg_1.resize(value=1400)
  637. pp_png_1 = pp_png_1.resize(value=1400)
  638. pp_bg = pp_bg.to_overlay_pic_advance(
  639. mode="pixel",
  640. top_img=pp_jpg_1,
  641. base="cs",
  642. value=(-pp_jpg_1.width/3, 0),
  643. top_png_img=pp_png_1,
  644. )
  645. mainTitle = self.get_text_value("跟-主标题")
  646. subTitle = self.get_text_value("跟-副标题")
  647. gengao = self.get_text_value("跟高")
  648. font_main = ImageFont.truetype(
  649. r"resources\ttf\puhui\Medium.ttf", 30
  650. ) # 设计理念
  651. pp_bg.get_text_image_advanced(
  652. value=(441, 220),
  653. font=font_main,
  654. text=mainTitle,
  655. align="right",
  656. # anchor="rs",
  657. spacing=5,
  658. fill=(60, 40, 29),
  659. return_mode="image",
  660. margins=(0, 0, 0, 0),
  661. )
  662. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
  663. pp_bg.get_text_image_advanced(
  664. value=(441, 272),
  665. font=font_sub,
  666. text=subTitle,
  667. align="right",
  668. # anchor="ls",
  669. spacing=5,
  670. fill=(60, 40, 29),
  671. return_mode="image",
  672. margins=(0, 0, 0, 0),
  673. )
  674. pp_bg.get_text_image_advanced(
  675. value=(605, 648),
  676. font=font_main,
  677. text=gengao,
  678. align="right",
  679. # anchor="ls",
  680. spacing=5,
  681. fill=(60, 40, 29),
  682. return_mode="image",
  683. margins=(0, 0, 0, 0),
  684. )
  685. pp_bg.paste_img(top_img=pp_bg_1)
  686. detailed_images.append(pp_bg)
  687. return self.pp_pic_subsection(
  688. PictureProcessing(im=self.add_pic(detailed_images))
  689. )
  690. def deal_pic_19(self):
  691. detailed_images = []
  692. image_path = r"{}\19.jpg".format(self.root)
  693. pp_bg = PictureProcessing(image_path)
  694. # 鞋底
  695. goods_art_no_list = list(self.data.keys())
  696. pp_jpg_1, pp_png_1 = self.image_one_pic(
  697. return_orign=True,
  698. goods_art_no=goods_art_no_list[0],
  699. name="鞋底",
  700. )
  701. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width)
  702. pp_png_1 = pp_png_1.resize(value=pp_bg.width)
  703. pp_bg = pp_bg.to_overlay_pic_advance(
  704. mode="pixel",
  705. top_img=pp_jpg_1,
  706. base="center",
  707. value=(0, 200),
  708. top_png_img=pp_png_1,
  709. )
  710. mainTitle = self.get_text_value("底-主标题")
  711. subTitle = self.get_text_value("底-副标题")
  712. font_main = ImageFont.truetype(
  713. r"resources\ttf\puhui\Medium.ttf", 30
  714. ) # 设计理念
  715. pp_bg.get_text_image_advanced(
  716. value=(114, 259),
  717. font=font_main,
  718. text=mainTitle,
  719. align="left",
  720. # anchor="rs",
  721. spacing=5,
  722. fill=(60, 40, 29),
  723. return_mode="image",
  724. margins=(0, 0, 0, 0),
  725. )
  726. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
  727. pp_bg.get_text_image_advanced(
  728. value=(114, 311),
  729. font=font_sub,
  730. text=subTitle,
  731. align="left",
  732. # anchor="ls",
  733. spacing=5,
  734. fill=(60, 40, 29),
  735. return_mode="image",
  736. margins=(0, 0, 0, 0),
  737. )
  738. # return PictureProcessing(image_path)
  739. detailed_images.append(pp_bg)
  740. return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
  741. def deal_pic_20(self):
  742. detailed_images = []
  743. bg_20 = PictureProcessing(r"{}\20.jpg".format(self.root))
  744. bg_21 = PictureProcessing(r"{}\21.jpg".format(self.root))
  745. bg_22 = PictureProcessing(r"{}\22.jpg".format(self.root))
  746. detailed_images.append(bg_20)
  747. detailed_images.append(bg_21)
  748. detailed_images.append(bg_22)
  749. return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
  750. if __name__ == "__main__":
  751. d = DetailPicGet(
  752. goods_no="test",
  753. goods_no_value={},
  754. out_put_dir="./output/xinnuo-1",
  755. test=True,
  756. )
  757. d.run_test()