From 5c822582281ede1479ce6de12b825fe97a0a8153 Mon Sep 17 00:00:00 2001 From: Marco van Dijk Date: Fri, 9 Jul 2021 22:01:54 +0200 Subject: [PATCH] Added variable for aggressiveness when resizing down, since we also consider whitespace atm we can do this more aggressively at the cost of speed --- lib/config.py | 3 ++- lib/dataStructures.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/config.py b/lib/config.py index e27e5b7..f96ab04 100644 --- a/lib/config.py +++ b/lib/config.py @@ -48,7 +48,8 @@ def initConfig(): 'metadataColour': '128,128,128', 'topMargin': 50, 'leftMargin': 50, - 'rightMargin': 50 + 'rightMargin': 50, + 'tryToShrinkRatio' : 0.25 } # (if CMD arguments: load CMD arguments to override specific settings) with open('config.ini', 'w') as configfile: diff --git a/lib/dataStructures.py b/lib/dataStructures.py index 5aa6247..ff2d753 100644 --- a/lib/dataStructures.py +++ b/lib/dataStructures.py @@ -221,6 +221,8 @@ class Song: self.metadataFontsize = int(configObj['metaFontWeight']) self.metadataFontFamily = configObj['metafontfamily'] self.fontMetadata = ImageFont.truetype(self.metadataFontFamily, self.metadataFontsize) + # percentageof missing whitespace and total page height + self.tryToShrinkRatio = float(configObj['tryToShrinkRatio']) @@ -366,7 +368,8 @@ class Song: shortInPercentages = amountWeAreShort / self.imageHeight #print("Whitespace {} vs next section height {}".format(whitespace, nextFirstSection.expectedHeight)) #print("We are {} short to fit the next image (total image height {} => {}% of total height)".format(amountWeAreShort, self.imageHeight, shortInPercentages*100)) - if shortInPercentages < 0.15: + # Since we also resize based on minimum required whitespaces, we can be a bit more aggressive with this + if shortInPercentages < self.tryToShrinkRatio: return True currentPageIt += 1 return False