-
Notifications
You must be signed in to change notification settings - Fork 685
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
Visual debugging raise ValueError: Decompressed Data Too Large #413
Comments
Hi @holytony Appreciate your interest in the library. Can you try modifying the memory values in the file at <policymap>
<policy domain="resource" name="memory" value="256MiB"/>
<policy domain="resource" name="map" value="512MiB"/>
<policy domain="resource" name="width" value="16KP"/>
<policy domain="resource" name="height" value="16KP"/>
<policy domain="resource" name="area" value="128MB"/>
<policy domain="resource" name="disk" value="1GiB"/> I also found this StackOverflow question that might be helpful. |
this is the policy.xml I got on my imagemagick 7
|
I tried replicating the issue on my machine but couldn't using the code you provided and the PDF. Did you try the answers provided at https://stackoverflow.com/q/42671252/7760998? |
nah, unfortunately not working |
I found myself in a similar situation, and this worked for me: from PIL import PngImagePlugin
LARGE_ENOUGH_NUMBER = 100
PngImagePlugin.MAX_TEXT_CHUNK = LARGE_ENOUGH_NUMBER * (1024**2) |
Update — this more reliably fixes things for me: from PIL import Image
Image.MAX_IMAGE_PIXELS = 1000000000 # Or sufficiently large number Will be adding a |
Describe the bug
While trying to using the visual debugging tool in pdf plumber, the module had issue converting certain pdf file to PageImage obj, raise ValueError: Decompressed Data Too Large, which seems to be caused by issue with Pillow module
By the way, here is pdf file I was dealing with
pdf_file_link
Interestingly enough, if I drag the several pages from the original pdf to make a new pdf using the Preview App on Mac , problem gone, everything works fine, even after I have set the resolution to very high value (500), it would still run smoothly.
Just for the sake of testing the limit of systems, after setting the resolution to 1500, I did manage to raise a DecompressionBombError.
PIL.Image.DecompressionBombError: Image size (217518678 pixels) exceeds limit of 178956970 pixels, could be decompression bomb DOS attack.
so, to summarize,
while using .to_image
original file-> ValueError: Decompressed Data Too Large
dragged_pages_using_Preview-> No problem what so ever
original file + super high resolution(1500)-> DecompressionBombError
dragged_pages_using_Preview+super high resolution(1500)->DecompressionBombError
something magical with the original file?
pdf_file_link
Code to reproduce the problem
Actual behavior
Traceback (most recent call last):
File "/Users/Tc/PycharmProjects/plumber_test_3/pdf_visual_debugging.py", line 188, in
visualize(‘test_page.pdf')
File "/Users/Tc/PycharmProjects/plumber_test_3/pdf_visual_debugging.py", line 172, in visualize
im = page.to_image(resolution=72)
File "/Users/Tc/PycharmProjects/plumber_test_3/lib/python3.8/site-packages/pdfplumber/page.py", line 299, in to_image
return PageImage(self, **kwargs)
File "/Users/Tc/PycharmProjects/plumber_test_3/lib/python3.8/site-packages/pdfplumber/display.py", line 53, in init
self.original = get_page_image(
File "/Users/Tc/PycharmProjects/plumber_test_3/lib/python3.8/site-packages/pdfplumber/display.py", line 45, in get_page_image
im = PIL.Image.open(BytesIO(png.make_blob()))
File "/Users/Tc/PycharmProjects/plumber_test_3/lib/python3.8/site-packages/PIL/Image.py", line 2944, in open
im = _open_core(fp, filename, prefix, formats)
File "/Users/Tc/PycharmProjects/plumber_test_3/lib/python3.8/site-packages/PIL/Image.py", line 2930, in _open_core
im = factory(fp, filename)
File "/Users/Tc/PycharmProjects/plumber_test_3/lib/python3.8/site-packages/PIL/ImageFile.py", line 121, in init
self._open()
File "/Users/Tc/PycharmProjects/plumber_test_3/lib/python3.8/site-packages/PIL/PngImagePlugin.py", line 694, in open
s = self.png.call(cid, pos, length)
File "/Users/Tc/PycharmProjects/plumber_test_3/lib/python3.8/site-packages/PIL/PngImagePlugin.py", line 187, in call
return getattr(self, "chunk" + cid.decode("ascii"))(pos, length)
File "/Users/Tc/PycharmProjects/plumber_test_3/lib/python3.8/site-packages/PIL/PngImagePlugin.py", line 545, in chunk_zTXt
v = _safe_zlib_decompress(v[1:])
File "/Users/Tc/PycharmProjects/plumber_test_3/lib/python3.8/site-packages/PIL/PngImagePlugin.py", line 133, in _safe_zlib_decompress
raise ValueError("Decompressed Data Too Large")
ValueError: Decompressed Data Too Large
Screenshots
If applicable, add screenshots to help explain your problem.
Environment
Additional context
Add any other context/notes about the problem here.
The text was updated successfully, but these errors were encountered: