mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-09 18:39:04 +08:00
Fix: [ALAS] close pillow Image object
This commit is contained in:
parent
3b65dfe6f0
commit
25c81f08f4
@ -530,13 +530,17 @@ def load_image(file, area=None):
|
|||||||
Returns:
|
Returns:
|
||||||
np.ndarray:
|
np.ndarray:
|
||||||
"""
|
"""
|
||||||
image = Image.open(file)
|
# always remember to close Image object
|
||||||
if area is not None:
|
with Image.open(file) as f:
|
||||||
image = image.crop(area)
|
if area is not None:
|
||||||
image = np.array(image)
|
f = f.crop(area)
|
||||||
channel = image.shape[2] if len(image.shape) > 2 else 1
|
|
||||||
if channel > 3:
|
image = np.array(f)
|
||||||
image = image[:, :, :3].copy()
|
|
||||||
|
channel = image_channel(image)
|
||||||
|
if channel == 4:
|
||||||
|
image = cv2.cvtColor(image, cv2.COLOR_RGBA2RGB)
|
||||||
|
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user