|
|
@@ -174,6 +174,7 @@ class GeneratePic(object):
|
|
|
bg_mask = bg_mask.resize(im_png.size)
|
|
|
# bg_mask = expand_or_shrink_mask(pil_image=bg_mask, expansion_radius=6, blur_radius=0)
|
|
|
else:
|
|
|
+ bg_mask = False
|
|
|
bg_mask = Image.new("RGB", im_png.size, (255, 255, 255))
|
|
|
bg_mask = bg_mask.convert("L")
|
|
|
|
|
|
@@ -699,16 +700,11 @@ class GeneratePic(object):
|
|
|
rgb_color = settings.hex_to_rgb(color_800image)
|
|
|
# ==========先进行剪切原图
|
|
|
_s = time.time()
|
|
|
- with Image.open(image_path) as orign_im:
|
|
|
- # 复制图像以便后续操作
|
|
|
- orign_im = orign_im.copy()
|
|
|
+ orign_im = Image.open(image_path)
|
|
|
print("242 need_time_1:{}".format(time.time() - _s))
|
|
|
orign_x, orign_y = orign_im.size
|
|
|
- with Image.open(cut_image_path) as cut_image:
|
|
|
- # 复制图像以便后续操作
|
|
|
- cut_image = cut_image.copy()
|
|
|
- cut_image_basic = cut_image.copy()
|
|
|
- cut_image, new_box = get_mini_crop_img(img=cut_image)
|
|
|
+ orign_im_cut = Image.open(cut_image_path) # 原始图的已扣图
|
|
|
+ cut_image, new_box = get_mini_crop_img(img=orign_im_cut)
|
|
|
im_shadow = orign_im.crop(new_box) # 切图
|
|
|
new_x, new_y = im_shadow.size
|
|
|
|
|
|
@@ -729,6 +725,7 @@ class GeneratePic(object):
|
|
|
grenerate_main_pic_brightness=image_mask_grenerate_main_pic_brightness)
|
|
|
elif image_mask_mode == 2:
|
|
|
shadow_mask, config = self.get_mask_and_config_v4_online(ori_im_jpg=orign_im,
|
|
|
+ ori_im_png=orign_im_cut,
|
|
|
im_jpg=im_shadow,
|
|
|
im_png=cut_image)
|
|
|
else:
|