From 42cc2e1c519840dcf6c541ab0e1576607fd13841 Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Mon, 24 Jun 2024 15:25:32 +0800 Subject: [PATCH] =?UTF-8?q?feat=20fix=20=20design=20print=E9=98=B2?= =?UTF-8?q?=E6=AD=A2png=E5=9B=BE=E7=89=87=E9=80=8F=E6=98=8E=E8=BD=AC?= =?UTF-8?q?=E9=BB=91=20=E5=87=BA=E7=8E=B0=E7=9A=84bug,=E9=87=87=E7=94=A8pi?= =?UTF-8?q?l=E8=AF=BB=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/design/items/pipelines/painting.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/service/design/items/pipelines/painting.py b/app/service/design/items/pipelines/painting.py index eaeafa3..dc5bd9b 100644 --- a/app/service/design/items/pipelines/painting.py +++ b/app/service/design/items/pipelines/painting.py @@ -466,13 +466,11 @@ class PrintPainting(object): bucket_name = print_dict['print_path_list'][0].split("/", 1)[0] object_name = print_dict['print_path_list'][0].split("/", 1)[1] - image = oss_get_image(bucket=bucket_name, object_name=object_name, data_type="cv2") + image = oss_get_image(bucket=bucket_name, object_name=object_name, data_type="PIL") # 判断图片格式,如果是RGBA 则贴在一张纯白图片上 防止透明转黑 - if image.shape[2] == 4: - image_rgb = cv2.cvtColor(image, cv2.COLOR_BGRA2RGBA) - image_pil = Image.fromarray(image_rgb) - new_background = Image.new('RGB', image_pil.size, (255, 255, 255)) - new_background.paste(image_pil, mask=image.split()[3]) + if image.mode == "RGBA": + new_background = Image.new('RGB', image.size, (255, 255, 255)) + new_background.paste(image, mask=image.split()[3]) image = new_background print_dict['image'] = cv2.cvtColor(np.asarray(image), cv2.COLOR_RGB2BGR)