diff options
| author | Stefanos I. Tsaklidis <ctefanos.t@gmail.com> | 2021-05-24 18:10:00 +0300 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-09-02 07:08:50 +0200 |
| commit | d0ea01af2814e276c4a090e599d5fd11c6ce4bf8 (patch) | |
| tree | 89df1d723513ed185eb19864081324c757eccb49 /django | |
| parent | c1d50b901b50672a46e7e5fe473c14da1616fc4e (diff) | |
Fixed #33079 -- Fixed get_image_dimensions() on nonexistent images.
Thanks Nick Pope for the review.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/files/images.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/django/core/files/images.py b/django/core/files/images.py index 579c32e11c..a1252f2c8b 100644 --- a/django/core/files/images.py +++ b/django/core/files/images.py @@ -44,7 +44,10 @@ def get_image_dimensions(file_or_path, close=False): file_pos = file.tell() file.seek(0) else: - file = open(file_or_path, 'rb') + try: + file = open(file_or_path, 'rb') + except OSError: + return (None, None) close = True try: # Most of the time Pillow only needs a small chunk to parse the image |
