1👍
If you read the code. You’ll see that get_image_dimensions
reads a chunk from the file and tries to parse it into an image with PIL. If it fails, it increases the chunksize and repeats. (Increasing the chunksize is to read the whole file in less reads than (filesize/initial chunksize) times. Fileformats like TIFF need to read the while file.)
Returning None
may happen in 3 cases.
- An empty file. And the first chunk read is empty.
- After reading the whole file, PIL can still not parse it into a file. Is your file complete? Is it an image?
- If Pillow sets the size to
None
. Try using PIL directly on you machine and see it can parse your file.
Source:stackexchange.com