Processors now use static properties.

This commit is contained in:
Matthew Tretter 2011-09-08 16:49:44 -04:00
parent db4d704f71
commit a1f11facbe
2 changed files with 20 additions and 12 deletions

View file

@ -3,12 +3,11 @@
from imagekit.specs import ImageSpec
from imagekit import processors
class ResizeThumbnail(processors.Resize):
class ResizeThumbnail(processors.Crop):
width = 100
height = 50
crop = True
class EnhanceSmall(processors.Adjustment):
class EnhanceSmall(processors.Adjust):
contrast = 1.2
sharpness = 1.1

View file

@ -87,11 +87,20 @@ class Reflection(ImageProcessor):
class _Resize(ImageProcessor):
def __init__(self, width, height, crop=False, upscale=False):
self.width = width
self.height = height
self.crop = crop
self.upscale = upscale
width = None
height = None
crop = False
upscale = False
def __init__(self, width=None, height=None, crop=None, upscale=None):
if width is not None:
self.width = width
if height is not None:
self.height = height
if crop is not None:
self.crop = crop
if upscale is not None:
self.upscale = upscale
def process(self, img, fmt, obj):
cur_width, cur_height = img.size
@ -134,13 +143,13 @@ class _Resize(ImageProcessor):
class Crop(_Resize):
def __init__(self, width, height):
super(Crop, self).__init__(width, height, True)
def __init__(self, width=None, height=None):
super(Crop, self).__init__(width, height, crop=True)
class Fit(_Resize):
def __init__(self, width, height, upscale=False):
super(Fit, self).__init__(width, height, False, upscale)
def __init__(self, width=None, height=None, upscale=None):
super(Fit, self).__init__(width, height, crop=False, upscale=upscale)
class Transpose(ImageProcessor):