Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #266 from cuchac/patch-1

Fix version size
  • Loading branch information...
commit febfad950774755ab215c48babc7822eb451ebee 2 parents 6d4238f + bb353eb
@sehmaschine authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 filebrowser/utils.py
View
5 filebrowser/utils.py
@@ -4,6 +4,7 @@
import re
import os
import unicodedata
+import math
# DJANGO IMPORTS
from django.utils import six
@@ -82,13 +83,13 @@ def scale_and_crop(im, width, height, opts):
r = min(xr/x, yr/y)
if r < 1.0 or (r > 1.0 and 'upscale' in opts):
- im = im.resize((int(x*r), int(y*r)), resample=Image.ANTIALIAS)
+ im = im.resize((int(math.ceil(x*r)), int(math.ceil(y*r))), resample=Image.ANTIALIAS)
if 'crop' in opts:
x, y = [float(v) for v in im.size]
ex, ey = (x-min(x, xr))/2, (y-min(y, yr))/2
if ex or ey:
- im = im.crop((int(ex), int(ey), int(x-ex), int(y-ey)))
+ im = im.crop((int(ex), int(ey), int(ex+xr), int(ey+yr)))
return im
scale_and_crop.valid_options = ('crop', 'upscale')
Please sign in to comment.
Something went wrong with that request. Please try again.