From 88798d9c9b76c07d45bfb87c303e241ed5bec78f Mon Sep 17 00:00:00 2001 From: turly221 Date: Fri, 6 Dec 2024 18:57:15 +0000 Subject: [PATCH] commit patch 28268844 --- django/core/files/images.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/django/core/files/images.py b/django/core/files/images.py index 228a7118c51a..7d7eac65db93 100644 --- a/django/core/files/images.py +++ b/django/core/files/images.py @@ -47,13 +47,18 @@ def get_image_dimensions(file_or_path, close=False): file = open(file_or_path, 'rb') close = True try: + # Most of the time PIL only needs a small chunk to parse the image and + # get the dimensions, but with some TIFF files PIL needs to parse the + # whole file. + chunk_size = 1024 while 1: - data = file.read(1024) + data = file.read(chunk_size) if not data: break p.feed(data) if p.image: return p.image.size + chunk_size = chunk_size*2 return None finally: if close: