This commit is contained in:
j 2019-12-02 13:40:52 +01:00
parent eaad9badbb
commit a0b3a144c6

View file

@ -540,7 +540,7 @@ class Document(models.Model, FulltextMixin):
if size: if size:
path = os.path.join(folder, '%dp%d.jpg' % (size, page)) path = os.path.join(folder, '%dp%d.jpg' % (size, page))
if len(crop) == 4: if len(crop) == 4:
path = os.path.join(folder, '%dp%d,%s.jpg' % (1024, page, ','.join(map(str, crop))) path = os.path.join(folder, '%dp%d,%s.jpg' % (1024, page, ','.join(map(str, crop))))
if not os.path.exists(path): if not os.path.exists(path):
img = Image.open(src).crop(crop) img = Image.open(src).crop(crop)
img.save(path) img.save(path)
@ -548,7 +548,7 @@ class Document(models.Model, FulltextMixin):
img = Image.open(path) img = Image.open(path)
src = path src = path
if size < max(img.size): if size < max(img.size):
path = os.path.join(folder, '%dp%d,%s.jpg' % (size, page, ','.join(map(str, crop))) path = os.path.join(folder, '%dp%d,%s.jpg' % (size, page, ','.join(map(str, crop))))
if not os.path.exists(path): if not os.path.exists(path):
resize_image(src, path, size=size) resize_image(src, path, size=size)
elif self.extension in ('jpg', 'png', 'gif'): elif self.extension in ('jpg', 'png', 'gif'):