1
0
Fork 0
forked from josch/img2pdf

restore feature that it is allowed to only specify width or height

This commit is contained in:
Johannes 'josch' Schauer 2016-02-17 17:51:57 +01:00
parent 3e8894c7da
commit ad528d4feb

View file

@ -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")