From 1abf02af6c0753785520d199c7e11ac9c78d1c67 Mon Sep 17 00:00:00 2001 From: Theodore Frederick Date: Sun, 30 Apr 2017 03:47:01 -0500 Subject: [PATCH] Updated resize_image to Optionally Ignore Aspect Ratio --- openlp/core/lib/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index caaa0ff57..e68f0e447 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -227,7 +227,7 @@ def validate_thumb(file_path, thumb_path): return image_date <= thumb_date -def resize_image(image_path, width, height, background='#000000'): +def resize_image(image_path, width, height, background='#000000', ignore_aspect_ratio=False): """ Resize an image to fit on the current screen. @@ -244,7 +244,7 @@ def resize_image(image_path, width, height, background='#000000'): image_ratio = reader.size().width() / reader.size().height() resize_ratio = width / height # Figure out the size we want to resize the image to (keep aspect ratio). - if image_ratio == resize_ratio: + if image_ratio == resize_ratio or ignore_aspect_ratio: size = QtCore.QSize(width, height) elif image_ratio < resize_ratio: # Use the image's height as reference for the new size.