Skip to content
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

Question about image verification #1408

Closed
AcidWeb opened this issue Sep 7, 2015 · 2 comments
Closed

Question about image verification #1408

AcidWeb opened this issue Sep 7, 2015 · 2 comments
Labels

Comments

@AcidWeb
Copy link

AcidWeb commented Sep 7, 2015

Is

img = Image.open(path)
img.verify()
img = Image.open(path)
img.load()

is enough to check if PNG/JPEG file is not corrupted and can be safely mangled ( :-) ) by Pillow?
Or above snippet still can pass some files that will fail later during various transformation.

@wiredfool
Copy link
Member

Image.Verify only checks the chunk checksums in png files, and is a no-op elsewhere.

Image.Load will read (some of) the pixel data, and at that point, you know that the image should be ok.

The exception is if you have a multiframe image, such as an animated GIF or multipage TIFF, then the data is only read on successive seeks.

Until the all the data is read, there's still a chance that something will go wrong.

@AcidWeb
Copy link
Author

AcidWeb commented Sep 9, 2015

OK. Thank you.

@AcidWeb AcidWeb closed this as completed Sep 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants