From 6c2e0730ee5665c62015f6ac462d3210b305f75c Mon Sep 17 00:00:00 2001 From: "Daniele Verducci (Slimpenguin)" Date: Tue, 28 Feb 2023 22:39:50 +0100 Subject: [PATCH] Fixed image ratio --- mastodon-image-fetcher.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mastodon-image-fetcher.py b/mastodon-image-fetcher.py index c3faad9..0640dc6 100755 --- a/mastodon-image-fetcher.py +++ b/mastodon-image-fetcher.py @@ -81,18 +81,17 @@ cropLeft = 0 cropTop = 0 cropRight = kindleResolutionWidth cropBottom = kindleResolutionHeight -print("Image size is {}x{}, ratio is {}, kindle ratio is {}".format(width, height, ratio, kindleRatio)) if ratio > kindleRatio: # Fit height destHeight = kindleResolutionHeight - destWidth = width * ratio + destWidth = width * (destHeight / height) # Calc crop cropLeft = (destWidth - kindleResolutionWidth) / 2 cropRight = cropLeft + kindleResolutionWidth else: # Fit width destWidth = kindleResolutionWidth - destHeight = height * (1 / ratio) + destHeight = height * (destWidth / width) # Calc crop cropTop = (destHeight - kindleResolutionHeight) / 2 cropBottom = cropTop + kindleResolutionHeight