Skip to content
Snippets Groups Projects
Commit 320b2c24 authored by Hugo Kerstens's avatar Hugo Kerstens
Browse files

Close wand image files after use

parent 225d5e4e
No related branches found
No related tags found
1 merge request!143Fix Wand memory leak
Pipeline #17613 passed
......@@ -170,6 +170,9 @@ def extract_images(filename):
yield img, pagenr+1
if wand_image is not None:
wand_image.close()
def extract_image_pypdf(pagenr, reader):
"""Extracts an image as an array from the designated page
......@@ -248,6 +251,8 @@ def extract_image_wand(pagenr, wand_image):
single_page.format = 'jpg'
img_array = np.asarray(bytearray(single_page.make_blob(format="jpg")), dtype=np.uint8)
img = Image.open(BytesIO(img_array))
img.load() # Load the data into the PIL image from the Wand image
single_page.close() # Then close the Wand image
return img
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment