Package: wagtail-easy-thumbnails
A simple django app that allows you to useeasy_thumbnailswith the images fromWagtail,
including the focal point that you can define on images in Wagtail.This will allow you to use easy_thumbnail’s features that the thumbnailer in Wagtail
does not provide, such as JPEG quality control per image, forcing images to JPEG and
the powerful extension mechanism of custom processors.This is not a drop-in replacement for the wagtail image tag. Rather, you will need use
the normal easy_thumbnail tag in combination with a filter and a processor to work nicely
with wagtail images.Quick startInstallwagtail_easy_thumbnailsfrom Pypi:pip install wagtail_easy_thumbnailsAddwagtail_easy_thumbnailsto yourINSTALLED_APPSsetting like this:INSTALLED_APPS = (
    ...
    'wagtail_easy_thumbnails',
)Add the following filters to to yourEASYTHUMBNAIL_PROCESSORSsetting like this:THUMBNAIL_PROCESSORS = (
    # use this one instead of normal scale_and_crop
    'wagtail_easy_thumbnails.processors.wagtail_scale_and_crop_with_focal_area',
    # 'easy_thumbnails.processors.scale_and_crop',
    ... other processors
)Use in templates as follows:{% load thumbnail wagtail_thumbnail %}
<img src="{% thumbnail page.visual|wagtail_thumbnailer 300x100 crop zoom=100 %}" alt=""/>

<!--or-->

{% thumbnail page.visual|wagtail_thumbnailer 300x100 crop zoom=100 as cropped_image %}
<img src="{{ cropped_image.url }}"
     width="{{ cropped_image.width }}"
     height="{{ cropped_image.height }}"
     alt=""/>Use in code as follows:from easy_thumbnails.files import get_thumbnailer

...

properties = {
    'size': ...,
    'crop': True,
    'zoom': 100,
}
# image is the wagtail image (or subclass) instance
wrapped_image = WagtailThumbnailerImageFieldFile(wagtail_image=image)

# thumbnailer has the same properties as the template tag result, so .url, .width, etc.
thumnailer = get_thumbnailer(wrapped_image).get_thumbnail(properties)Thumbnail optionsThe following options can be used to create the thumbnails. Also see theEasy Thumbnails documentationfor all thumbnailing options.sizeis a required option, and defines the bounds that the generated image
must fit within. If one of either width or height is 0, the ratio of the original
image is used to determine the resulting width or height, respectively.Other options are only provided if the given functionality is required:croprequired to make the processor do anything. If not given, the normalscale_and_cropprocessor is used. Options for crop are not supported for this processor.zoom=<N>where N is an integer between 0 and 100 specifying how close to the focal area the image is cropped. Default is 0, meaning as close to the outer image boundaries as possible, 100 means as close to the focal area as possible.upscaleif given and the resulting image is smaller that the requested size, the image is upscaled.If the wagtail image does not have a focal area defined, the normalscale_and_cropprocessor
is used to generate the thumbnail.SettingsThe following settings can be set to override the defaults. Also see theEasy Thumbnails documentationfor all thumbnail settings.WAGTAIL_FOCAL_AREA_IMAGE_DEBUG: Defaults toFalse. If set toTrue, the focal area is drawn on the resulting image (useful for debugging).WAGTAIL_THUMBNAIL_ALWAYS_RECREATEDefaults toFalse. If set toTrue, the thumbnails are always regenerated, regardless of cached versions (useful for debugging)Changes0.3 (2017-11-27)Fixed division by zero error in exceptional situations (thanks to lucasmoeskops)0.2 (2017-03-15)Fixed github link in setup.py (thanks to reduxionist)Fixed a bug where too much zoom was applied when focal area was smaller than target sizeSome code cleanupLicenseThis software is released under the MIT License, see LICENSE.