From 51212749e9759b1237fd5c5238fdf96c42085bc0 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Sat, 11 Feb 2012 15:28:47 -0500 Subject: [PATCH] Improve `BasicCrop` API as discussed in #94 --- imagekit/processors/crop.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/imagekit/processors/crop.py b/imagekit/processors/crop.py index b27ea90..c812f9e 100644 --- a/imagekit/processors/crop.py +++ b/imagekit/processors/crop.py @@ -75,16 +75,15 @@ class BasicCrop(object): """Crops an image to the specified rectangular region. """ - def __init__(self, left, top, right, bottom): - self.left = left - self.top = top - self.right = right - self.bottom = bottom + def __init__(self, x, y, width, height): + self.x = x + self.y = y + self.width = width + self.height = height def process(self, img): - box = (self.left, self.top, self.right, self.bottom) - img = img.crop(box) - return img + box = (self.x, self.y, self.x + self.width, self.y + self.height) + return img.crop(box) class Crop(object):