-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Handle truncated chunks at the end of PNG images #7709
Conversation
If you're interested in an immediate solution as an alternative to this PR, I find that you can just ignore the error and the image works fine. from PIL import Image
im = Image.open('in.png')
try:
im.load()
except OSError:
pass
im.save("out.png") |
I'm amazed by your quick response. Indeed, loading images by ignoring load exceptions can be a way to load and convert images into a normal state. Thank you for your suggestion. Are there any other suggested modifications for this pull request? |
The test image that you've added is 721kb - this is a bit large. Here's a test image I've created by modifying hopper_idat_after_image_end.png - it is only 30kb. |
@radarhere The comments have all been fixed. |
Do I need to perform any additional actions for this PR to be merged? @radarhere |
I've just combined the commits in this PR into one so that your original image isn't part of the commit history. |
d306d20
to
98dc9ac
Compare
for more information, see https://pre-commit.ci
Test error is raised without LOAD_TRUNCATED_IMAGES
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
Fix png image plugin load_end func handle truncated file.
When attempting to process PNG image files that are incomplete at the end, the current LOAD_TRUNCATED_IMAGES parameter is unable to handle such cases. It is necessary to add corresponding handling code within the load_end function to ensure proper processing of incomplete images. Below is a link to an example of such an anomalous image:
Changes proposed in this pull request:
cc @radarhere Can you help me with a code review? thanks a lot.