Added variable for aggressiveness when resizing down, since we also consider whitespace atm we can do this more aggressively at the cost of speed

This commit is contained in:
Marco van Dijk 2021-07-09 22:01:54 +02:00
parent 72c4daa126
commit 5c82258228
2 changed files with 6 additions and 2 deletions

View File

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

View File

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