|
|
@@ -15,14 +15,23 @@ from PIL import Image
|
|
|
import shutil
|
|
|
from service.base import get_images, check_path, get_image_mask
|
|
|
from natsort import ns, natsorted
|
|
|
+
|
|
|
# import math
|
|
|
from PIL import ImageFont
|
|
|
import settings
|
|
|
|
|
|
|
|
|
class DetailBase(object):
|
|
|
- def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, excel_data=None,
|
|
|
- assigned_page_list=None, output_queue=None):
|
|
|
+ def __init__(
|
|
|
+ self,
|
|
|
+ goods_no,
|
|
|
+ goods_no_value: dict,
|
|
|
+ out_put_dir,
|
|
|
+ windows=None,
|
|
|
+ excel_data=None,
|
|
|
+ assigned_page_list=None,
|
|
|
+ output_queue=None,
|
|
|
+ ):
|
|
|
self.goods_no = goods_no
|
|
|
self.output_queue = output_queue
|
|
|
self.out_put_dir = out_put_dir
|
|
|
@@ -79,7 +88,9 @@ class DetailBase(object):
|
|
|
return False
|
|
|
|
|
|
def del_detail_folder(self):
|
|
|
- out_path = "{out_put_dir}/{goods_no}".format(out_put_dir=self.out_put_dir, goods_no=self.goods_no)
|
|
|
+ out_path = "{out_put_dir}/{goods_no}".format(
|
|
|
+ out_put_dir=self.out_put_dir, goods_no=self.goods_no
|
|
|
+ )
|
|
|
if not os.path.exists(out_path):
|
|
|
return
|
|
|
try:
|
|
|
@@ -97,7 +108,9 @@ class DetailBase(object):
|
|
|
self.del_detail_folder()
|
|
|
detailed_images = self.deal_details()
|
|
|
self.create_folder(self.out_put_dir)
|
|
|
- detail_path = "{out_put_dir}/{goods_no}/details".format(out_put_dir=self.out_put_dir, goods_no=self.goods_no)
|
|
|
+ detail_path = "{out_put_dir}/{goods_no}/details".format(
|
|
|
+ out_put_dir=self.out_put_dir, goods_no=self.goods_no
|
|
|
+ )
|
|
|
self.create_folder(detail_path)
|
|
|
self.save_to_png(detailed_images=detailed_images, detail_path=detail_path)
|
|
|
# 生成拼接图
|
|
|
@@ -105,7 +118,9 @@ class DetailBase(object):
|
|
|
|
|
|
# ------------移动其他图片---------------------
|
|
|
# 获取主图模板列表
|
|
|
- main_pic_path_list = DetailBase.get_temp_pic_info(root=self.root)["main_pic_path_list"]
|
|
|
+ main_pic_path_list = DetailBase.get_temp_pic_info(root=self.root)[
|
|
|
+ "main_pic_path_list"
|
|
|
+ ]
|
|
|
if not main_pic_path_list:
|
|
|
self.move_other_pic(move_main_pic=True)
|
|
|
else:
|
|
|
@@ -124,19 +139,26 @@ class DetailBase(object):
|
|
|
continue
|
|
|
color_name = pic_data["颜色名称"]
|
|
|
|
|
|
- color_file_path = "{out_put_dir}/{goods_no}/{goods_number}".format(out_put_dir=self.out_put_dir,
|
|
|
- goods_no=self.goods_no,
|
|
|
- goods_number=pic_data["编号"])
|
|
|
+ color_file_path = "{out_put_dir}/{goods_no}/{goods_number}".format(
|
|
|
+ out_put_dir=self.out_put_dir,
|
|
|
+ goods_no=self.goods_no,
|
|
|
+ goods_number=pic_data["编号"],
|
|
|
+ )
|
|
|
for i in self.goods_no_value["data_all_goods_art_info"]:
|
|
|
if color_name in i["color"]:
|
|
|
- new_path = "{out_put_dir}/{goods_no}/{goods_number}".format(out_put_dir=self.out_put_dir,
|
|
|
- goods_no=self.goods_no,
|
|
|
- goods_number="NUM{}".format(
|
|
|
- i["number"]))
|
|
|
+ new_path = "{out_put_dir}/{goods_no}/{goods_number}".format(
|
|
|
+ out_put_dir=self.out_put_dir,
|
|
|
+ goods_no=self.goods_no,
|
|
|
+ goods_number="NUM{}".format(i["number"]),
|
|
|
+ )
|
|
|
if not os.path.exists(new_path):
|
|
|
# 创建文件夹
|
|
|
os.makedirs(new_path)
|
|
|
- self.move_one_pic(color_file_path, new_path, "NUM{}".format(i["number"]))
|
|
|
+ self.move_one_pic(
|
|
|
+ color_file_path,
|
|
|
+ new_path,
|
|
|
+ "NUM{}".format(i["number"]),
|
|
|
+ )
|
|
|
return True
|
|
|
|
|
|
# 移动一张图片到新的文件夹
|
|
|
@@ -165,7 +187,9 @@ class DetailBase(object):
|
|
|
|
|
|
# 生成拼接的图片
|
|
|
def generate_spliced_picture(self):
|
|
|
- detail_path = "{out_put_dir}/{goods_no}/details".format(out_put_dir=self.out_put_dir, goods_no=self.goods_no)
|
|
|
+ detail_path = "{out_put_dir}/{goods_no}/details".format(
|
|
|
+ out_put_dir=self.out_put_dir, goods_no=self.goods_no
|
|
|
+ )
|
|
|
if not os.path.exists(detail_path):
|
|
|
return
|
|
|
detailed_images = []
|
|
|
@@ -173,7 +197,9 @@ class DetailBase(object):
|
|
|
detailed_images.append(PictureProcessing(image_data["file_path"]))
|
|
|
# 生成拼接图
|
|
|
img = self.add_pic(detailed_images)
|
|
|
- join_path = "{out_put_dir}/{goods_no}/拼接图".format(out_put_dir=self.out_put_dir, goods_no=self.goods_no)
|
|
|
+ join_path = "{out_put_dir}/{goods_no}/拼接图".format(
|
|
|
+ out_put_dir=self.out_put_dir, goods_no=self.goods_no
|
|
|
+ )
|
|
|
self.create_folder(join_path)
|
|
|
img.save("{}/1.jpg".format(join_path), format="JPEG")
|
|
|
|
|
|
@@ -189,7 +215,11 @@ class DetailBase(object):
|
|
|
for index, pp in enumerate(detailed_images):
|
|
|
if isinstance(pp, dict):
|
|
|
continue
|
|
|
- pp.im.save("{}/{}({}).png".format(detail_path, self.goods_no, str(index + 11).zfill(2)))
|
|
|
+ pp.im.save(
|
|
|
+ "{}/{}({}).png".format(
|
|
|
+ detail_path, self.goods_no, str(index + 11).zfill(2)
|
|
|
+ )
|
|
|
+ )
|
|
|
|
|
|
def check_state_end(self):
|
|
|
if self.windows is not None:
|
|
|
@@ -224,9 +254,10 @@ class DetailBase(object):
|
|
|
|
|
|
def init(self):
|
|
|
for goods_art_no_value in self.goods_no_value["货号资料"]:
|
|
|
- self.data[goods_art_no_value["货号"]] = {"pics": goods_art_no_value["pics"],
|
|
|
- "pic_is_deal": {}
|
|
|
- }
|
|
|
+ self.data[goods_art_no_value["货号"]] = {
|
|
|
+ "pics": goods_art_no_value["pics"],
|
|
|
+ "pic_is_deal": {},
|
|
|
+ }
|
|
|
|
|
|
def get_text_value(self, key, subsection_len=0):
|
|
|
text = ""
|
|
|
@@ -274,9 +305,10 @@ class DetailBase(object):
|
|
|
"""
|
|
|
return_data = []
|
|
|
for goods_art_no in self.data:
|
|
|
- goods_art_no_dict = {"货号": goods_art_no,
|
|
|
- "素材": [],
|
|
|
- }
|
|
|
+ goods_art_no_dict = {
|
|
|
+ "货号": goods_art_no,
|
|
|
+ "素材": [],
|
|
|
+ }
|
|
|
|
|
|
# 图片数据重新排序
|
|
|
pic_data = []
|
|
|
@@ -289,15 +321,27 @@ class DetailBase(object):
|
|
|
for file_name in pic_data:
|
|
|
if "阴影" in file_name:
|
|
|
_, action_name, _ = file_name.split("_")
|
|
|
- pic_path = self.data[goods_art_no]["pics"]["{}-阴影".format(action_name)]
|
|
|
- pic_cutout_path = self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)]
|
|
|
+ pic_path = self.data[goods_art_no]["pics"][
|
|
|
+ "{}-阴影".format(action_name)
|
|
|
+ ]
|
|
|
+ pic_cutout_path = self.data[goods_art_no]["pics"][
|
|
|
+ "{}-抠图".format(action_name)
|
|
|
+ ]
|
|
|
if os.path.exists(pic_path) and os.path.exists(pic_cutout_path):
|
|
|
- goods_art_no_dict["素材"].append({"名称": action_name, "抠图": pic_cutout_path, "阴影": pic_path})
|
|
|
+ goods_art_no_dict["素材"].append(
|
|
|
+ {
|
|
|
+ "名称": action_name,
|
|
|
+ "抠图": pic_cutout_path,
|
|
|
+ "阴影": pic_path,
|
|
|
+ }
|
|
|
+ )
|
|
|
return_data.append(goods_art_no_dict)
|
|
|
|
|
|
return return_data
|
|
|
|
|
|
- def get_overlay_pic_from_dict(self, goods_art_no, color_name, bg_color) -> PictureProcessing:
|
|
|
+ def get_overlay_pic_from_dict(
|
|
|
+ self, goods_art_no, color_name, bg_color
|
|
|
+ ) -> PictureProcessing:
|
|
|
self.check_state_end()
|
|
|
# 增加逻辑,获取任意货号下的组合图
|
|
|
if "组合" in color_name:
|
|
|
@@ -313,9 +357,14 @@ class DetailBase(object):
|
|
|
action_name = pic_name.replace("-阴影", "")
|
|
|
if action_name == color_name:
|
|
|
pp1 = PictureProcessing(pic_path)
|
|
|
- pp2 = PictureProcessing(self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)])
|
|
|
- pp1 = pp1.get_overlay_pic(top_img=pp2, color=bg_color).resize(mode="pixel", base="width",
|
|
|
- value=1600)
|
|
|
+ pp2 = PictureProcessing(
|
|
|
+ self.data[goods_art_no]["pics"][
|
|
|
+ "{}-抠图".format(action_name)
|
|
|
+ ]
|
|
|
+ )
|
|
|
+ pp1 = pp1.get_overlay_pic(top_img=pp2, color=bg_color).resize(
|
|
|
+ mode="pixel", base="width", value=1600
|
|
|
+ )
|
|
|
self.overlay_pic_dict[key] = pp1
|
|
|
|
|
|
if key in self.overlay_pic_dict:
|
|
|
@@ -328,9 +377,12 @@ class DetailBase(object):
|
|
|
if "阴影" in pic_name:
|
|
|
action_name = pic_name.replace("-阴影", "")
|
|
|
pp1 = PictureProcessing(pic_path)
|
|
|
- pp2 = PictureProcessing(self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)])
|
|
|
- pp1 = pp1.get_overlay_pic(top_img=pp2, color=bg_color).resize(mode="pixel", base="width",
|
|
|
- value=1600)
|
|
|
+ pp2 = PictureProcessing(
|
|
|
+ self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)]
|
|
|
+ )
|
|
|
+ pp1 = pp1.get_overlay_pic(top_img=pp2, color=bg_color).resize(
|
|
|
+ mode="pixel", base="width", value=1600
|
|
|
+ )
|
|
|
self.data[goods_art_no]["pic_is_deal"][action_name] = pp1
|
|
|
|
|
|
# 获取任意货号的场景图,优先取指定货号;
|
|
|
@@ -361,17 +413,20 @@ class DetailBase(object):
|
|
|
# 找任意一个有组合图的货号
|
|
|
for goods_art_no_dict in self.goods_no_value["货号资料"]:
|
|
|
_goods_art_no = goods_art_no_dict["货号"]
|
|
|
- if _goods_art_no !=goods_art_no:
|
|
|
+ if _goods_art_no != goods_art_no:
|
|
|
continue
|
|
|
_view_name_list = set([x.split("-")[0] for x in goods_art_no_dict["pics"]])
|
|
|
for _view_name in _view_name_list:
|
|
|
if "组合" not in _view_name:
|
|
|
continue
|
|
|
data.append(
|
|
|
- {"goods_art_no": _goods_art_no,
|
|
|
- "view_name": _view_name,
|
|
|
- "real_view_name": "组合1" if _view_name == "组合" else _view_name
|
|
|
- }
|
|
|
+ {
|
|
|
+ "goods_art_no": _goods_art_no,
|
|
|
+ "view_name": _view_name,
|
|
|
+ "real_view_name": (
|
|
|
+ "组合1" if _view_name == "组合" else _view_name
|
|
|
+ ),
|
|
|
+ }
|
|
|
)
|
|
|
if len(data) <= view_index:
|
|
|
return goods_art_no, "无法匹配"
|
|
|
@@ -393,10 +448,13 @@ class DetailBase(object):
|
|
|
if name != action_name:
|
|
|
continue
|
|
|
pp1 = PictureProcessing(pic_path)
|
|
|
- pp2 = PictureProcessing(self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)])
|
|
|
+ pp2 = PictureProcessing(
|
|
|
+ self.data[goods_art_no]["pics"]["{}-抠图".format(action_name)]
|
|
|
+ )
|
|
|
if not return_orign:
|
|
|
- pp1 = pp1.get_overlay_pic(top_img=pp2, color=bg_color).resize(mode="pixel", base="width",
|
|
|
- value=1600)
|
|
|
+ pp1 = pp1.get_overlay_pic(top_img=pp2, color=bg_color).resize(
|
|
|
+ mode="pixel", base="width", value=1600
|
|
|
+ )
|
|
|
return pp1
|
|
|
else:
|
|
|
return pp1, pp2
|
|
|
@@ -423,44 +481,68 @@ class DetailBase(object):
|
|
|
goods_art_no = goods_art_no_dict["货号"]
|
|
|
# print("goods_art_no:", goods_art_no)
|
|
|
# 移动颜色图=====================
|
|
|
- goods_art_no_f = "{}/{}/{}".format(self.out_put_dir, self.goods_no, goods_art_no)
|
|
|
+ goods_art_no_f = "{}/{}/{}".format(
|
|
|
+ self.out_put_dir, self.goods_no, goods_art_no
|
|
|
+ )
|
|
|
self.create_folder(goods_art_no_f)
|
|
|
# 放入一张主图
|
|
|
old_pic_path_1 = goods_art_no_dict["800x800"][0]
|
|
|
- shutil.copy(old_pic_path_1,
|
|
|
- "{}/{}{}".format(goods_art_no_f, goods_art_no, os.path.splitext(old_pic_path_1)[1]))
|
|
|
+ shutil.copy(
|
|
|
+ old_pic_path_1,
|
|
|
+ "{}/{}{}".format(
|
|
|
+ goods_art_no_f, goods_art_no, os.path.splitext(old_pic_path_1)[1]
|
|
|
+ ),
|
|
|
+ )
|
|
|
|
|
|
# 把其他主图放入作为款号图=====================
|
|
|
if move_main_pic:
|
|
|
for pic_path in goods_art_no_dict["800x800"]:
|
|
|
goods_no_main_pic_number += 1
|
|
|
e = os.path.splitext(pic_path)[1]
|
|
|
- shutil.copy(pic_path,
|
|
|
- "{out_put_dir}/{goods_no}/{goods_no}({goods_no_main_pic_number}){e}".format(
|
|
|
- out_put_dir=self.out_put_dir, goods_no=self.goods_no,
|
|
|
- goods_no_main_pic_number=str(goods_no_main_pic_number + 10).zfill(2),
|
|
|
- e=e))
|
|
|
+ shutil.copy(
|
|
|
+ pic_path,
|
|
|
+ "{out_put_dir}/{goods_no}/{goods_no}({goods_no_main_pic_number}){e}".format(
|
|
|
+ out_put_dir=self.out_put_dir,
|
|
|
+ goods_no=self.goods_no,
|
|
|
+ goods_no_main_pic_number=str(
|
|
|
+ goods_no_main_pic_number + 10
|
|
|
+ ).zfill(2),
|
|
|
+ e=e,
|
|
|
+ ),
|
|
|
+ )
|
|
|
|
|
|
def deal_all_main_pic(self):
|
|
|
"""
|
|
|
处理主图模板,如存在出图模板则进行对应处理
|
|
|
"""
|
|
|
# 获取主图模板列表
|
|
|
- all_main_pic_path_list = DetailBase.get_temp_pic_info(root=self.root)["main_pic_path_list"]
|
|
|
+ all_main_pic_path_list = DetailBase.get_temp_pic_info(root=self.root)[
|
|
|
+ "main_pic_path_list"
|
|
|
+ ]
|
|
|
if not all_main_pic_path_list:
|
|
|
return
|
|
|
mask_pic_list = DetailBase.get_temp_pic_info(root=self.root)["mask_pic_list"]
|
|
|
data = self.get_all_process_pics()
|
|
|
print("========deal_all_main_pic=========主图相关素材:")
|
|
|
|
|
|
- view_list = ["组合", "组合2", "组合3", "组合4", "组合5", "组合6", "俯视", "侧视", "后跟", "鞋底", "内里", ]
|
|
|
+ view_list = [
|
|
|
+ "组合",
|
|
|
+ "组合2",
|
|
|
+ "组合3",
|
|
|
+ "组合4",
|
|
|
+ "组合5",
|
|
|
+ "组合6",
|
|
|
+ "俯视",
|
|
|
+ "侧视",
|
|
|
+ "后跟",
|
|
|
+ "鞋底",
|
|
|
+ "内里",
|
|
|
+ ]
|
|
|
|
|
|
for _index, main_pic_path_list in enumerate(all_main_pic_path_list):
|
|
|
self.check_state_end()
|
|
|
out_path_root = "{out_put_dir}/{goods_no}/main_image_{_index}".format(
|
|
|
- out_put_dir=self.out_put_dir,
|
|
|
- goods_no=self.goods_no,
|
|
|
- _index=_index
|
|
|
+ out_put_dir=self.out_put_dir, goods_no=self.goods_no, _index=_index
|
|
|
)
|
|
|
check_path(out_path_root)
|
|
|
if mask_pic_list[_index]:
|
|
|
@@ -488,7 +570,9 @@ class DetailBase(object):
|
|
|
if view_name not in _material_sort_dict:
|
|
|
continue
|
|
|
self.check_state_end()
|
|
|
- pp_jpg, pp_png = self.image_one_pic(goods_art_no, view_name, bg_color=None, return_orign=True)
|
|
|
+ pp_jpg, pp_png = self.image_one_pic(
|
|
|
+ goods_art_no, view_name, bg_color=None, return_orign=True
|
|
|
+ )
|
|
|
if not pp_jpg:
|
|
|
continue
|
|
|
|
|
|
@@ -514,8 +598,12 @@ class DetailBase(object):
|
|
|
mask_x, mask_y = box_size[0], box_size[1]
|
|
|
else:
|
|
|
mask_width, mask_height = pp_bg.size
|
|
|
- mask_width, mask_height = int(mask_width * 12 / 16), int(mask_height * 12 / 16)
|
|
|
- mask_x, mask_y = int((pp_bg.size[0] - mask_width) / 2), int((pp_bg.size[1] - mask_height) / 2)
|
|
|
+ mask_width, mask_height = int(mask_width * 12 / 16), int(
|
|
|
+ mask_height * 12 / 16
|
|
|
+ )
|
|
|
+ mask_x, mask_y = int((pp_bg.size[0] - mask_width) / 2), int(
|
|
|
+ (pp_bg.size[1] - mask_height) / 2
|
|
|
+ )
|
|
|
|
|
|
if view_name != "后跟":
|
|
|
pp_jpg = pp_jpg.resize(base_by_box=(mask_width, mask_height))
|
|
|
@@ -524,13 +612,24 @@ class DetailBase(object):
|
|
|
# 计算粘贴的位置 mask的位置+图片在mask中的位置
|
|
|
p_x = mask_x + int((mask_width - pp_jpg.width) / 2)
|
|
|
p_y = mask_y + int((mask_height - pp_jpg.height) / 2)
|
|
|
- pp_bg = pp_bg.to_overlay_pic_advance(mode="pixel", top_img=pp_jpg, base="nw",
|
|
|
- value=(p_x, p_y), top_png_img=pp_png)
|
|
|
+ pp_bg = pp_bg.to_overlay_pic_advance(
|
|
|
+ mode="pixel",
|
|
|
+ top_img=pp_jpg,
|
|
|
+ base="nw",
|
|
|
+ value=(p_x, p_y),
|
|
|
+ top_png_img=pp_png,
|
|
|
+ )
|
|
|
else:
|
|
|
- new_mask_width, new_mask_height = int(mask_width / 1.6), int(mask_height / 1.6)
|
|
|
-
|
|
|
- pp_jpg = pp_jpg.resize(base_by_box=(new_mask_width, new_mask_height))
|
|
|
- pp_png = pp_png.resize(base_by_box=(new_mask_width, new_mask_height))
|
|
|
+ new_mask_width, new_mask_height = int(mask_width / 1.6), int(
|
|
|
+ mask_height / 1.6
|
|
|
+ )
|
|
|
+
|
|
|
+ pp_jpg = pp_jpg.resize(
|
|
|
+ base_by_box=(new_mask_width, new_mask_height)
|
|
|
+ )
|
|
|
+ pp_png = pp_png.resize(
|
|
|
+ base_by_box=(new_mask_width, new_mask_height)
|
|
|
+ )
|
|
|
new_mask_x = int((mask_width - new_mask_width) / 2 + mask_x)
|
|
|
new_mask_y = int((mask_height - new_mask_height) / 2 + mask_y)
|
|
|
|
|
|
@@ -538,8 +637,13 @@ class DetailBase(object):
|
|
|
p_x = new_mask_x + int((new_mask_width - pp_jpg.width) / 2)
|
|
|
p_y = new_mask_y + int((new_mask_height - pp_jpg.height) / 2)
|
|
|
|
|
|
- pp_bg = pp_bg.to_overlay_pic_advance(mode="pixel", top_img=pp_jpg, base="nw", value=(p_x, p_y),
|
|
|
- top_png_img=pp_png)
|
|
|
+ pp_bg = pp_bg.to_overlay_pic_advance(
|
|
|
+ mode="pixel",
|
|
|
+ top_img=pp_jpg,
|
|
|
+ base="nw",
|
|
|
+ value=(p_x, p_y),
|
|
|
+ top_png_img=pp_png,
|
|
|
+ )
|
|
|
|
|
|
goods_no_main_pic_number += 1
|
|
|
out_pic_path = "{out_path_root}/{goods_no}({goods_no_main_pic_number}){pic_mode}".format(
|
|
|
@@ -559,8 +663,12 @@ class DetailBase(object):
|
|
|
print("392 out_pic_path", out_pic_path)
|
|
|
if settings.OUT_PIC_MODE == ".jpg":
|
|
|
pp_bg.save_as_rgb(out_pic_path)
|
|
|
- else:
|
|
|
+ elif settings.OUT_PIC_MODE == ".png":
|
|
|
pp_bg.save_as_png(out_pic_path)
|
|
|
+ else:
|
|
|
+ pp_bg.save_as_other(
|
|
|
+ out_pic_path, settings.OUT_PIC_MODE.split(".")[-1]
|
|
|
+ )
|
|
|
|
|
|
def add_pic(self, detailed_images):
|
|
|
self.check_state_end()
|
|
|
@@ -618,7 +726,7 @@ class DetailBase(object):
|
|
|
spacing=5,
|
|
|
fill=text_data["fill"],
|
|
|
return_mode="min_image",
|
|
|
- margins=(0, 0, 0, 0)
|
|
|
+ margins=(0, 0, 0, 0),
|
|
|
)
|
|
|
text_image_list.append(_pp)
|
|
|
if _pp.width > max_w:
|
|
|
@@ -645,12 +753,13 @@ class DetailBase(object):
|
|
|
return bg
|
|
|
|
|
|
def generate_font_list_to_pic(self):
|
|
|
- font_path_list = [r"resources\ttf\puhui\Bold.ttf",
|
|
|
- r"resources\ttf\puhui\Medium.ttf",
|
|
|
- r"resources\ttf\puhui\Heavy.ttf",
|
|
|
- r"resources\ttf\puhui\Light.ttf",
|
|
|
- r"resources\ttf\puhui\Regular.ttf",
|
|
|
- ]
|
|
|
+ font_path_list = [
|
|
|
+ r"resources\ttf\puhui\Bold.ttf",
|
|
|
+ r"resources\ttf\puhui\Medium.ttf",
|
|
|
+ r"resources\ttf\puhui\Heavy.ttf",
|
|
|
+ r"resources\ttf\puhui\Light.ttf",
|
|
|
+ r"resources\ttf\puhui\Regular.ttf",
|
|
|
+ ]
|
|
|
text_v_list = [
|
|
|
"这是一段话Bold",
|
|
|
"这是一段话Medium",
|
|
|
@@ -663,13 +772,18 @@ class DetailBase(object):
|
|
|
text_list = []
|
|
|
for size in range(26, 80, 2):
|
|
|
font = ImageFont.truetype(font_path, size)
|
|
|
- text_list.append({"text": "{}-字号{}".format(text, size),
|
|
|
- "font": font,
|
|
|
- "fill": (110, 110, 110),
|
|
|
- })
|
|
|
+ text_list.append(
|
|
|
+ {
|
|
|
+ "text": "{}-字号{}".format(text, size),
|
|
|
+ "font": font,
|
|
|
+ "fill": (110, 110, 110),
|
|
|
+ }
|
|
|
+ )
|
|
|
text_image = self.add_text_list(text_list, spacing=15, base="nw")
|
|
|
text_image = text_image.crop(mode="min")
|
|
|
- text_image = text_image.paste_img_invert(top_img=PictureProcessing("RGB", text_image.size, (255, 255, 255)))
|
|
|
+ text_image = text_image.paste_img_invert(
|
|
|
+ top_img=PictureProcessing("RGB", text_image.size, (255, 255, 255))
|
|
|
+ )
|
|
|
detailed_images.append(text_image)
|
|
|
return PictureProcessing(im=self.add_pic(detailed_images))
|
|
|
|