|
|
@@ -67,16 +67,31 @@ class DetailPicGet(DetailBase):
|
|
|
print(f"run {template_name} ")
|
|
|
self.base_bg_color = (255, 255, 255)
|
|
|
self.deal_pic_func_list = [
|
|
|
- self.deal_pic_1,
|
|
|
+ self.deal_pic_1(),
|
|
|
+ self.deal_pic_2(),
|
|
|
]
|
|
|
- if test:
|
|
|
- self.run_test()
|
|
|
- else:
|
|
|
- self.run_all()
|
|
|
+ img = self.add_pic(self.deal_pic_func_list)
|
|
|
+ file_path = self.get_text_value("图片路径")
|
|
|
+ # file_path = file_path.replace("\\", "/")
|
|
|
+ parent_folder = os.path.dirname(file_path)
|
|
|
+ if os.path.exists(parent_folder) == False:
|
|
|
+ # 确保目标目录存在
|
|
|
+ os.makedirs(parent_folder, exist_ok=True)
|
|
|
+ print("file_path是否存在",parent_folder, os.path.exists(parent_folder))
|
|
|
+ file_extension = file_path.split(".")[-1]
|
|
|
+ format_mapping = {"jpg": "JPEG", "png": "PNG", "webp": "WEBP", "avif": "AVIF"}
|
|
|
+ file_format = format_mapping[file_extension]
|
|
|
+ img.save(file_path, format=file_format)
|
|
|
+ img.show()
|
|
|
+ # if test:
|
|
|
+ # self.run_test()
|
|
|
+ # else:
|
|
|
+ # self.run_all()
|
|
|
|
|
|
def run_test(self):
|
|
|
detailed_images = []
|
|
|
detailed_images.append(self.deal_pic_1())
|
|
|
+ detailed_images.append(self.deal_pic_2())
|
|
|
img = self.add_pic(detailed_images)
|
|
|
if img:
|
|
|
self.create_folder(r"{}/{}".format(self.out_put_dir, template_name))
|
|
|
@@ -94,7 +109,17 @@ class DetailPicGet(DetailBase):
|
|
|
base_bg_width = 1200
|
|
|
base_limit_width = base_bg_width / 2
|
|
|
font = ImageFont.truetype("msyh.ttc", 20)
|
|
|
- dataList = ["款号", "面料", "内里", "垫脚", "大底", "饰扣", "客户", "日期"]
|
|
|
+ dataList = [
|
|
|
+ "款号",
|
|
|
+ "面料",
|
|
|
+ "内里",
|
|
|
+ "垫脚",
|
|
|
+ "大底",
|
|
|
+ "饰扣",
|
|
|
+ "客户",
|
|
|
+ "码数",
|
|
|
+ "日期",
|
|
|
+ ]
|
|
|
height_total = 0
|
|
|
text_list = []
|
|
|
line_space = 15
|
|
|
@@ -152,12 +177,22 @@ class DetailPicGet(DetailBase):
|
|
|
detailed_images.append(pp_image_jpg)
|
|
|
return PictureProcessing(im=self.add_pic(detailed_images))
|
|
|
|
|
|
- def deal_pic_1(self):
|
|
|
+ def deal_pic_2(self):
|
|
|
detailed_images = []
|
|
|
base_bg_width = 1200
|
|
|
base_limit_width = base_bg_width / 2
|
|
|
- font = ImageFont.truetype("msyh.ttc", 20)
|
|
|
- dataList = ["款号", "面料", "内里", "垫脚", "大底", "饰扣", "客户", "日期"]
|
|
|
+ font = ImageFont.truetype("arial.ttf", 20)
|
|
|
+ dataList = [
|
|
|
+ "JEFFREY CAMPBELL",
|
|
|
+ "Supplier",
|
|
|
+ "款号", # Fty No
|
|
|
+ "Material",
|
|
|
+ "Lining&Sock",
|
|
|
+ "码数", # Size
|
|
|
+ "日期", # Date
|
|
|
+ "Remark",
|
|
|
+ "MADE IN CHINA",
|
|
|
+ ]
|
|
|
height_total = 0
|
|
|
text_list = []
|
|
|
line_space = 15
|
|
|
@@ -165,8 +200,19 @@ class DetailPicGet(DetailBase):
|
|
|
info = self.get_text_value(item)
|
|
|
if info == None or info == "":
|
|
|
continue
|
|
|
+ mapping = {
|
|
|
+ "JEFFREY CAMPBELL": "",
|
|
|
+ "Supplier": "Supplier:",
|
|
|
+ "款号": "Fty No:",
|
|
|
+ "Material": "Material:",
|
|
|
+ "Lining&Sock": "Lining&Sock:",
|
|
|
+ "码数": "Size:",
|
|
|
+ "日期": "Date:",
|
|
|
+ "Remark": "Remark:",
|
|
|
+ "MADE IN CHINA": "",
|
|
|
+ }
|
|
|
_pp = PictureProcessing()
|
|
|
- text = f"{item}: {self.get_text_value(item)}"
|
|
|
+ text = f"{mapping[item]} {self.get_text_value(item)}"
|
|
|
duanluo = ""
|
|
|
sum_width = 0
|
|
|
line_count = 0
|
|
|
@@ -178,7 +224,11 @@ class DetailPicGet(DetailBase):
|
|
|
sum_width = 0
|
|
|
duanluo += "\n"
|
|
|
duanluo += char
|
|
|
+ value = (0,0)
|
|
|
+ if idx ==0 or idx == len(dataList)-1:
|
|
|
+ value = (-5,0)
|
|
|
_pp = _pp.get_text_image_advanced(
|
|
|
+ value=value,
|
|
|
font=font,
|
|
|
text=duanluo,
|
|
|
spacing=10,
|