I have some strange problem with PIL not resizing the image.
def handle_uploaded_image(i, u):
# resize image
from PIL import Image
img = Image.open(i)
if img.mode not in ('L', 'RGB'):
img = img.convert('RGB')
width, height = img.size
if width == height:
img.thumbnail(settings.THUMB_SIZE, Image.ANTIALIAS)
elif width > height:
ratio = floor(width / height)
newwidth = ratio * 150
newwidthhalf = floor(newwidth / 2)
img.resize((newwidth, 150), Image.ANTIALIAS)
box = 1
img.crop((newwidthhalf, 0, 150, 150))
elif height > width:
ratio = floor(height / width)
newheight = ratio * 150
newheighthalf = floor(newheight / 2)
img.resize((150, newheight), image