summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-08-30 05:04:15 +0300
committerMaxim Devaev <[email protected]>2022-08-30 05:04:15 +0300
commit2459e3a25970dad0bf8eea709866dd31df4bcdd7 (patch)
tree10d08fe9a28a4db7e08674875ad21862e55b2471
parent170cee937da1bc9466c9fa56f4c9c7e7690c3100 (diff)
ocr: close old image on resizing
-rw-r--r--kvmd/apps/kvmd/tesseract.py5
1 files changed, 4 insertions, 1 deletions
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: