From fcda64ca05eb0d6640adac20c910b93c29c490c3 Mon Sep 17 00:00:00 2001 From: Sanj Date: Tue, 5 Jul 2011 18:52:17 +0530 Subject: [PATCH] try to fix missing crops --- edgware/editor/models.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/edgware/editor/models.py b/edgware/editor/models.py index ed9e396..93376c0 100644 --- a/edgware/editor/models.py +++ b/edgware/editor/models.py @@ -673,6 +673,14 @@ class ImageBox(models.Model): ''' return str(self.file.file) + def do_crop(self, x1, y1, x2, y2, width, height): + tpl = (x1, y1, x2, y2,) + image_path = join(MEDIA_ROOT, self.original_print()) + cropped = Image.open(image_path).crop(tpl) + save_path = join(MEDIA_ROOT, self.cropped_path(), self.cropped_fname()) + cropped.save(save_path) + return self + def crop(self, x1, y1, x2, y2, width, height): original_image = Image.open(join(MEDIA_ROOT, self.actual_unresized())) original_width = original_image.size[0] @@ -731,7 +739,7 @@ class ImageBox(models.Model): try: f = open(path) except: - self.crop(self.crop_x1, self.crop_y1, self.crop_x2, self.crop_y2, self.width, self.height) + self.do_crop(self.crop_x1, self.crop_y1, self.crop_x2, self.crop_y2, self.width, self.height) f = open(path) size = str(int(self.width * m)) + "x" + str(int(self.height * m))