diff --git a/django/forms/fields.py b/django/forms/fields.py
index 4668ead..2798341 100644
a
|
b
|
class ImageField(FileField):
|
559 | 559 | # load() is the only method that can spot a truncated JPEG, |
560 | 560 | # but it cannot be called sanely after verify() |
561 | 561 | trial_image = Image.open(file) |
| 562 | |
| 563 | MAX_DIMENSIONS = (5000, 5000) |
| 564 | dimensions = trial_image.size |
| 565 | if dimensions[0] > MAX_DIMENSIONS[0] or dimensions[1] > MAX_DIMENSIONS[1]: |
| 566 | raise ValidationError('Maximum image dimensions are %sx%s px. This file is %sx%s px' % (MAX_DIMENSIONS + dimensions)) |
| 567 | |
562 | 568 | trial_image.load() |
563 | 569 | |
564 | 570 | # Since we're about to use the file again we have to reset the |
… |
… |
class ImageField(FileField):
|
575 | 581 | # _imaging C module isn't available, so an ImportError will be |
576 | 582 | # raised. Catch and re-raise. |
577 | 583 | raise |
| 584 | except ValidationError: |
| 585 | # any validation errors are re-raised as is |
| 586 | raise |
578 | 587 | except Exception: # Python Imaging Library doesn't recognize it as an image |
579 | 588 | raise ValidationError(self.error_messages['invalid_image']) |
580 | 589 | if hasattr(f, 'seek') and callable(f.seek): |