forked from josch/img2pdf
restore feature that it is allowed to only specify width or height
This commit is contained in:
parent
3e8894c7da
commit
ad528d4feb
1 changed files with 4 additions and 2 deletions
|
@ -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")
|
||||
|
||||
|
|
Loading…
Reference in a new issue