浏览代码

path问题

rambo 1 月之前
父节点
当前提交
b6f2e689e3

+ 13 - 8
python/custom_plugins/plugins/detail_template/clothing/detail_clothing1.py

@@ -97,7 +97,8 @@ class DetailPicGet(DetailBase):
         detailed_images = []
         pp_0 = PictureProcessing(r"{}\1.jpg".format(self.root))
         detailed_images.append(pp_0)
-        bg_img = self.getSpecialImage(category="场景图", instead_category="正面")
+        image_path = self.goods_no_value["货号资料"][0].get("场景图",None)
+        bg_img = self.getSpecialImage(path=image_path, instead_category="正面")
         detailed_images.append(bg_img)
         fab_bg = PictureProcessing("RGB", (bg_img.width, 400), (255, 255, 255))
         font_1 = ImageFont.truetype(r"resources\ttf\puhui\Regular.ttf", 30)  # 颜色名称
@@ -126,11 +127,12 @@ class DetailPicGet(DetailBase):
         detailed_images.append(fab_bg)
         return PictureProcessing(im=self.add_pic(detailed_images))
 
-    def getSpecialImage(self, category="模特图", instead_category="正面", resize=1200):
+    def getSpecialImage(self, path=None, instead_category="正面", resize=1200):
         """获取特殊图片"""
         goods_art_no_list = list(self.data.keys())
-        if self.get_text_value(category):
-            mote_img = PictureProcessing(self.get_text_value(category))
+        
+        if path:
+            mote_img = PictureProcessing(path)
             mote_img = mote_img.resize(value=resize)
         else:
             pp_jpg, pp_png = self.image_one_pic_no_shandow(
@@ -153,13 +155,14 @@ class DetailPicGet(DetailBase):
         for idx,goods_art_no_dict in enumerate(self.goods_no_value["货号资料"]):
             # color_name = goods_art_no_dict["颜色名称"]
             # goods_art_no = goods_art_no_dict["货号"]
+            image_path = goods_art_no_dict.get("模特图",None)
             if len(self.goods_no_value["货号资料"]) > 1:
                 pp_jpg = self.getSpecialImage(
-                    category="模特图", instead_category="正面", resize=pp_1.width/2.2
+                    path=image_path, instead_category="正面", resize=pp_1.width/2.2
                 )
             else:
                 pp_jpg = self.getSpecialImage(
-                    category="模特图", instead_category="正面", resize=pp_1.width
+                    path=image_path, instead_category="正面", resize=pp_1.width
                 )
             color_pic_list_1.append(pp_jpg)
 
@@ -193,8 +196,9 @@ class DetailPicGet(DetailBase):
         pp_1 = PictureProcessing(r"{}\8.jpg".format(self.root))
         # 细节展示
         detailed_images.append(pp_1)
+        image_path = self.goods_no_value["货号资料"][0].get("模特图",None)
         pp_jpg = self.getSpecialImage(
-            category="模特图", instead_category="正面", resize=pp_1.width / 2.1
+            path=image_path, instead_category="正面", resize=pp_1.width / 2.1
         )
         color_pic_list_1.append(pp_jpg)
         second_pp_jpg, _ = self.image_one_pic_no_shandow(
@@ -254,7 +258,8 @@ class DetailPicGet(DetailBase):
         pp_10 = PictureProcessing(r"{}\10.jpg".format(self.root))
         # 模特展示
         detailed_images.append(pp_10)
-        model_img = self.getSpecialImage(category="模特图", instead_category="正面", resize=pp_10.width)
+        image_path = self.goods_no_value["货号资料"][0].get("模特图",None)
+        model_img = self.getSpecialImage(path=image_path, instead_category="正面", resize=pp_10.width)
         detailed_images.append(model_img)
         pp_jpg, _ = self.image_one_pic_no_shandow(
             return_orign=True,

+ 13 - 8
python/custom_plugins/plugins/detail_template/clothing/detail_clothing2.py

@@ -101,16 +101,17 @@ class DetailPicGet(DetailBase):
         """   制作主图  """
         detailed_images = []
         pp_0 = PictureProcessing(r"{}\1.png".format(self.root))
-        bg_img = self.getSpecialImage(category="场景图", instead_category="正面",resize=pp_0.width)
+        image_path_scene = self.goods_no_value["货号资料"][0].get("场景图",None)
+        bg_img = self.getSpecialImage(path=image_path_scene, instead_category="正面",resize=pp_0.width)
         bg_img.paste_img(top_img=pp_0, base="nc", value=(0, 0))
         detailed_images.append(bg_img)
         return PictureProcessing(im=self.add_pic(detailed_images))
 
-    def getSpecialImage(self, category="模特图", instead_category="正面", resize=1200):
+    def getSpecialImage(self, path=None, instead_category="正面", resize=1200):
         """获取特殊图片"""
         goods_art_no_list = list(self.data.keys())
-        if self.get_text_value(category):
-            mote_img = PictureProcessing(self.get_text_value(category))
+        if path:
+            mote_img = PictureProcessing(path)
             mote_img = mote_img.resize(value=resize)
         else:
             pp_jpg, pp_png = self.image_one_pic_no_shandow(
@@ -129,8 +130,10 @@ class DetailPicGet(DetailBase):
         detailed_images = []
         # 尺码表
         pp_1 = PictureProcessing(r"{}\2.jpg".format(self.root))
+        image_path = self.goods_no_value["货号资料"][0].get("模特图",None)
+        image_path_scene = self.goods_no_value["货号资料"][0].get("场景图",None)
         bg_img = self.getSpecialImage(
-            category="模特图", instead_category="正面", resize=pp_1.width
+            path=image_path, instead_category="正面", resize=pp_1.width
         )
         right_top_img = bg_img.resize(value=pp_1.width)
         detail_2_bg = PictureProcessing(
@@ -139,7 +142,7 @@ class DetailPicGet(DetailBase):
         detail_2_bg.paste_img(top_img=right_top_img, base="cc", value=(0, 0))
         pp_1.paste_img(top_img=detail_2_bg, base="en", value=(30, 80))
         bg_img2 = self.getSpecialImage(
-            category="场景图", instead_category="背面", resize=pp_1.width
+            path=image_path_scene, instead_category="背面", resize=pp_1.width
         )
         left_bottom_img = bg_img2.resize(value=pp_1.width*1.3)
         detail_3_bg = PictureProcessing(
@@ -155,8 +158,9 @@ class DetailPicGet(DetailBase):
         detailed_images = []
         pp_1 = PictureProcessing(r"{}\3.jpg".format(self.root))
         # 细节展示
+        image_path = self.goods_no_value["货号资料"][0].get("模特图",None)
         pp_jpg = self.getSpecialImage(
-            category="模特图", instead_category="正面", resize=pp_1.width*1.5
+            path=image_path, instead_category="正面", resize=pp_1.width*1.5
         )
         detail_3_bg = PictureProcessing(
             "RGB", (pp_1.width - 100, pp_1.width - 100), (255, 255, 255)
@@ -264,8 +268,9 @@ class DetailPicGet(DetailBase):
         detailed_images = []
 
         pp_10 = PictureProcessing(r"{}\8.jpg".format(self.root))
+        image_path = self.goods_no_value["货号资料"][0].get("模特图",None)
         pp_jpg = self.getSpecialImage(
-            category="模特图", instead_category="正面", resize=pp_10.width * 1.5
+            path=image_path, instead_category="正面", resize=pp_10.width * 1.5
         )
         bg_img = PictureProcessing("RGB", (pp_10.width, pp_10.width), (255, 255, 255))
         bg_img = bg_img.paste_img(top_img=pp_jpg, base="nc", value=(0, -50))