From 2459e3a25970dad0bf8eea709866dd31df4bcdd7 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Tue, 30 Aug 2022 05:04:15 +0300 Subject: ocr: close old image on resizing --- kvmd/apps/kvmd/tesseract.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kvmd/apps/kvmd/tesseract.py b/kvmd/apps/kvmd/tesseract.py index a5292439..58cba9ae 100644 --- a/kvmd/apps/kvmd/tesseract.py +++ b/kvmd/apps/kvmd/tesseract.py @@ -151,7 +151,10 @@ class TesseractOcr: image = image_cropped ImageOps.grayscale(image) - image=image.resize((int(image.size[0]*2),int(image.size[1]*2)), PilImage.BICUBIC) + image_resized = image.resize((int(image.size[0] * 2), int(image.size[1] * 2)), PilImage.BICUBIC) + image.close() + image = image_resized + _libtess.TessBaseAPISetImage(api, image.tobytes("raw", "RGB"), image.width, image.height, 3, image.width * 3) text_ptr = None try: -- cgit v1.2.3