feat
fix design print防止png图片透明转黑 出现的bug,采用pil读图
This commit is contained in:
@@ -466,13 +466,11 @@ class PrintPainting(object):
|
|||||||
|
|
||||||
bucket_name = print_dict['print_path_list'][0].split("/", 1)[0]
|
bucket_name = print_dict['print_path_list'][0].split("/", 1)[0]
|
||||||
object_name = print_dict['print_path_list'][0].split("/", 1)[1]
|
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 则贴在一张纯白图片上 防止透明转黑
|
# 判断图片格式,如果是RGBA 则贴在一张纯白图片上 防止透明转黑
|
||||||
if image.shape[2] == 4:
|
if image.mode == "RGBA":
|
||||||
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGRA2RGBA)
|
new_background = Image.new('RGB', image.size, (255, 255, 255))
|
||||||
image_pil = Image.fromarray(image_rgb)
|
new_background.paste(image, mask=image.split()[3])
|
||||||
new_background = Image.new('RGB', image_pil.size, (255, 255, 255))
|
|
||||||
new_background.paste(image_pil, mask=image.split()[3])
|
|
||||||
image = new_background
|
image = new_background
|
||||||
print_dict['image'] = cv2.cvtColor(np.asarray(image), cv2.COLOR_RGB2BGR)
|
print_dict['image'] = cv2.cvtColor(np.asarray(image), cv2.COLOR_RGB2BGR)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user