diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 5586d45cf4..cba02ef073 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -28,6 +28,7 @@ Changelog * Add blog about image uploads in Wagtail forms to third party tutorial documentation (a-mere-peasant) * Clean up multiple minor documentation issues (David T Thompson, ryanomor, kailwallin) * Add AbstractUser import to custom user model documentation (LB (Ben Johnston)) + * `WAGTAILIMAGES_MAX_IMAGE_PIXELS` limit now takes the number of animation frames into account (Karl Hobley) * Fix: Added line breaks to long filenames on multiple image / document uploader (Kevin Howbrook) * Fix: Added https support for Scribd oEmbed provider (Rodrigo) * Fix: Changed StreamField group labels color so labels are visible (Catherine Farman) diff --git a/docs/advanced_topics/settings.rst b/docs/advanced_topics/settings.rst index 441c824cdc..3c35a16e9b 100644 --- a/docs/advanced_topics/settings.rst +++ b/docs/advanced_topics/settings.rst @@ -268,7 +268,7 @@ This setting lets you override the maximum upload size for images (in bytes). If WAGTAILIMAGES_MAX_IMAGE_PIXELS = 128000000 # i.e. 128 megapixels -This setting lets you override the maximum number of pixels an image can have. If omitted, Wagtail will fall back to using its 128 megapixels default value. +This setting lets you override the maximum number of pixels an image can have. If omitted, Wagtail will fall back to using its 128 megapixels default value. The pixel count takes animation frames into account - for example, a 25-frame animation of size 100x100 is considered to have 100 * 100 * 25 = 250000 pixels. .. code-block:: python diff --git a/docs/releases/2.7.rst b/docs/releases/2.7.rst index 0f6926b112..1b6a6d2de6 100644 --- a/docs/releases/2.7.rst +++ b/docs/releases/2.7.rst @@ -47,6 +47,7 @@ Other features * Add blog about image uploads in Wagtail forms to third party tutorial documentation (a-mere-peasant) * Clean up multiple minor documentation issues (David T Thompson, ryanomor, kailwallin) * Add AbstractUser import to custom user model documentation (LB (Ben Johnston)) + * ``WAGTAILIMAGES_MAX_IMAGE_PIXELS`` limit now takes the number of animation frames into account (Karl Hobley) Bug fixes diff --git a/setup.py b/setup.py index 8dd8571826..0b407c4589 100755 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ install_requires = [ "beautifulsoup4>=4.5.1,<4.6.1", "html5lib>=0.999,<2", "Unidecode>=0.04.14,<2.0", - "Willow>=1.1,<1.2", + "Willow>=1.3,<1.4", "requests>=2.11.1,<3.0", "pytz>=2016.6", # for l18n "six>=1.11,<2.0", # for l18n diff --git a/wagtail/images/fields.py b/wagtail/images/fields.py index 1873e9d85e..e9492567f1 100644 --- a/wagtail/images/fields.py +++ b/wagtail/images/fields.py @@ -1,8 +1,8 @@ import os +import willow from django.conf import settings from django.core.exceptions import ValidationError -from django.core.files.images import get_image_dimensions from django.forms.fields import ImageField from django.template.defaultfilters import filesizeformat from django.utils.translation import ugettext_lazy as _ @@ -95,14 +95,14 @@ class WagtailImageField(ImageField): return # Check the pixel size - dimensions = get_image_dimensions(f) - if dimensions == (None, None): - return + image = willow.Image.open(f) + width, height = image.get_size() + frames = image.get_frame_count() + num_pixels = width * height * frames - pixel_size = dimensions[0] * dimensions[1] - if pixel_size > self.max_image_pixels: + if num_pixels > self.max_image_pixels: raise ValidationError(self.error_messages['file_too_many_pixels'] % ( - pixel_size + num_pixels ), code='file_too_many_pixels') def to_python(self, data):