def setUp(self): """ Instantiates the PILEngine, loads up a basic source image in an instance of PIL.Image. """ self.engine = PILEngine() self.trololo_path = get_test_images_path(image_filename='trololo.jpg') self.trololo_image = PIL.Image.open(self.trololo_path)
from pial.engines.pil_engine import PILEngine from validators import ImageUploadExtensionValidator try: #noinspection PyUnresolvedReferences from south.modelsinspector import add_introspection_rules add_introspection_rules([], ["^athumb\.fields\.ImageWithThumbsField"]) except ImportError: # Not using South, no big deal. pass # TODO: Make this configurable. # Thumbnailing is done through here. Eventually we can support image libraries # other than PIL. THUMBNAIL_ENGINE = PILEngine() # Cache URLs for thumbnails so we don't have to keep re-generating them. THUMBNAIL_URL_CACHE_TIME = getattr(settings, 'THUMBNAIL_URL_CACHE_TIME', 3600 * 24) # Optional cache-buster string to append to end of thumbnail URLs. MEDIA_CACHE_BUSTER = getattr(settings, 'MEDIA_CACHE_BUSTER', '') # Models want this instantiated ahead of time. IMAGE_EXTENSION_VALIDATOR = ImageUploadExtensionValidator() class ImageWithThumbsFieldFile(ImageFieldFile): """ Serves as the file-level storage object for thumbnails. """