cropping wtf
This commit is contained in:
parent
60a2509e24
commit
47ea3e6fc3
|
@ -735,20 +735,20 @@ class ImageBox(models.Model):
|
||||||
current_height = self.height
|
current_height = self.height
|
||||||
divisor = original_width / (current_width + .0)
|
divisor = original_width / (current_width + .0)
|
||||||
if self.is_cropped == False:
|
if self.is_cropped == False:
|
||||||
self.crop_x1 = int(x1 * divisor)
|
self.crop_x1 = int(round(x1 * divisor))
|
||||||
self.crop_y1 = int(y1 * divisor)
|
self.crop_y1 = int(round(y1 * divisor))
|
||||||
self.crop_x2 = int(x2 * divisor)
|
self.crop_x2 = int(round(x2 * divisor))
|
||||||
self.crop_y2 = int(y2 * divisor)
|
self.crop_y2 = int(round(y2 * divisor))
|
||||||
self.is_cropped = True
|
self.is_cropped = True
|
||||||
else:
|
else:
|
||||||
old_x1 = self.crop_x1
|
old_x1 = self.crop_x1
|
||||||
old_y1 = self.crop_y1
|
old_y1 = self.crop_y1
|
||||||
old_x2 = self.crop_x2
|
old_x2 = self.crop_x2
|
||||||
old_y2 = self.crop_y2
|
old_y2 = self.crop_y2
|
||||||
self.crop_x1 = int(x1 * divisor) + old_x1
|
self.crop_x1 = int(round(x1 * divisor)) + old_x1
|
||||||
self.crop_y1 = int(y1 * divisor) + old_y1
|
self.crop_y1 = int(round(y1 * divisor)) + old_y1
|
||||||
self.crop_x2 = int(x2 * divisor) + old_x1
|
self.crop_x2 = int(round(x2 * divisor)) + old_x1
|
||||||
self.crop_y2 = int(y2 * divisor) + old_y1
|
self.crop_y2 = int(round(y2 * divisor)) + old_y1
|
||||||
self.width = width
|
self.width = width
|
||||||
self.height = height
|
self.height = height
|
||||||
self.save()
|
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)
|
self.do_crop(self.crop_x1, self.crop_y1, self.crop_x2, self.crop_y2, self.width, self.height)
|
||||||
f = open(path)
|
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)
|
im = get_thumbnail(f, size, crop='center', quality=99)
|
||||||
'''
|
'''
|
||||||
context = {
|
context = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user