|
|
@@ -11,7 +11,7 @@ from functools import wraps
|
|
|
from .multi_threaded_image_saving import ImageSaver
|
|
|
from .get_mask_by_green import GetMask
|
|
|
from middleware import UnicornException
|
|
|
-
|
|
|
+from logger import logger
|
|
|
def time_it(func):
|
|
|
@wraps(func) # 使用wraps来保留原始函数的元数据信息
|
|
|
def wrapper(*args, **kwargs):
|
|
|
@@ -474,7 +474,6 @@ class GeneratePic(object):
|
|
|
_s = time.time()
|
|
|
orign_im = Image.open(image_path) # 原始图
|
|
|
print("242 need_time_1:{}".format(time.time() - _s))
|
|
|
-
|
|
|
orign_x, orign_y = orign_im.size
|
|
|
cut_image = Image.open(cut_image_path) # 原始图的已扣图
|
|
|
cut_image, new_box = get_mini_crop_img(img=cut_image)
|
|
|
@@ -738,7 +737,17 @@ class GeneratePic(object):
|
|
|
_format=new_format,
|
|
|
)
|
|
|
# image_bg.save(out_path)
|
|
|
-
|
|
|
+ # 在函数结束时使用更安全的关闭方式
|
|
|
+ try:
|
|
|
+ if 'orign_im' in locals() and orign_im:
|
|
|
+ orign_im.close()
|
|
|
+ if 'cut_image' in locals() and cut_image:
|
|
|
+ cut_image.close()
|
|
|
+ if 'logo_im' in locals() and logo_im:
|
|
|
+ logo_im.close()
|
|
|
+ except Exception as e:
|
|
|
+ logger.info(f"阴影处理关闭图片对象失败:{str(e)}")
|
|
|
+ print(f"Error closing images: {e}")
|
|
|
if output_queue is not None:
|
|
|
output_queue.put(True)
|
|
|
return True
|