try to fix missing crops
This commit is contained in:
parent
3ff94dc17b
commit
fcda64ca05
|
@ -673,6 +673,14 @@ class ImageBox(models.Model):
|
||||||
'''
|
'''
|
||||||
return str(self.file.file)
|
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):
|
def crop(self, x1, y1, x2, y2, width, height):
|
||||||
original_image = Image.open(join(MEDIA_ROOT, self.actual_unresized()))
|
original_image = Image.open(join(MEDIA_ROOT, self.actual_unresized()))
|
||||||
original_width = original_image.size[0]
|
original_width = original_image.size[0]
|
||||||
|
@ -731,7 +739,7 @@ class ImageBox(models.Model):
|
||||||
try:
|
try:
|
||||||
f = open(path)
|
f = open(path)
|
||||||
except:
|
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)
|
f = open(path)
|
||||||
|
|
||||||
size = str(int(self.width * m)) + "x" + str(int(self.height * m))
|
size = str(int(self.width * m)) + "x" + str(int(self.height * m))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user