0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Merge pull request #777 from kaedroho/willow

Added Willow support
This commit is contained in:
Karl Hobley 2015-01-15 11:03:32 +00:00
commit aa9e6ce7bf
4 changed files with 24 additions and 0 deletions

View File

@ -40,6 +40,7 @@ install_requires = [
"Unidecode>=0.04.14",
"six>=1.7.0",
'requests>=2.0.0',
"Willow==0.1",
]

View File

@ -17,6 +17,7 @@ base =
python-dateutil==2.2
pytz==2014.7
Embedly
Willow==0.1
coverage
dj17 =

View File

@ -4,6 +4,7 @@ import re
from six import BytesIO, text_type
from taggit.managers import TaggableManager
from willow.image import Image as WillowImage
from django.core.files import File
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
@ -80,6 +81,13 @@ class AbstractImage(models.Model, TagSearchable):
def __str__(self):
return self.title
def get_willow_image(self):
image_file = self.file.file
image_file.open('rb')
image_file.seek(0)
return WillowImage.open(image_file)
def get_rect(self):
return Rect(0, 0, self.width, self.height)

View File

@ -1,4 +1,5 @@
import unittest
from willow.image import Image as WillowImage
from django.test import TestCase
from django.core.urlresolvers import reverse
@ -268,6 +269,19 @@ class TestGetUsage(TestCase):
self.assertTrue(issubclass(Page, type(self.image.get_usage()[0])))
def TestGetWillowImage(TestCase):
def setUp(self):
self.image = Image.objects.create(
title="Test image",
file=get_test_image_file(),
)
def test_willow_image_object_returned(self):
willow_image = self.image.get_willow_image()
self.assertIsInstance(willow_image, WillowImage)
class TestIssue573(TestCase):
"""
This tests for a bug which causes filename limit on Renditions to be reached