1
0
Fork 0
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:
Johannes 'josch' Schauer 2020-06-10 00:11:09 +02:00
parent efb70042e8
commit 5564a723f5
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1
2 changed files with 18 additions and 7 deletions

View file

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

View file

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