Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7ca10b1 commit 9ca0ff6Copy full SHA for 9ca0ff6
django/core/files/images.py
@@ -47,13 +47,18 @@ def get_image_dimensions(file_or_path, close=False):
47
file = open(file_or_path, 'rb')
48
close = True
49
try:
50
+ # Most of the time PIL only needs a small chunk to parse the image and
51
+ # get the dimensions, but with some TIFF files PIL needs to parse the
52
+ # whole file.
53
+ chunk_size = 1024
54
while 1:
- data = file.read(1024)
55
+ data = file.read(chunk_size)
56
if not data:
57
break
58
p.feed(data)
59
if p.image:
60
return p.image.size
61
+ chunk_size = chunk_size*2
62
return None
63
finally:
64
if close:
0 commit comments