detail_xinnuo1.py 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962
  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 = ["俯视", "侧视", "后跟", "鞋底", "内里"]
  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_17,
  67. self.deal_pic_18,
  68. self.deal_pic_19,
  69. self.deal_pic_20,
  70. self.deal_pic_21,
  71. ]
  72. if test:
  73. # pp = self.generate_font_list_to_pic()
  74. # pp.im.save(r"C:\Users\gymmc\Desktop\细节图示例/字号.png")
  75. # for k, v in self.goods_no_value.items():
  76. # print(k, v)
  77. self.run_test()
  78. else:
  79. self.run_all()
  80. def run_test(self):
  81. detailed_images = []
  82. detailed_images.append(self.deal_pic_1())
  83. detailed_images.append(self.deal_pic_2())
  84. detailed_images.append(self.deal_pic_3())
  85. detailed_images.append(self.deal_pic_4())
  86. detailed_images.append(self.deal_pic_5())
  87. detailed_images.append(self.deal_pic_6())
  88. detailed_images.append(self.deal_pic_7())
  89. detailed_images.append(self.deal_pic_8())
  90. detailed_images.append(self.deal_pic_9())
  91. detailed_images.append(self.deal_pic_10())
  92. detailed_images.append(self.deal_pic_11())
  93. detailed_images.append(self.deal_pic_13())
  94. detailed_images.append(self.deal_pic_17())
  95. detailed_images.append(self.deal_pic_18())
  96. detailed_images.append(self.deal_pic_19())
  97. detailed_images.append(self.deal_pic_20())
  98. detailed_images.append(self.deal_pic_21())
  99. img = self.add_pic(detailed_images)
  100. img.save(r"{}/{}.jpg".format(self.out_put_dir, self.goods_no, format="JPEG"))
  101. img.show()
  102. # 标题文字展示
  103. def deal_pic_1(self):
  104. pp_bg = PictureProcessing(r"{}\1.jpg".format(self.root),1600)
  105. font_main = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 102) # 设计理念
  106. mainTitle = self.get_text_value("主标题")
  107. subTitle = self.get_text_value("副标题")
  108. pp_bg.get_text_image_advanced(
  109. value=(336, 95),
  110. font=font_main,
  111. text=mainTitle,
  112. align="left",
  113. # anchor="ma",
  114. spacing=5,
  115. fill=(60, 40, 29),
  116. return_mode="image",
  117. margins=(0, 0, 0, 0),
  118. )
  119. font_sub = ImageFont.truetype(
  120. r"resources\ttf\puhui\Bold.ttf", 40
  121. ) # 设计理念
  122. pp_bg.get_text_image_advanced(
  123. value=(82, 95),
  124. font=font_sub,
  125. text=subTitle,
  126. align="left",
  127. # anchor="ma",
  128. spacing=5,
  129. fill=(60, 40, 29),
  130. return_mode="image",
  131. margins=(0, 0, 0, 0),
  132. )
  133. goods_art_no_list = list(self.data.keys())
  134. pp_jpg_1, pp_png_1 = self.image_one_pic(
  135. return_orign=True,
  136. goods_art_no=goods_art_no_list[0],
  137. name="俯视",
  138. )
  139. if self.check_shoe_is_right_by_pixel(im=pp_png_1.im):
  140. pp_jpg_1 = pp_jpg_1.transpose()
  141. pp_png_1 = pp_png_1.transpose()
  142. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width/1.1)
  143. pp_png_1 = pp_png_1.resize(value=pp_bg.width / 1.1)
  144. pp_bg = pp_bg.to_overlay_pic_advance(
  145. top_img=pp_jpg_1, top_png_img=pp_png_1, base="cs", value=(-50, 190)
  146. )
  147. pp_bg = pp_bg.to_overlay_pic_advance(
  148. top_img=pp_jpg_1, top_png_img=pp_png_1, base="cs", value=(50, 130)
  149. )
  150. return pp_bg
  151. # 展示鞋头和后跟
  152. def deal_pic_2(self):
  153. pp_bg = PictureProcessing(r"{}\2.jpg".format(self.root), 1600)
  154. font = ImageFont.truetype(
  155. r"resources\ttf\puhui\Regular.ttf", 24
  156. ) # 设计理念
  157. design_text = self.get_text_value("设计理念")
  158. text_bg = PictureProcessing("RGBA", (pp_bg.width, 200), (255,255,255,0))
  159. text_bg = text_bg.get_text_image_advanced(
  160. value=(0, 0),
  161. font=font,
  162. text=design_text,
  163. align="center",
  164. spacing=20,
  165. fill=(88, 52, 28),
  166. return_mode="min_image",
  167. )
  168. pp_bg = pp_bg.paste_img(top_img=text_bg, base="nc", value=(0, 359))
  169. goods_art_no_list = list(self.data.keys())
  170. pp_jpg_1, pp_png_1 = self.image_one_pic(
  171. return_orign=True,
  172. goods_art_no=goods_art_no_list[0],
  173. name="组合",
  174. )
  175. if pp_jpg_1 == None:
  176. pp_jpg_1, pp_png_1 = self.image_one_pic(
  177. return_orign=True,
  178. goods_art_no=goods_art_no_list[0],
  179. name="俯视",
  180. )
  181. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width)
  182. pp_png_1 = pp_png_1.resize(value=pp_bg.width)
  183. pp_bg = pp_bg.to_overlay_pic_advance(
  184. top_img=pp_jpg_1, top_png_img=pp_png_1, base="cs", value=(0, 315)
  185. )
  186. return pp_bg
  187. # 展示鞋头放大图
  188. def deal_pic_3(self):
  189. pp_bg = PictureProcessing(r"{}\3.jpg".format(self.root),1600)
  190. goods_art_no_list = list(self.data.keys())
  191. pp_jpg_1, pp_png_1 = self.image_one_pic(
  192. return_orign=True,
  193. goods_art_no=goods_art_no_list[0],
  194. name="内里",
  195. )
  196. pp_jpg_1 = pp_jpg_1.resize(value=1600)
  197. pp_png_1 = pp_png_1.resize(value=1600)
  198. # pp_bg = pp_bg.paste_img(top_img=shoe_bg, value=(0, 0), base="nw")
  199. pp_bg = pp_bg.to_overlay_pic_advance(
  200. mode="pixel",
  201. top_img=pp_jpg_1,
  202. base="sw",
  203. value=(-pp_bg.width - 100, 280),
  204. top_png_img=pp_png_1,
  205. )
  206. return pp_bg
  207. # 展示后跟放大图
  208. def deal_pic_4(self):
  209. pp_bg = PictureProcessing(r"{}\4.jpg".format(self.root))
  210. return pp_bg
  211. # 展示后跟细节卡片
  212. def deal_pic_5(self):
  213. pp_bg = PictureProcessing(r"{}\5.jpg".format(self.root))
  214. return pp_bg
  215. # "心动"设计亮点,展示旋转的侧视图
  216. def deal_pic_6(self):
  217. pp_bg = PictureProcessing(r"{}\6.jpg".format(self.root))
  218. goods_art_no_list = list(self.data.keys())
  219. goods_art = goods_art_no_list[0]
  220. pp_jpg_1, pp_png_1 = self.image_one_pic(
  221. return_orign=True,
  222. goods_art_no=goods_art,
  223. name="组合2",
  224. )
  225. if pp_jpg_1 == None:
  226. pp_jpg_1, pp_png_1 = self.image_one_pic(
  227. return_orign=True,
  228. goods_art_no=goods_art,
  229. name="俯视",
  230. )
  231. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width/1.4)
  232. pp_png_1 = pp_png_1.resize(value=pp_bg.width / 1.4)
  233. # pp_bg = pp_bg.paste_img(top_img=shoe_bg, value=(0, 0), base="nw")
  234. pp_bg = pp_bg.to_overlay_pic_advance(
  235. mode="pixel",
  236. top_img=pp_jpg_1,
  237. base="center",
  238. value=(0, 0),
  239. top_png_img=pp_png_1,
  240. )
  241. return pp_bg
  242. # 产品展示,帮面等等
  243. def deal_pic_7(self):
  244. pp_bg = PictureProcessing(r"{}\7.jpg".format(self.root))
  245. goods_art_no_list = list(self.data.keys())
  246. pp_jpg_1, pp_png_1 = self.image_one_pic(
  247. return_orign=True,
  248. goods_art_no=goods_art_no_list[0],
  249. name="俯视",
  250. )
  251. pp_jpg_1 = pp_jpg_1.resize(value=500)
  252. pp_png_1 = pp_png_1.resize(value=500)
  253. # pp_bg = pp_bg.paste_img(top_img=shoe_bg, value=(0, 0), base="nw")
  254. pp_bg = pp_bg.to_overlay_pic_advance(
  255. mode="pixel",
  256. top_img=pp_jpg_1,
  257. base="sw",
  258. value=(123, 237),
  259. top_png_img=pp_png_1,
  260. )
  261. font = ImageFont.truetype(
  262. r"resources\ttf\puhui\Medium.ttf", 24
  263. ) # 设计理念
  264. font_hei = ImageFont.truetype(r"resources\ttf\simhei.ttf", 24) # 设计理念
  265. bangmian = self.get_text_value("帮面")
  266. neili = self.get_text_value("内里")
  267. xiedi = self.get_text_value("鞋底")
  268. xiedian = self.get_text_value("鞋垫")
  269. xiekuan = self.get_text_value("鞋宽")
  270. banggao = self.get_text_value("帮高")
  271. gengao = self.get_text_value("跟高")
  272. pp_bg.get_text_image_advanced(
  273. value=(230, 351),
  274. font=font,
  275. text=bangmian,
  276. align="left",
  277. # anchor="ma",
  278. spacing=5,
  279. fill=(60, 40, 29),
  280. return_mode="image",
  281. margins=(0, 0, 0, 0),
  282. )
  283. pp_bg.get_text_image_advanced(
  284. value=(551, 351),
  285. font=font,
  286. text=neili,
  287. align="left",
  288. # anchor="ma",
  289. spacing=5,
  290. fill=(60, 40, 29),
  291. return_mode="image",
  292. margins=(0, 0, 0, 0),
  293. )
  294. pp_bg.get_text_image_advanced(
  295. value=(230, 461),
  296. font=font,
  297. text=xiedi,
  298. align="left",
  299. # anchor="ma",
  300. spacing=5,
  301. fill=(60, 40, 29),
  302. return_mode="image",
  303. margins=(0, 0, 0, 0),
  304. )
  305. pp_bg.get_text_image_advanced(
  306. value=(551, 461),
  307. font=font,
  308. text=xiedian,
  309. align="left",
  310. # anchor="ma",
  311. spacing=5,
  312. fill=(60, 40, 29),
  313. return_mode="image",
  314. margins=(0, 0, 0, 0),
  315. )
  316. pp_bg.get_text_image_advanced(
  317. value=(64, 901),
  318. font=font_hei,
  319. text=f"鞋宽\n{xiekuan}",
  320. align="left",
  321. # anchor="ma",
  322. spacing=5,
  323. fill=(60, 40, 29),
  324. return_mode="image",
  325. margins=(0, 0, 0, 0),
  326. )
  327. pp_bg.get_text_image_advanced(
  328. value=(621, 650),
  329. font=font_hei,
  330. text=f"帮高\n{banggao}",
  331. align="left",
  332. # anchor="ma",
  333. spacing=5,
  334. fill=(60, 40, 29),
  335. return_mode="image",
  336. margins=(0, 0, 0, 0),
  337. )
  338. pp_bg.get_text_image_advanced(
  339. value=(621, 752),
  340. font=font_hei,
  341. text=f"跟高\n{gengao}",
  342. align="left",
  343. # anchor="ma",
  344. spacing=5,
  345. fill=(60, 40, 29),
  346. return_mode="image",
  347. margins=(0, 0, 0, 0),
  348. )
  349. return pp_bg
  350. # 功能展示与卖点
  351. def deal_pic_8(self):
  352. detailed_images = []
  353. pp_bg = PictureProcessing(r"{}\7.jpg".format(self.root))
  354. pp_bg_circle = PictureProcessing(r"{}\bg_circle.png".format(self.root))
  355. # detailed_images.append(pp_bg)
  356. goods_art_no_list = list(self.data.keys())
  357. all_color_name = []
  358. bg_color = (254, 249, 245)
  359. text_color = (70, 48, 41)
  360. font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 25)
  361. goods_art_images = []
  362. total_height = 0
  363. for index, goods_art_no in enumerate(goods_art_no_list):
  364. pp_jpg,pp_png = self.image_one_pic(
  365. goods_art_no=goods_art_no,
  366. name="侧视",
  367. return_orign=True,
  368. )
  369. if pp_jpg is None:
  370. continue
  371. pp_jpg = pp_jpg.resize(value=pp_bg.width / 2.5)
  372. pp_png = pp_png.resize(value=pp_bg.width / 2.5)
  373. color_name = self.goods_no_value["货号资料"][index]["颜色名称"]
  374. all_color_name.append(color_name)
  375. text_bg = PictureProcessing("RGBA", (pp_jpg.width, 50), (255,255,255,0))
  376. text_bg = text_bg.get_text_image_advanced(
  377. value=(0, 0),
  378. font=font,
  379. text="● {}".format(color_name),
  380. align="center",
  381. # anchor="mm",
  382. spacing=5,
  383. fill=text_color,
  384. return_mode="image",
  385. margins=(0, 0, 0, 0),
  386. )
  387. _bg = PictureProcessing(
  388. "RGB",
  389. (pp_bg.width / 2, pp_jpg.height+200),
  390. bg_color,
  391. )
  392. pp_bg_circle = pp_bg_circle.resize(value=_bg.width/2)
  393. _bg.paste_img(top_img=pp_bg_circle, base="center")
  394. if (index+1) == 1:
  395. total_height += _bg.height
  396. if (index + 1) % 2 != 0 and (index + 1) != 1:
  397. total_height += _bg.height
  398. _bg = _bg.to_overlay_pic_advance(top_img=pp_jpg,top_png_img=pp_png, base="center")
  399. _bg = _bg.paste_img(
  400. top_img=text_bg, value=(pp_jpg.width / 2, pp_jpg.height+100)
  401. )
  402. goods_art_images.append(_bg)
  403. rows = 2
  404. shoes_bg = PictureProcessing(
  405. ).horizontal_distribution(
  406. pp_list=goods_art_images,
  407. bg_width=pp_bg.width,
  408. margins=(0, 0, 0, 0),
  409. line_spacing=0,
  410. number_per_row=rows,
  411. )
  412. main_bg = PictureProcessing(
  413. "RGB",
  414. (pp_bg.width, total_height),
  415. bg_color,
  416. )
  417. main_bg.paste_img(top_img=shoes_bg)
  418. detailed_images.append(main_bg)
  419. return PictureProcessing(im=self.add_pic(detailed_images))
  420. # 添加尺码表
  421. def deal_pic_9(self):
  422. image_path = r"{}\9.jpg".format(self.root)
  423. return PictureProcessing(image_path)
  424. # 角度展示
  425. def deal_pic_10(self):
  426. detailed_images = []
  427. image_path = r"{}\10.jpg".format(self.root)
  428. pp_bg = PictureProcessing(image_path,1600)
  429. pp_arrow = PictureProcessing(r"{}\arrow.png".format(self.root))
  430. goods_art_no_list = list(self.data.keys())
  431. pp_jpg_1, pp_png_1 = self.image_one_pic(
  432. return_orign=True,
  433. goods_art_no=goods_art_no_list[0],
  434. name="俯视",
  435. )
  436. pp_jpg_1 = pp_jpg_1.resize(value=1400)
  437. pp_png_1 = pp_png_1.resize(value=1400)
  438. bg_circl = PictureProcessing("RGB", (300, 300), (239, 208, 177))
  439. bg_circl_paste = PictureProcessing("RGB", (290, 290), (239, 208, 177))
  440. bg_circl_paste.paste_img(top_img=pp_jpg_1, base="center")
  441. bg_circl_paste = bg_circl_paste.radius(value=145, circular_pos=(1, 1, 1, 1))
  442. bg_circl = bg_circl.radius(value=150, circular_pos=(1, 1, 1, 1))
  443. bg_circl = bg_circl.paste_img(top_img=bg_circl_paste, base="center")
  444. bg_circl = bg_circl.paste_img(top_img=pp_arrow, base="nc")
  445. pp_bg = pp_bg.paste_img(top_img=bg_circl, base="nw", value=(63, 493))
  446. pp_bg = pp_bg.to_overlay_pic_advance(
  447. mode="pixel",
  448. top_img=pp_jpg_1,
  449. base="nw",
  450. value=(0, pp_bg.height - pp_jpg_1.height),
  451. top_png_img=pp_png_1,
  452. )
  453. font_main = ImageFont.truetype(
  454. r"resources\ttf\puhui\Medium.ttf", 58
  455. ) # 设计理念
  456. mainTitle = self.get_text_value("细节亮点主标题")
  457. subTitle = self.get_text_value("细节亮点副标题")
  458. pp_bg.get_text_image_advanced(
  459. value=(pp_bg.width / 2, 219),
  460. font=font_main,
  461. text=mainTitle,
  462. align="center",
  463. anchor="ma",
  464. spacing=5,
  465. fill=(60, 40, 29),
  466. return_mode="image",
  467. margins=(0, 0, 0, 0),
  468. )
  469. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 36) # 设计理念
  470. pp_bg.get_text_image_advanced(
  471. value=(pp_bg.width / 2, 313),
  472. font=font_sub,
  473. text=subTitle,
  474. align="center",
  475. anchor="ma",
  476. spacing=5,
  477. fill=(60, 40, 29),
  478. return_mode="image",
  479. margins=(0, 0, 0, 0),
  480. )
  481. detailed_images.append(pp_bg)
  482. return self.pp_pic_subsection(
  483. PictureProcessing(im=self.add_pic(detailed_images))
  484. )
  485. # 添加注意事项
  486. def deal_pic_11(self):
  487. """
  488. bg_12_image_path = r"{}\12.jpg".format(self.root)
  489. bg_12 = PictureProcessing(bg_12_image_path)
  490. detailed_images.append(bg_12)
  491. """
  492. detailed_images = []
  493. image_path = r"{}\11.png".format(self.root)
  494. pp_bg = PictureProcessing(image_path, 1600)
  495. pp_bg_backend = PictureProcessing(
  496. "RGB", (pp_bg.width, pp_bg.height), (245, 235, 226)
  497. )
  498. goods_art_no_list = list(self.data.keys())
  499. pp_jpg_1, pp_png_1 = self.image_one_pic(
  500. return_orign=True,
  501. goods_art_no=goods_art_no_list[0],
  502. name="俯视",
  503. )
  504. pp_jpg_1 = pp_jpg_1.resize(value=2000)
  505. pp_png_1 = pp_png_1.resize(value=2000)
  506. pp_bg_backend = pp_bg_backend.to_overlay_pic_advance(
  507. mode="pixel",
  508. top_img=pp_jpg_1,
  509. base="cs",
  510. value=(0, -50),
  511. top_png_img=pp_png_1,
  512. )
  513. font_main = ImageFont.truetype(
  514. r"resources\ttf\puhui\Medium.ttf", 58
  515. ) # 设计理念
  516. pp_bg_backend.get_text_image_advanced(
  517. value=(pp_bg.width / 2, 219),
  518. font=font_main,
  519. text="经 典 系 带",
  520. align="center",
  521. anchor="ma",
  522. spacing=5,
  523. fill=(107, 70, 61),
  524. return_mode="image",
  525. margins=(0, 0, 0, 0),
  526. )
  527. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 36) # 设计理念
  528. pp_bg_backend.get_text_image_advanced(
  529. value=(pp_bg.width / 2, 313),
  530. font=font_sub,
  531. text="松 紧 自 由 调 节",
  532. align="center",
  533. anchor="ma",
  534. spacing=5,
  535. fill=(107, 70, 61),
  536. return_mode="image",
  537. margins=(0, 0, 0, 0),
  538. )
  539. pp_bg_backend.paste_img(top_img=pp_bg,base="center")
  540. detailed_images.append(pp_bg_backend)
  541. # bg_12_image_path = r"{}\12.jpg".format(self.root)
  542. # bg_12 = PictureProcessing(bg_12_image_path)
  543. # detailed_images.append(bg_12)
  544. return self.pp_pic_subsection(
  545. PictureProcessing(im=self.add_pic(detailed_images))
  546. )
  547. def deal_pic_13(self):
  548. detailed_images = []
  549. image_path = r"{}\12.jpg".format(self.root)
  550. pp_bg = PictureProcessing(image_path,1600)
  551. detailed_images.append(pp_bg)
  552. radius_top = PictureProcessing(
  553. "RGB", (pp_bg.width * 0.75, 40), (255, 255, 255)
  554. ).radius(value=30, circular_pos=(1, 1, 0, 0))
  555. radius_top_bg = PictureProcessing("RGB", (pp_bg.width, 40), (253, 246, 237))
  556. image_list = ["俯视","侧视","后跟"]
  557. for item in image_list:
  558. pp_bg_background = PictureProcessing(
  559. "RGB", (pp_bg.width, 800), (253, 246, 237)
  560. )
  561. pp_bg_radius = PictureProcessing(
  562. "RGB", (pp_bg.width * 0.85, 800), (255, 255, 255)
  563. )
  564. radius_top_bg = radius_top_bg.paste_img(top_img=radius_top, base="cc")
  565. detailed_images.append(radius_top_bg)
  566. goods_art_no_list = list(self.data.keys())
  567. pp_jpg_1, pp_png_1 = self.image_one_pic(
  568. return_orign=True,
  569. goods_art_no=goods_art_no_list[0],
  570. name=item,
  571. )
  572. if item =="俯视":
  573. if self.check_shoe_is_right_by_pixel(im=pp_png_1.im):
  574. pp_jpg_1 = pp_jpg_1.transpose()
  575. pp_png_1 = pp_png_1.transpose()
  576. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_radius.width / 1.3)
  577. pp_png_1 = pp_png_1.resize(value=pp_bg_radius.width / 1.3)
  578. pp_bg_radius = pp_bg_radius.to_overlay_pic_advance(
  579. top_img=pp_jpg_1, top_png_img=pp_png_1, base="cc", value=(-50, 0)
  580. )
  581. pp_bg_radius = pp_bg_radius.to_overlay_pic_advance(
  582. top_img=pp_jpg_1, top_png_img=pp_png_1, base="cc", value=(50, 60)
  583. )
  584. if item == "侧视":
  585. if self.check_shoe_is_right_by_pixel(im=pp_png_1.im):
  586. pp_jpg_1 = pp_jpg_1.transpose()
  587. pp_png_1 = pp_png_1.transpose()
  588. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_radius.width / 1.3)
  589. pp_png_1 = pp_png_1.resize(value=pp_bg_radius.width / 1.3)
  590. pp_bg_radius = pp_bg_radius.to_overlay_pic_advance(
  591. top_img=pp_jpg_1, top_png_img=pp_png_1, base="cc", value=(60, 0)
  592. )
  593. pp_bg_radius = pp_bg_radius.to_overlay_pic_advance(
  594. top_img=pp_jpg_1, top_png_img=pp_png_1, base="cc", value=(-60, 0)
  595. )
  596. if item == "后跟":
  597. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg_radius.width / 2.3)
  598. pp_png_1 = pp_png_1.resize(value=pp_bg_radius.width / 2.3)
  599. pp_jpg_1 = pp_jpg_1.transpose()
  600. pp_png_1 = pp_png_1.transpose()
  601. pp_bg_radius = pp_bg_radius.to_overlay_pic_advance(
  602. top_img=pp_jpg_1, top_png_img=pp_png_1, base="cc", value=(130, 0)
  603. )
  604. pp_jpg_1 = pp_jpg_1.transpose()
  605. pp_png_1 = pp_png_1.transpose()
  606. pp_bg_radius = pp_bg_radius.to_overlay_pic_advance(
  607. top_img=pp_jpg_1, top_png_img=pp_png_1, base="cc", value=(-130, 0)
  608. )
  609. pp_bg_radius = pp_bg_radius.radius(value=30, circular_pos=(1, 1, 1, 1))
  610. pp_bg_background.paste_img(top_img=pp_bg_radius, base="cc", value=(0, 0))
  611. detailed_images.append(pp_bg_background)
  612. radius_bottom = PictureProcessing(
  613. "RGB", (pp_bg.width * 0.75, 40), (255, 255, 255)
  614. ).radius(value=30, circular_pos=(0, 0, 1, 1))
  615. radius_bottom_bg = PictureProcessing("RGB", (pp_bg.width, 40), (253, 246, 237))
  616. radius_bottom_bg = radius_bottom_bg.paste_img(top_img=radius_bottom, base="cc")
  617. detailed_images.append(radius_bottom_bg)
  618. detailed_images.append(
  619. PictureProcessing("RGB", (pp_bg.width, 50), (253, 246, 237))
  620. )
  621. return self.pp_pic_subsection(
  622. PictureProcessing(im=self.add_pic(detailed_images))
  623. )
  624. def deal_pic_17(self):
  625. # 产品细节
  626. image_path = r"{}\17.jpg".format(self.root)
  627. image_path_1 = r"{}\17_1.png".format(self.root)
  628. detailed_images = []
  629. pp_bg_1 = PictureProcessing(image_path_1)
  630. pp_bg = PictureProcessing(image_path)
  631. goods_art_no_list = list(self.data.keys())
  632. pp_jpg_1, pp_png_1 = self.image_one_pic(
  633. return_orign=True,
  634. goods_art_no=goods_art_no_list[0],
  635. name="俯视",
  636. )
  637. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width+100)
  638. pp_png_1 = pp_png_1.resize(value=pp_bg.width + 100)
  639. pp_bg = pp_bg.to_overlay_pic_advance(
  640. mode="pixel",
  641. top_img=pp_jpg_1,
  642. base="cs",
  643. value=(0, 0),
  644. top_png_img=pp_png_1,
  645. )
  646. mainTitle = self.get_text_value("艺-主标题")
  647. subTitle = 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=(113, 545),
  653. font=font_main,
  654. text=mainTitle,
  655. align="left",
  656. # anchor="ma",
  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=(113, 602),
  665. font=font_sub,
  666. text=subTitle,
  667. align="left",
  668. # anchor="ma",
  669. spacing=5,
  670. fill=(60, 40, 29),
  671. return_mode="image",
  672. margins=(0, 0, 0, 0),
  673. )
  674. pp_bg.paste_img(top_img=pp_bg_1)
  675. detailed_images.append(pp_bg)
  676. return self.pp_pic_subsection(
  677. PictureProcessing(im=self.add_pic(detailed_images))
  678. )
  679. def deal_pic_18(self):
  680. image_path = r"{}\18.jpg".format(self.root)
  681. image_path_1 = r"{}\18_1.png".format(self.root)
  682. detailed_images = []
  683. pp_bg_1 = PictureProcessing(image_path_1)
  684. pp_bg = PictureProcessing(image_path)
  685. goods_art_no_list = list(self.data.keys())
  686. pp_jpg_1, pp_png_1 = self.image_one_pic(
  687. return_orign=True,
  688. goods_art_no=goods_art_no_list[0],
  689. name="侧视",
  690. )
  691. pp_jpg_1 = pp_jpg_1.resize(value=1400)
  692. pp_png_1 = pp_png_1.resize(value=1400)
  693. pp_bg = pp_bg.to_overlay_pic_advance(
  694. mode="pixel",
  695. top_img=pp_jpg_1,
  696. base="cs",
  697. value=(-pp_jpg_1.width/3, 0),
  698. top_png_img=pp_png_1,
  699. )
  700. mainTitle = self.get_text_value("跟-主标题")
  701. subTitle = self.get_text_value("跟-副标题")
  702. gengao = self.get_text_value("跟高")
  703. font_main = ImageFont.truetype(
  704. r"resources\ttf\puhui\Medium.ttf", 30
  705. ) # 设计理念
  706. pp_bg.get_text_image_advanced(
  707. value=(441, 220),
  708. font=font_main,
  709. text=mainTitle,
  710. align="right",
  711. # anchor="rs",
  712. spacing=5,
  713. fill=(60, 40, 29),
  714. return_mode="image",
  715. margins=(0, 0, 0, 0),
  716. )
  717. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
  718. pp_bg.get_text_image_advanced(
  719. value=(441, 272),
  720. font=font_sub,
  721. text=subTitle,
  722. align="right",
  723. # anchor="ls",
  724. spacing=5,
  725. fill=(60, 40, 29),
  726. return_mode="image",
  727. margins=(0, 0, 0, 0),
  728. )
  729. pp_bg.get_text_image_advanced(
  730. value=(605, 648),
  731. font=font_main,
  732. text=gengao,
  733. align="right",
  734. # anchor="ls",
  735. spacing=5,
  736. fill=(60, 40, 29),
  737. return_mode="image",
  738. margins=(0, 0, 0, 0),
  739. )
  740. pp_bg.paste_img(top_img=pp_bg_1)
  741. detailed_images.append(pp_bg)
  742. return self.pp_pic_subsection(
  743. PictureProcessing(im=self.add_pic(detailed_images))
  744. )
  745. def deal_pic_19(self):
  746. detailed_images = []
  747. image_path = r"{}\19.jpg".format(self.root)
  748. pp_bg = PictureProcessing(image_path)
  749. # 鞋底
  750. goods_art_no_list = list(self.data.keys())
  751. pp_jpg_1, pp_png_1 = self.image_one_pic(
  752. return_orign=True,
  753. goods_art_no=goods_art_no_list[0],
  754. name="鞋底",
  755. )
  756. pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width)
  757. pp_png_1 = pp_png_1.resize(value=pp_bg.width)
  758. pp_bg = pp_bg.to_overlay_pic_advance(
  759. mode="pixel",
  760. top_img=pp_jpg_1,
  761. base="center",
  762. value=(0, 200),
  763. top_png_img=pp_png_1,
  764. )
  765. mainTitle = self.get_text_value("底-主标题")
  766. subTitle = self.get_text_value("底-副标题")
  767. font_main = ImageFont.truetype(
  768. r"resources\ttf\puhui\Medium.ttf", 30
  769. ) # 设计理念
  770. pp_bg.get_text_image_advanced(
  771. value=(114, 259),
  772. font=font_main,
  773. text=mainTitle,
  774. align="left",
  775. # anchor="rs",
  776. spacing=5,
  777. fill=(60, 40, 29),
  778. return_mode="image",
  779. margins=(0, 0, 0, 0),
  780. )
  781. font_sub = ImageFont.truetype(r"resources\ttf\puhui\Light.ttf", 24) # 设计理念
  782. pp_bg.get_text_image_advanced(
  783. value=(114, 311),
  784. font=font_sub,
  785. text=subTitle,
  786. align="left",
  787. # anchor="ls",
  788. spacing=5,
  789. fill=(60, 40, 29),
  790. return_mode="image",
  791. margins=(0, 0, 0, 0),
  792. )
  793. # return PictureProcessing(image_path)
  794. detailed_images.append(pp_bg)
  795. return self.pp_pic_subsection(PictureProcessing(im=self.add_pic(detailed_images)))
  796. def deal_pic_20(self):
  797. detailed_images = []
  798. font = ImageFont.truetype(r"resources\ttf\puhui\Medium.ttf", 30) # 设计理念
  799. pp_bg = PictureProcessing(r"{}\20.jpg".format(self.root))
  800. detailed_images.append(pp_bg)
  801. goods_art_no_list = list(self.data.keys())
  802. for item in goods_art_no_list:
  803. radius_top_bg = PictureProcessing(
  804. "RGB", (pp_bg.width, 1048), (253, 246, 237)
  805. )
  806. bg_radius = PictureProcessing(
  807. "RGB",
  808. (pp_bg.width * 0.85, radius_top_bg.height * 0.85),
  809. (255, 255, 255),
  810. )
  811. pp_jpg_1, pp_png_1 = self.image_one_pic(
  812. return_orign=True,
  813. goods_art_no=item,
  814. name="俯视",
  815. )
  816. pp_jpg_1 = pp_jpg_1.resize(value=bg_radius.width/1.3)
  817. pp_png_1 = pp_png_1.resize(value=bg_radius.width /1.3)
  818. bg_radius = bg_radius.to_overlay_pic_advance(
  819. top_img=pp_jpg_1, top_png_img=pp_png_1, base="nc",value=(0,150)
  820. )
  821. bg_radius = bg_radius.radius(value=30)
  822. text_bg = PictureProcessing(
  823. "RGBA", (pp_jpg_1.width, 50), (255, 255, 255, 0)
  824. )
  825. text_bg = text_bg.get_text_image_advanced(
  826. value=(0, 0),
  827. font=font,
  828. text="斜面展示",
  829. align="center",
  830. # anchor="mm",
  831. spacing=5,
  832. fill=(70, 45, 36),
  833. return_mode="min_image",
  834. margins=(0, 0, 0, 0),
  835. )
  836. _bg = PictureProcessing(
  837. "RGBA",
  838. (pp_bg.width / 2, pp_png_1.height + 200),
  839. (255, 255, 255,0),
  840. )
  841. _bg.paste_img(top_img=text_bg, base="center")
  842. bg_radius.paste_img(top_img=_bg, base="center")
  843. radius_top_bg = radius_top_bg.paste_img(top_img=bg_radius, base="center")
  844. pp_jpg_1, pp_png_1 = self.image_one_pic(
  845. return_orign=True,
  846. goods_art_no=item,
  847. name="内里",
  848. )
  849. pp_jpg_1 = pp_jpg_1.resize(value=bg_radius.width / 2)
  850. pp_png_1 = pp_png_1.resize(value=bg_radius.width / 2)
  851. bg_radius = bg_radius.to_overlay_pic_advance(
  852. top_img=pp_jpg_1, top_png_img=pp_png_1, base="sw", value=(0, 150)
  853. )
  854. bg_radius = bg_radius.radius(value=30)
  855. text_bg = PictureProcessing(
  856. "RGBA", (pp_jpg_1.width, 50), (255, 255, 255, 0)
  857. )
  858. text_bg = text_bg.get_text_image_advanced(
  859. value=(0, 0),
  860. font=font,
  861. text="鞋面展示",
  862. align="center",
  863. # anchor="mm",
  864. spacing=5,
  865. fill=(70, 45, 36),
  866. return_mode="min_image",
  867. margins=(0, 0, 0, 0),
  868. )
  869. _bg = PictureProcessing(
  870. "RGBA",
  871. (pp_bg.width / 2, pp_png_1.height + 150),
  872. (255, 255, 255, 0),
  873. )
  874. _bg.paste_img(top_img=text_bg, base="center")
  875. bg_radius.paste_img(top_img=_bg, base="sw",value=(-50,-20))
  876. radius_top_bg = radius_top_bg.paste_img(top_img=bg_radius, base="center")
  877. pp_jpg_1, pp_png_1 = self.image_one_pic(
  878. return_orign=True,
  879. goods_art_no=item,
  880. name="鞋底",
  881. )
  882. pp_jpg_1 = pp_jpg_1.resize(value=bg_radius.width / 2)
  883. pp_png_1 = pp_png_1.resize(value=bg_radius.width / 2)
  884. bg_radius = bg_radius.to_overlay_pic_advance(
  885. top_img=pp_jpg_1, top_png_img=pp_png_1, base="es", value=(0, 150)
  886. )
  887. bg_radius = bg_radius.radius(value=30)
  888. text_bg = PictureProcessing(
  889. "RGBA", (pp_jpg_1.width, 50), (255, 255, 255, 0)
  890. )
  891. text_bg = text_bg.get_text_image_advanced(
  892. value=(0, 0),
  893. font=font,
  894. text="鞋面展示",
  895. align="center",
  896. # anchor="mm",
  897. spacing=5,
  898. fill=(70, 45, 36),
  899. return_mode="min_image",
  900. margins=(0, 0, 0, 0),
  901. )
  902. _bg = PictureProcessing(
  903. "RGBA",
  904. (pp_bg.width / 2, pp_png_1.height + 150),
  905. (255, 255, 255, 0),
  906. )
  907. _bg.paste_img(top_img=text_bg, base="center")
  908. bg_radius.paste_img(top_img=_bg, base="es", value=(-50, -20))
  909. radius_top_bg = radius_top_bg.paste_img(top_img=bg_radius, base="center")
  910. detailed_images.append(radius_top_bg)
  911. return self.pp_pic_subsection(
  912. PictureProcessing(im=self.add_pic(detailed_images))
  913. )
  914. def deal_pic_21(self):
  915. detailed_images = []
  916. bg_21 = PictureProcessing(r"{}\21.jpg".format(self.root))
  917. detailed_images.append(bg_21)
  918. return self.pp_pic_subsection(
  919. PictureProcessing(im=self.add_pic(detailed_images))
  920. )
  921. if __name__ == "__main__":
  922. d = DetailPicGet(
  923. goods_no="test",
  924. goods_no_value={},
  925. out_put_dir="./output/xinnuo-1",
  926. test=True,
  927. )
  928. d.run_test()