From 7ab13308b3169dc00aae3678261b08d01bfb1935 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Tue, 19 Sep 2017 21:15:54 +0200 Subject: [PATCH] Resize portrait images to same size as landscape With the current approach images are resized along the width, which means images in portrait mode are substantially smaller than landscape images. This change resizes portrait images along the height so that they will cover the exact same area. --- sigal/image.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sigal/image.py b/sigal/image.py index ebd0e25..ecd33d1 100644 --- a/sigal/image.py +++ b/sigal/image.py @@ -118,7 +118,13 @@ def generate_image(source, outname, settings, options=None): logger.error('Wrong processor name: %s', settings['img_processor']) sys.exit() - processor = processor_cls(*settings['img_size'], upscale=False) + width, height = settings['img_size'] + + if img.size[0] < img.size[1]: + # swap target size if image is in portrait mode + height, width = width, height + + processor = processor_cls(width, height, upscale=False) img = processor.process(img) # signal.send() does not work here as plugins can modify the image, so we