From ad528d4feb973352a2f36f2457dec2e0f79397c4 Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Wed, 17 Feb 2016 17:51:57 +0100 Subject: [PATCH] restore feature that it is allowed to only specify width or height --- src/img2pdf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/img2pdf.py b/src/img2pdf.py index 967e7e3..c71bcb2 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -695,11 +695,13 @@ def get_layout_fun(pagesize, imgsize, border, fit, auto_orient): # are negative but one of them must still be positive # if fit is not fill or enlarge then both dimensions must be positive if fit in [FitMode.fill, FitMode.enlarge] and \ - (fitwidth < 0 and fitheight < 0): + fitwidth is not None and fitwidth < 0 and \ + fitheight is not None and fitheight < 0: raise ValueError("cannot fit into a rectangle where both " "dimensions are negative") elif fit not in [FitMode.fill, FitMode.enlarge] and \ - (fitwidth < 0 or fitheight < 0): + ((fitwidth is not None and fitwidth < 0) or + (fitheight is not None and fitheight < 0)): raise Exception("cannot fit into a rectangle where either " "dimensions are negative")