+6
-1
lines changedFilter options
+6
-1
lines changed Original file line number Diff line number Diff line change
@@ -47,13 +47,18 @@ def get_image_dimensions(file_or_path, close=False):
47
47
file = open(file_or_path, 'rb')
48
48
close = True
49
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
50
54
while 1:
51
-
data = file.read(1024)
55
+
data = file.read(chunk_size)
52
56
if not data:
53
57
break
54
58
p.feed(data)
55
59
if p.image:
56
60
return p.image.size
61
+
chunk_size = chunk_size*2
57
62
return None
58
63
finally:
59
64
if close:
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4