This is a first version of Wagtail wit support for image processing
backends. A first refactoring of image processing code has been done,
moving the image processing code to the wagtailimages/backends package and
changing models.py (more specifically, the process_image method of Filter
model) to use the code there.
The backends package contains the __init__.py module which defines the
get_image_backend method that will get the correct image backend based on
the passe parameer (or default if not parameer is passed) and the
WAGTAILIMAGES_BACKENDS option. The code is copie with small modifications
from similar code in wagtailsearch/backends package.
Concerning the backends, a BaseImageBackend is defined in the base module.
This interface defines a number of methods that the backends inheriting
from it should implement. The only methods that need to be implemented is
open_image, save_image, resize and crop_to_centre. The other methods are
more or less the same (if the image object provides a size attribute).
The two backends, wand_backend and pillow_backend provide implementations
for Pillow and Wand. Both seem to be working but Wand needs some more
testing.
To be able to wand, we have to install Wand + ImageMagick. Follow the
instructions here: http://docs.wand-py.org/en/0.3.5/guide/install.html.
Things to do next:
a. Check again the API that BaseImageBackend exposes -- it's not very
intuitive and some things should be more DRY
b. Find out a method of choosing the backend from the outside world - we
may have an Image class that we want to render with Wand and another class
that we want to render with Pillow.
c. Assert that crop_to_centre method works fine also.
d. Check resize filters of Wand (Imagemagick)
e. Make tests pass with both Pillow and Wand backends
Image filenames containing non ascii characters would be translated to a
series of underscores (____.png). To fix this, we use the unidecoe library
(which we also add to the required packages for Wagtail) which translates
each unicode character to an ascii equivalent.
For more info on how unidecode works please check @Evgeny's answer at this
question:
http://stackoverflow.com/questions/702337/how-to-make-django-slugify-work-properly-with-unicode-strings
Addresses the "ForeignKey null=False" issue; new instances were throwing an exception, which prevented the edit handler from rendering the proper JavaScript in _editor_js.html.