rambo 7 ماه پیش
والد
کامیت
456941794a
1فایلهای تغییر یافته به همراه18 افزوده شده و 9 حذف شده
  1. 18 9
      python/service/OnePicTest.py

+ 18 - 9
python/service/OnePicTest.py

@@ -63,15 +63,21 @@ class OnePicTest():
         main_out_path = r"{}\temp\pic_test\{}-主图.jpg".format(
             os.getcwd(), os.path.splitext(file)[0]
         )
-        GeneratePic().run(
-            image_path=image_path,
-            cut_image_path=cut_image_path,
-            out_path=main_out_path,
-            image_deal_mode=1,
-            resize_mode=1,
-            out_pic_size=1024,
-            is_logo=False,
-        )
+        print("image_path", image_path)
+        print("cut_image_path", cut_image_path)
+        print("main_out_path", main_out_path)
+        try:
+            GeneratePic().run(
+                image_path=image_path,
+                cut_image_path=cut_image_path,
+                out_path=main_out_path,
+                image_deal_mode=1,
+                resize_mode=1,
+                out_pic_size=1024,
+                is_logo=False,
+            )
+        except:
+            raise UnicornException("处理失败,请重试")
 
         # return_data["code"] = 0
         # return_data["data"]["image_path"] = image_path
@@ -83,6 +89,9 @@ class OnePicTest():
         # 先做整体校验
         if not os.path.exists(self.pic_path):
             raise UnicornException("图片不存在")
+        image_pth = Image.open(self.pic_path)
+        if image_pth.mode != "RGB":
+            raise UnicornException("抠图图片不能是PNG")
         return_data = self.deal_image(self.pic_path)
         # if return_data["message"]:
         #     raise UnicornException(return_data["message"])