Skip to content

Commit

Permalink
fix: reduce maximum image size
Browse files Browse the repository at this point in the history
- Decrease the maximum width and height from 9000 to 4500 pixels
- This change aims to prevent excessive resource usage when rendering PDFs
  • Loading branch information
Alapipapi committed Dec 2, 2024
1 parent 6b33d97 commit c5ef935
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions magic_pdf/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def fitz_doc_to_image(doc, dpi=200) -> dict:
mat = fitz.Matrix(dpi / 72, dpi / 72)
pm = doc.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 = doc.get_pixmap(matrix=fitz.Matrix(1, 1), alpha=False)

img = Image.frombytes('RGB', (pm.width, pm.height), pm.samples)
Expand Down

0 comments on commit c5ef935

Please sign in to comment.