forked from josch/plakativ
flip poster dimensions if necessary to create maximum size poster regardless of portrait or landscape mode
This commit is contained in:
parent
efb70042e8
commit
5564a723f5
2 changed files with 18 additions and 7 deletions
21
plakativ.py
21
plakativ.py
|
@ -338,11 +338,22 @@ class Plakativ:
|
||||||
if mode in ["size", "mult"]:
|
if mode in ["size", "mult"]:
|
||||||
if mode == "size":
|
if mode == "size":
|
||||||
# fit the input page size into the selected postersize
|
# fit the input page size into the selected postersize
|
||||||
poster_width = postersize[0]
|
width_portrait = postersize[0]
|
||||||
poster_height = (poster_width * inpage_height) / inpage_width
|
height_portrait = (width_portrait * inpage_height) / inpage_width
|
||||||
if poster_height > postersize[1]:
|
if height_portrait > postersize[1]:
|
||||||
poster_height = postersize[1]
|
height_portrait = postersize[1]
|
||||||
poster_width = (poster_height * inpage_width) / inpage_height
|
width_portrait = (height_portrait * inpage_width) / inpage_height
|
||||||
|
area_portrait = width_portrait * height_portrait
|
||||||
|
width_landscape = postersize[1]
|
||||||
|
height_landscape = (width_landscape * inpage_height) / inpage_width
|
||||||
|
if height_landscape > postersize[0]:
|
||||||
|
height_landscape = postersize[0]
|
||||||
|
width_landscape = (height_landscape * inpage_width) / inpage_height
|
||||||
|
area_landscape = width_landscape * height_landscape
|
||||||
|
if area_portrait > area_landscape:
|
||||||
|
poster_width, poster_height = width_portrait, height_portrait
|
||||||
|
else:
|
||||||
|
poster_width, poster_height = width_landscape, height_landscape
|
||||||
elif mode == "mult":
|
elif mode == "mult":
|
||||||
area = inpage_width * inpage_height * mult
|
area = inpage_width * inpage_height * mult
|
||||||
poster_width = math.sqrt(area * inpage_width / inpage_height)
|
poster_width = math.sqrt(area * inpage_width / inpage_height)
|
||||||
|
|
4
test.py
4
test.py
|
@ -55,7 +55,7 @@ _formats = {
|
||||||
"dina4_landscape": (297, 210),
|
"dina4_landscape": (297, 210),
|
||||||
"dina3_portrait": (297, 420),
|
"dina3_portrait": (297, 420),
|
||||||
"dina3_landscape": (420, 297),
|
"dina3_landscape": (420, 297),
|
||||||
"dina1_portrait": (594, 841),
|
"dina2_portrait": (420, 594),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ _formats = {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
_formats["dina1_portrait"],
|
_formats["dina2_portrait"],
|
||||||
_formats["dina4_landscape"],
|
_formats["dina4_landscape"],
|
||||||
_formats["dina4_portrait"],
|
_formats["dina4_portrait"],
|
||||||
"complex",
|
"complex",
|
||||||
|
|
Loading…
Reference in a new issue