detail_generate_base.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. import json
  2. import os
  3. from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
  4. from PIL import Image
  5. import shutil
  6. from module.base_mode.base import get_images, check_path, get_image_mask
  7. from natsort import ns, natsorted
  8. import math
  9. from PIL import ImageFont
  10. import settings
  11. class DetailBase(object):
  12. def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, excel_data=None,
  13. assigned_page_list=None):
  14. self.goods_no = goods_no
  15. self.out_put_dir = out_put_dir
  16. self.deal_pic_func_list = []
  17. self.goods_no_value = goods_no_value
  18. self.root = ""
  19. self.windows = windows
  20. print(goods_no_value)
  21. # 重新解析为新的数据结构
  22. self.data = {}
  23. self.detailed_images = []
  24. self.assigned_page_list = assigned_page_list
  25. self.overlay_pic_dict = {}
  26. self.init()
  27. # for goods_art_no_dict in self.goods_no_value["货号资料"]:
  28. # print(goods_art_no_dict)
  29. #
  30. # raise 1
  31. if excel_data:
  32. ig_keys = ["模板名称"]
  33. for k, v in excel_data.items():
  34. if k not in ig_keys:
  35. self.goods_no_value[k] = v
  36. def run_all(self):
  37. print("===================detailed_images=================")
  38. detailed_images = self.deal_details()
  39. self.create_folder(self.out_put_dir)
  40. detail_path = "{out_put_dir}/{goods_no}/details".format(out_put_dir=self.out_put_dir, goods_no=self.goods_no)
  41. self.create_folder(detail_path)
  42. self.save_to_png(detailed_images=detailed_images, detail_path=detail_path)
  43. # 生成拼接图
  44. self.generate_spliced_picture()
  45. # ------------移动其他图片---------------------
  46. # 获取主图模板列表
  47. main_pic_path_list = DetailBase.get_temp_pic_info(root=self.root)["main_pic_path_list"]
  48. if not main_pic_path_list:
  49. self.move_other_pic(move_main_pic=True)
  50. else:
  51. self.move_other_pic(move_main_pic=True)
  52. if not self.assigned_page_list:
  53. self.deal_all_main_pic()
  54. else:
  55. if "主图" in self.assigned_page_list:
  56. self.deal_all_main_pic()
  57. return True
  58. # 生成各个详情图切片
  59. def deal_details(self):
  60. detailed_images = []
  61. for index, func in enumerate(self.deal_pic_func_list):
  62. if not self.assigned_page_list:
  63. self.image_list_append(detailed_images, func())
  64. else:
  65. index = "{}".format(index + 1)
  66. if index in self.assigned_page_list:
  67. self.image_list_append(detailed_images, func())
  68. else:
  69. self.image_list_append(detailed_images, {"mes": "不生成"})
  70. return [x for x in detailed_images if x]
  71. # 生成拼接的图片
  72. def generate_spliced_picture(self):
  73. detail_path = "{out_put_dir}/{goods_no}/details".format(out_put_dir=self.out_put_dir, goods_no=self.goods_no)
  74. if not os.path.exists(detail_path):
  75. return
  76. detailed_images = []
  77. for image_data in get_images(detail_path):
  78. detailed_images.append(PictureProcessing(image_data["file_path"]))
  79. # 生成拼接图
  80. img = self.add_pic(detailed_images)
  81. join_path = "{out_put_dir}/{goods_no}/拼接图".format(out_put_dir=self.out_put_dir, goods_no=self.goods_no)
  82. self.create_folder(join_path)
  83. img.save("{}/1.jpg".format(join_path), format="JPEG")
  84. def image_list_append(self, image_list: list, data):
  85. self.check_state_end()
  86. image_list.append(data)
  87. def save_to_png(self, detailed_images, detail_path):
  88. self.check_state_end()
  89. for index, pp in enumerate(detailed_images):
  90. if isinstance(pp, dict):
  91. continue
  92. pp.im.save("{}/{}({}).png".format(detail_path, self.goods_no, str(index + 11).zfill(2)))
  93. def check_state_end(self):
  94. if self.windows is not None:
  95. if self.windows.state == 99:
  96. raise "用户主动取消"
  97. @classmethod
  98. def get_temp_pic_info(cls, root):
  99. """
  100. 获取详情页模板中的信息
  101. """
  102. main_pic_list = []
  103. mask_pic_list = []
  104. if os.path.exists(r"{}\main_image".format(root)):
  105. for _name in os.listdir(r"{}\main_image".format(root)):
  106. _path = r"{}\main_image\{}".format(root, _name)
  107. if os.path.isdir(_path):
  108. main_pic_list.append([x["file_path"] for x in get_images(_path)])
  109. mask_pic_list.append(
  110. [x["file_path"] for x in get_image_mask(_path)]
  111. )
  112. _l = get_images(r"{}\show".format(root))
  113. temp_pic_path = _l[0]["file_path"] if _l else None
  114. other_pic_list = [x["file_path"] for x in get_images(r"{}".format(root))]
  115. return {
  116. "main_pic_path_list": main_pic_list,
  117. "temp_pic_path": temp_pic_path,
  118. "mask_pic_list": mask_pic_list,
  119. "other_pic_path_list": other_pic_list,
  120. }
  121. def init(self):
  122. for goods_art_no_value in self.goods_no_value["货号资料"]:
  123. self.data[goods_art_no_value["货号"]] = {"pics": goods_art_no_value["pics"],
  124. "pic_is_deal": {}
  125. }
  126. def get_text_value(self, key, subsection_len=0):
  127. text = ""
  128. if key in self.goods_no_value:
  129. if self.goods_no_value[key]:
  130. text = str(self.goods_no_value[key])
  131. text = text.replace(r"\n", "\n")
  132. if key in ["跟高", "鞋宽", "帮高", "脚掌围", "鞋长"]:
  133. if text:
  134. text = text.split(".")[0]
  135. if subsection_len != 0:
  136. text = text.split("\n")
  137. text = [x for x in text if x]
  138. if len(text) == 2:
  139. text_1 = text[0]
  140. text_2 = text[1]
  141. return text_1, text_2
  142. else:
  143. if text:
  144. text_1 = text[0]
  145. else:
  146. text_1 = ""
  147. text_2 = ""
  148. return text_1, text_2
  149. return text
  150. def create_folder(self, path):
  151. if not os.path.exists(path):
  152. os.makedirs(path)
  153. def get_all_process_pics(self):
  154. """
  155. 获取所有颜色的过程图片
  156. data = [
  157. {"货号": "",
  158. "素材": [{
  159. "名称": "俯视",
  160. "抠图": "路径1",
  161. "阴影": "路径2"
  162. }, ]},
  163. ]
  164. """
  165. return_data = []
  166. for goods_art_no in self.data:
  167. goods_art_no_dict = {"货号": goods_art_no,
  168. "素材": [],
  169. }
  170. # 图片数据重新排序
  171. pic_data = []
  172. for pic_name, pic_path in self.data[goods_art_no]["pics"].items():
  173. root_path, file_name = os.path.split(pic_path)
  174. pic_data.append(file_name)
  175. pic_data = natsorted(pic_data, alg=ns.PATH)
  176. for file_name in pic_data:
  177. if "阴影" in file_name:
  178. _, action_name, _ = file_name.split("_")
  179. pic_path = self.data[goods_art_no]["pics"]["{}-阴影".format(action_name)]
  180. pic_cutout_path = self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)]
  181. if os.path.exists(pic_path) and os.path.exists(pic_cutout_path):
  182. goods_art_no_dict["素材"].append({"名称": action_name, "抠图": pic_cutout_path, "阴影": pic_path})
  183. return_data.append(goods_art_no_dict)
  184. return return_data
  185. def get_overlay_pic_from_dict(self, goods_art_no, color_name, bg_color) -> PictureProcessing:
  186. self.check_state_end()
  187. # 增加逻辑,获取任意货号下的组合图
  188. if "组合" in color_name:
  189. goods_art_no, color_name = self.get_all_scene_list(goods_art_no, color_name)
  190. key = "{}-{}-{}".format(goods_art_no, color_name, bg_color)
  191. if key in self.overlay_pic_dict:
  192. return self.overlay_pic_dict[key]
  193. if goods_art_no in self.data:
  194. for pic_name, pic_path in self.data[goods_art_no]["pics"].items():
  195. if "阴影" in pic_name:
  196. action_name = pic_name.replace("-阴影", "")
  197. if action_name == color_name:
  198. pp1 = PictureProcessing(pic_path)
  199. pp2 = PictureProcessing(self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)])
  200. pp1 = pp1.get_overlay_pic(top_img=pp2, color=bg_color).resize(mode="pixel", base="width",
  201. value=1600)
  202. self.overlay_pic_dict[key] = pp1
  203. if key in self.overlay_pic_dict:
  204. return self.overlay_pic_dict[key]
  205. def image_init(self, bg_color=(246, 246, 246)):
  206. # 制作一批素材图,添加背景色,并保留阴影,以及处理成最小尺寸
  207. for goods_art_no in self.data:
  208. for pic_name, pic_path in self.data[goods_art_no]["pics"].items():
  209. if "阴影" in pic_name:
  210. action_name = pic_name.replace("-阴影", "")
  211. pp1 = PictureProcessing(pic_path)
  212. pp2 = PictureProcessing(self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)])
  213. pp1 = pp1.get_overlay_pic(top_img=pp2, color=bg_color).resize(mode="pixel", base="width",
  214. value=1600)
  215. self.data[goods_art_no]["pic_is_deal"][action_name] = pp1
  216. # 获取任意货号的场景图,优先取指定货号;
  217. # 调整,按顺序从货号列表中提取所有组合图
  218. def get_all_scene_info(self, goods_art_no):
  219. data = []
  220. # 收集所有组合图
  221. # 找任意一个有组合图的货号
  222. for goods_art_no_dict in self.goods_no_value["货号资料"]:
  223. _goods_art_no = goods_art_no_dict["货号"]
  224. _view_name_list = set([x.split("-")[0] for x in goods_art_no_dict["pics"]])
  225. for _view_name in _view_name_list:
  226. if "组合" not in _view_name:
  227. continue
  228. return _goods_art_no
  229. return goods_art_no
  230. def get_all_scene_list(self, goods_art_no, view_name: str):
  231. if "组合" == view_name:
  232. view_name = "组合1"
  233. try:
  234. view_index = int(view_name.replace("组合", "")) - 1
  235. except:
  236. return goods_art_no, "无法匹配"
  237. data = []
  238. # 收集所有组合图
  239. # 找任意一个有组合图的货号
  240. for goods_art_no_dict in self.goods_no_value["货号资料"]:
  241. _goods_art_no = goods_art_no_dict["货号"]
  242. _view_name_list = set([x.split("-")[0] for x in goods_art_no_dict["pics"]])
  243. for _view_name in _view_name_list:
  244. if "组合" not in _view_name:
  245. continue
  246. data.append(
  247. {"goods_art_no": _goods_art_no,
  248. "view_name": _view_name
  249. }
  250. )
  251. if len(data) <= view_index:
  252. return goods_art_no, "无法匹配"
  253. else:
  254. return data[view_index]["goods_art_no"], data[view_index]["view_name"]
  255. def image_one_pic(self, goods_art_no, name, bg_color=None, return_orign=None):
  256. # 增加逻辑,获取任意货号下的组合图
  257. if "组合" in name:
  258. goods_art_no, name = self.get_all_scene_list(goods_art_no, name)
  259. # 制作一批素材图,添加背景色,并保留阴影,以及处理成最小尺寸
  260. for pic_name, pic_path in self.data[goods_art_no]["pics"].items():
  261. if "阴影" in pic_name:
  262. action_name = pic_name.replace("-阴影", "")
  263. if name != action_name:
  264. continue
  265. pp1 = PictureProcessing(pic_path)
  266. pp2 = PictureProcessing(self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)])
  267. if not return_orign:
  268. pp1 = pp1.get_overlay_pic(top_img=pp2, color=bg_color).resize(mode="pixel", base="width",
  269. value=1600)
  270. return pp1
  271. else:
  272. return pp1, pp2
  273. if not return_orign:
  274. return None
  275. else:
  276. return None, None
  277. def move_other_pic(self, move_main_pic=True):
  278. # ------------------------------移动其他图片------------------------------
  279. goods_no_main_pic_number = 0
  280. for goods_art_no_dict in self.goods_no_value["货号资料"]:
  281. if "800x800" not in goods_art_no_dict:
  282. continue
  283. if not goods_art_no_dict["800x800"]:
  284. continue
  285. goods_art_no = ""
  286. if "编号" in goods_art_no_dict:
  287. if goods_art_no_dict["编号"]:
  288. goods_art_no = goods_art_no_dict["编号"]
  289. if not goods_art_no:
  290. goods_art_no = goods_art_no_dict["货号"]
  291. # print("goods_art_no:", goods_art_no)
  292. # 移动颜色图=====================
  293. goods_art_no_f = "{}/{}/{}".format(self.out_put_dir, self.goods_no, goods_art_no)
  294. self.create_folder(goods_art_no_f)
  295. # 放入一张主图
  296. old_pic_path_1 = goods_art_no_dict["800x800"][0]
  297. shutil.copy(old_pic_path_1,
  298. "{}/{}{}".format(goods_art_no_f, goods_art_no, os.path.splitext(old_pic_path_1)[1]))
  299. # 把其他主图放入作为款号图=====================
  300. if move_main_pic:
  301. for pic_path in goods_art_no_dict["800x800"]:
  302. goods_no_main_pic_number += 1
  303. e = os.path.splitext(pic_path)[1]
  304. shutil.copy(pic_path,
  305. "{out_put_dir}/{goods_no}/{goods_no}({goods_no_main_pic_number}){e}".format(
  306. out_put_dir=self.out_put_dir, goods_no=self.goods_no,
  307. goods_no_main_pic_number=str(goods_no_main_pic_number + 10).zfill(2),
  308. e=e))
  309. def deal_all_main_pic(self):
  310. """
  311. 处理主图模板,如存在出图模板则进行对应处理
  312. """
  313. # 获取主图模板列表
  314. all_main_pic_path_list = DetailBase.get_temp_pic_info(root=self.root)["main_pic_path_list"]
  315. if not all_main_pic_path_list:
  316. return
  317. mask_pic_list = DetailBase.get_temp_pic_info(root=self.root)["mask_pic_list"]
  318. data = self.get_all_process_pics()
  319. print("========deal_all_main_pic=========主图相关素材:")
  320. view_list = ["组合", "组合2", "组合3", "组合4", "组合5", "组合6", "俯视", "侧视", "后跟", "鞋底", "内里", ]
  321. for _index, main_pic_path_list in enumerate(all_main_pic_path_list):
  322. self.check_state_end()
  323. out_path_root = "{out_put_dir}/{goods_no}/main_image_{_index}".format(
  324. out_put_dir=self.out_put_dir,
  325. goods_no=self.goods_no,
  326. _index=_index
  327. )
  328. check_path(out_path_root)
  329. if mask_pic_list[_index]:
  330. mask_pic = mask_pic_list[_index][0]
  331. else:
  332. mask_pic = None
  333. goods_no_main_pic_number = 10
  334. # g_index 为第几个颜色货号
  335. for g_index, goods_art_no_dict in enumerate(data):
  336. goods_art_no = goods_art_no_dict["货号"]
  337. # =====================重新指定=================================
  338. _material_sort_dict = {}
  339. for index, material_dict in enumerate(goods_art_no_dict["素材"]):
  340. name = material_dict["名称"]
  341. _material_sort_dict[name] = material_dict
  342. # ======================================================
  343. file_name_index = -1
  344. for view_name in view_list:
  345. # 组合图比较特殊,为全局获取
  346. if g_index != 0:
  347. if "组合" in view_name:
  348. continue
  349. if view_name not in _material_sort_dict:
  350. continue
  351. self.check_state_end()
  352. pp_jpg, pp_png = self.image_one_pic(goods_art_no, view_name, bg_color=None, return_orign=True)
  353. if not pp_jpg:
  354. continue
  355. file_name_index += 1
  356. # 获取对应主图模板
  357. if len(main_pic_path_list) < file_name_index + 1:
  358. main_pic_path = main_pic_path_list[-1]
  359. else:
  360. main_pic_path = main_pic_path_list[file_name_index]
  361. pp_bg = PictureProcessing(main_pic_path)
  362. original_width = pp_bg.width
  363. if original_width != 1600:
  364. pp_bg = pp_bg.resize(value=1600)
  365. if mask_pic:
  366. mask_bg = PictureProcessing(mask_pic)
  367. mask_bg = mask_bg.resize(value=1600)
  368. mask_box_im = mask_bg.get_im()
  369. box_size = mask_box_im.getbbox()
  370. result_image = mask_box_im.crop(box_size)
  371. mask_width, mask_height = result_image.size
  372. mask_x, mask_y = box_size[0], box_size[1]
  373. else:
  374. mask_width, mask_height = pp_bg.size
  375. mask_width, mask_height = int(mask_width * 12 / 16), int(mask_height * 12 / 16)
  376. mask_x, mask_y = int((pp_bg.size[0] - mask_width) / 2), int((pp_bg.size[1] - mask_height) / 2)
  377. if view_name != "后跟":
  378. pp_jpg = pp_jpg.resize(base_by_box=(mask_width, mask_height))
  379. pp_png = pp_png.resize(base_by_box=(mask_width, mask_height))
  380. # 计算粘贴的位置 mask的位置+图片在mask中的位置
  381. p_x = mask_x + int((mask_width - pp_jpg.width) / 2)
  382. p_y = mask_y + int((mask_height - pp_jpg.height) / 2)
  383. pp_bg = pp_bg.to_overlay_pic_advance(mode="pixel", top_img=pp_jpg, base="nw",
  384. value=(p_x, p_y), top_png_img=pp_png)
  385. else:
  386. new_mask_width, new_mask_height = int(mask_width / 1.6), int(mask_height / 1.6)
  387. pp_jpg = pp_jpg.resize(base_by_box=(new_mask_width, new_mask_height))
  388. pp_png = pp_png.resize(base_by_box=(new_mask_width, new_mask_height))
  389. new_mask_x = int((mask_width - new_mask_width) / 2 + mask_x)
  390. new_mask_y = int((mask_height - new_mask_height) / 2 + mask_y)
  391. # 计算粘贴的位置 mask的位置+图片在mask中的位置
  392. p_x = new_mask_x + int((new_mask_width - pp_jpg.width) / 2)
  393. p_y = new_mask_y + int((new_mask_height - pp_jpg.height) / 2)
  394. pp_bg = pp_bg.to_overlay_pic_advance(mode="pixel", top_img=pp_jpg, base="nw", value=(p_x, p_y),
  395. top_png_img=pp_png)
  396. goods_no_main_pic_number += 1
  397. out_pic_path = "{out_path_root}/{goods_no}({goods_no_main_pic_number}){pic_mode}".format(
  398. out_path_root=out_path_root,
  399. goods_no=self.goods_no,
  400. goods_no_main_pic_number=goods_no_main_pic_number,
  401. pic_mode=settings.OUT_PIC_MODE,
  402. )
  403. if settings.OUT_PIC_FACTOR > 1.0:
  404. print("图片锐化处理")
  405. pp_bg = pp_bg.sharpen_image(factor=settings.OUT_PIC_FACTOR)
  406. if original_width < 1600:
  407. pp_bg = pp_bg.resize(value=original_width)
  408. print("392 out_pic_path", out_pic_path)
  409. if settings.OUT_PIC_MODE == ".jpg":
  410. pp_bg.save_as_rgb(out_pic_path)
  411. else:
  412. pp_bg.save_as_png(out_pic_path)
  413. def add_pic(self, detailed_images):
  414. self.check_state_end()
  415. detailed_images = [x for x in detailed_images if x]
  416. if not detailed_images:
  417. return
  418. page_len = 0
  419. for index, pp in enumerate(detailed_images):
  420. page_len += pp.height
  421. bg_im = Image.new("RGB", (pp.width, page_len), (255, 255, 255))
  422. n = 0
  423. for index, pp in enumerate(detailed_images):
  424. bg_im.paste(pp.im, (0, n))
  425. n += pp.height
  426. return bg_im
  427. # 通用方法,用于写文字
  428. def add_text_list(self, text_list, spacing=5, base="wn"):
  429. text_list = [x for x in text_list if x["text"]]
  430. # print(text_list)
  431. # spacing 行间距
  432. text_image_list = []
  433. max_w = 0
  434. total_h = 0
  435. for text_data in text_list:
  436. _pp = PictureProcessing("RGBA", (1200, 800), (255, 255, 255, 0))
  437. if base == "wn" or base == "nw":
  438. align = "left"
  439. anchor = None
  440. value = (0, 200)
  441. if base == "cn" or base == "nc":
  442. align = "center"
  443. anchor = "mm"
  444. value = (600, 200)
  445. if base == "en" or base == "ne":
  446. align = "right"
  447. anchor = "rs"
  448. value = (1200, 200)
  449. _pp = _pp.get_text_image_advanced(
  450. value=value,
  451. font=text_data["font"],
  452. text=text_data["text"],
  453. align=align,
  454. anchor=anchor,
  455. spacing=5,
  456. fill=text_data["fill"],
  457. return_mode="min_image",
  458. margins=(0, 0, 0, 0)
  459. )
  460. text_image_list.append(_pp)
  461. if _pp.width > max_w:
  462. max_w = _pp.width
  463. total_h += _pp.height
  464. if "spacing" in text_data:
  465. total_h += text_data["spacing"]
  466. if not text_image_list:
  467. return None
  468. #
  469. bg = PictureProcessing("RGBA", (max_w, total_h * 3), (0, 0, 0, 0))
  470. y = 0
  471. for text_image, text_data in zip(text_image_list, text_list):
  472. bg = bg.paste_img(top_img=text_image, value=(0, y), base=base)
  473. y += spacing + text_image.height
  474. if "spacing" in text_data:
  475. y += text_data["spacing"]
  476. bg = bg.crop(mode="min")
  477. # _ = bg.paste_img_invert(top_img=PictureProcessing("RGB", (bg.width,bg.height), (255, 255, 255)))
  478. # _.show()
  479. return bg
  480. def generate_font_list_to_pic(self):
  481. font_path_list = [r"resources\ttf\puhui\Bold.ttf",
  482. r"resources\ttf\puhui\Medium.ttf",
  483. r"resources\ttf\puhui\Heavy.ttf",
  484. r"resources\ttf\puhui\Light.ttf",
  485. r"resources\ttf\puhui\Regular.ttf",
  486. ]
  487. text_v_list = [
  488. "这是一段话Bold",
  489. "这是一段话Medium",
  490. "这是一段话Heavy",
  491. "这是一段话Light",
  492. "这是一段话Regular",
  493. ]
  494. detailed_images = []
  495. for font_path, text in zip(font_path_list, text_v_list):
  496. text_list = []
  497. for size in range(26, 80, 2):
  498. font = ImageFont.truetype(font_path, size)
  499. text_list.append({"text": "{}-字号{}".format(text, size),
  500. "font": font,
  501. "fill": (110, 110, 110),
  502. })
  503. text_image = self.add_text_list(text_list, spacing=15, base="nw")
  504. text_image = text_image.crop(mode="min")
  505. text_image = text_image.paste_img_invert(top_img=PictureProcessing("RGB", text_image.size, (255, 255, 255)))
  506. detailed_images.append(text_image)
  507. return PictureProcessing(im=self.add_pic(detailed_images))