kopia lustrzana https://github.com/wagtail/wagtail
[5225] Take number of frames into account when limiting image size
rodzic
3d5f55d731
commit
b4ecead6d9
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
2
setup.py
2
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
|
||||
|
|
|
@ -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):
|
||||
|
|
Ładowanie…
Reference in New Issue