-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Piximap program crash #3848
Comments
Please do provide reproducing file and code. |
case.pdf from pymupdf.utils import get_pixmap, get_page_pixmap on page 2 of 4. |
This script works: import pymupdf
doc = pymupdf.open("case.pdf")
page = doc[1]
paths = page.get_drawings()
for i, p in enumerate(paths):
rect = p["rect"] # best check for emptiness already here!
text = page.get_textbox(rect)
if text:
pix = page.get_pixmap(clip=rect)
if pymupdf.IRect(pix.irect).is_empty:
print(i, "pixmap has empty area - skipping")
continue
print("path", i, pix.color_topusage()) So the reason for the crash is a pixmap that covers no area, and the Otherwise please take note of the following comments:
|
Description of the bug
What is happening is that when I read from the PDF, I use the rectangle information to collect color data. Recently, however, I encountered an issue with one of the PDF collections: while collecting the color information, the program crashes unexpectedly without any error messages. I traced the problem to the color_topusage function. Specifically, the error appears to originate from the call to this function, where the issue seems to be related to color_count -> JM_color_count -> oldpix = read_sample(pm, s, n).
How to reproduce the bug
I traced the problem to the color_topusage function. Specifically, the error appears to originate from the call to this function, where the issue seems to be related to color_count -> JM_color_count -> oldpix = read_sample(pm, s, n).
PyMuPDF version
1.24.10
Operating system
Windows
Python version
3.12
The text was updated successfully, but these errors were encountered: