1
0
mirror of https://github.com/sjlongland/tornado-gallery.git synced 2025-09-13 08:42:23 +10:00

resizer: Implement rotation

Need to work on dimensions.
This commit is contained in:
Stuart Longland 2018-04-18 13:57:44 +10:00
parent 8c67f262bf
commit 2fd4fa665f
Signed by: stuartl
GPG Key ID: 6AA32EFB18079BAA

View File

@ -190,12 +190,18 @@ class ResizerPool(object):
# We do not, press on!
pass
# Open the image
img = Image.open(open(orig_node.abs_path,'rb'))
# Rotate if asked:
if rotation != 0:
img = img.rotate(rotation, expand=1)
# Resize!
orig = Image.open(open(orig_node.abs_path,'rb'))
resized = orig.resize((width, height), Image.LANCZOS)
img = img.resize((width, height), Image.LANCZOS)
# Write out the new file.
resized.save(open(cache_path,'wb'), img_format.pil_fmt)
img.save(open(cache_path,'wb'), img_format.pil_fmt)
# Return to caller
log.info('Returning resized result')