From b3644157e7f9d32c8ee2b794361fd87301acbc46 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 26 Nov 2024 22:35:35 +0800 Subject: [PATCH] perf(image_processing): reduce maximum image size for analysis - Decrease the maximum image size threshold from 9000 to 4500 pixels - This change aims to improve performance and reduce memory usage - Affects the custom model document analysis process --- magic_pdf/model/doc_analyze_by_custom_model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/magic_pdf/model/doc_analyze_by_custom_model.py b/magic_pdf/model/doc_analyze_by_custom_model.py index d3784bad..a3536a3b 100644 --- a/magic_pdf/model/doc_analyze_by_custom_model.py +++ b/magic_pdf/model/doc_analyze_by_custom_model.py @@ -46,8 +46,8 @@ def load_images_from_pdf(pdf_bytes: bytes, dpi=200, start_page_id=0, end_page_id mat = fitz.Matrix(dpi / 72, dpi / 72) pm = page.get_pixmap(matrix=mat, alpha=False) - # If the width or height exceeds 9000 after scaling, do not scale further. - if pm.width > 9000 or pm.height > 9000: + # If the width or height exceeds 4500 after scaling, do not scale further. + if pm.width > 4500 or pm.height > 4500: pm = page.get_pixmap(matrix=fitz.Matrix(1, 1), alpha=False) img = Image.frombytes("RGB", (pm.width, pm.height), pm.samples)