From 47ea3e6fc31656cc03903172d050b87ea2eb3177 Mon Sep 17 00:00:00 2001 From: Sanj Date: Wed, 6 Jul 2011 20:17:04 +0530 Subject: [PATCH] cropping wtf --- edgware/editor/models.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/edgware/editor/models.py b/edgware/editor/models.py index 1a4cdd4..ced1c86 100644 --- a/edgware/editor/models.py +++ b/edgware/editor/models.py @@ -735,20 +735,20 @@ class ImageBox(models.Model): current_height = self.height divisor = original_width / (current_width + .0) if self.is_cropped == False: - self.crop_x1 = int(x1 * divisor) - self.crop_y1 = int(y1 * divisor) - self.crop_x2 = int(x2 * divisor) - self.crop_y2 = int(y2 * divisor) + self.crop_x1 = int(round(x1 * divisor)) + self.crop_y1 = int(round(y1 * divisor)) + self.crop_x2 = int(round(x2 * divisor)) + self.crop_y2 = int(round(y2 * divisor)) self.is_cropped = True else: old_x1 = self.crop_x1 old_y1 = self.crop_y1 old_x2 = self.crop_x2 old_y2 = self.crop_y2 - self.crop_x1 = int(x1 * divisor) + old_x1 - self.crop_y1 = int(y1 * divisor) + old_y1 - self.crop_x2 = int(x2 * divisor) + old_x1 - self.crop_y2 = int(y2 * divisor) + old_y1 + self.crop_x1 = int(round(x1 * divisor)) + old_x1 + self.crop_y1 = int(round(y1 * divisor)) + old_y1 + self.crop_x2 = int(round(x2 * divisor)) + old_x1 + self.crop_y2 = int(round(y2 * divisor)) + old_y1 self.width = width self.height = height self.save() @@ -788,7 +788,7 @@ class ImageBox(models.Model): 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)) + size = str(int(round(self.width * m))) + "x" + str(int(round(self.height * m))) im = get_thumbnail(f, size, crop='center', quality=99) ''' context = {