There was an error while loading. Please reload this page.
1 parent 94e91f7 commit da33d67Copy full SHA for da33d67
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