From dbf0cf0eb8c93f298425b057b926c3c7ec0c3cd4 Mon Sep 17 00:00:00 2001 From: stephenmk Date: Sun, 16 Jul 2023 18:53:28 -0500 Subject: [PATCH] Fix Yomichan image height calculation error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For images that have greater height than width values, the image proportions for Yomichan were being calculated incorrectly. This can be observed for example in the SMK8 entry for くの字点 and the DAIJIRIN2 entry for 定積分. --- bot/yomichan/glossary/daijirin2.py | 20 ++++++++++---------- bot/yomichan/glossary/jitenon.py | 4 ++-- bot/yomichan/glossary/smk8.py | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bot/yomichan/glossary/daijirin2.py b/bot/yomichan/glossary/daijirin2.py index 71e06ad..0adaa96 100644 --- a/bot/yomichan/glossary/daijirin2.py +++ b/bot/yomichan/glossary/daijirin2.py @@ -111,8 +111,8 @@ def __convert_gaiji(soup, image_dir): ratio = Icons.calculate_ratio(path) img = BeautifulSoup("", "xml").img img.attrs = { - "height": 1.0 if ratio > 1.0 else ratio, - "width": ratio if ratio > 1.0 else 1.0, + "height": 1.0, + "width": ratio, "sizeUnits": "em", "collapsible": False, "collapsed": False, @@ -150,8 +150,8 @@ def __convert_logos(soup, image_dir): ratio = Icons.calculate_ratio(path) img = BeautifulSoup("", "xml").img img.attrs = { - "height": 1.0 if ratio > 1.0 else ratio, - "width": ratio if ratio > 1.0 else 1.0, + "height": 1.0, + "width": ratio, "sizeUnits": "em", "collapsible": False, "collapsed": False, @@ -174,8 +174,8 @@ def __convert_kanjion_logos(soup, image_dir): ratio = Icons.calculate_ratio(path) img = BeautifulSoup("", "xml").img img.attrs = { - "height": 1.0 if ratio > 1.0 else ratio, - "width": ratio if ratio > 1.0 else 1.0, + "height": 1.0, + "width": ratio, "sizeUnits": "em", "collapsible": False, "collapsed": False, @@ -198,8 +198,8 @@ def __convert_daigoginum(soup, image_dir): ratio = Icons.calculate_ratio(path) img = BeautifulSoup("", "xml").img img.attrs = { - "height": 1.0 if ratio > 1.0 else ratio, - "width": ratio if ratio > 1.0 else 1.0, + "height": 1.0, + "width": ratio, "sizeUnits": "em", "collapsible": False, "collapsed": False, @@ -222,8 +222,8 @@ def __convert_jundaigoginum(soup, image_dir): ratio = Icons.calculate_ratio(path) img = BeautifulSoup("", "xml").img img.attrs = { - "height": 1.0 if ratio > 1.0 else ratio, - "width": ratio if ratio > 1.0 else 1.0, + "height": 1.0, + "width": ratio, "sizeUnits": "em", "collapsible": False, "collapsed": False, diff --git a/bot/yomichan/glossary/jitenon.py b/bot/yomichan/glossary/jitenon.py index a342214..61111b4 100644 --- a/bot/yomichan/glossary/jitenon.py +++ b/bot/yomichan/glossary/jitenon.py @@ -118,8 +118,8 @@ class JitenonKokugoGlossary(JitenonGlossary): ratio = Icons.calculate_ratio(path) img = BeautifulSoup("", "xml").img img.attrs = { - "height": 1.0 if ratio > 1.0 else ratio, - "width": ratio if ratio > 1.0 else 1.0, + "height": 1.0, + "width": ratio, "sizeUnits": "em", "collapsible": False, "collapsed": False, diff --git a/bot/yomichan/glossary/smk8.py b/bot/yomichan/glossary/smk8.py index b49fc47..f17ee42 100644 --- a/bot/yomichan/glossary/smk8.py +++ b/bot/yomichan/glossary/smk8.py @@ -92,8 +92,8 @@ def __convert_gaiji(soup, image_dir): ratio = Icons.calculate_ratio(path) img = BeautifulSoup("", "xml").img img.attrs = { - "height": 1.0 if ratio > 1.0 else ratio, - "width": ratio if ratio > 1.0 else 1.0, + "height": 1.0, + "width": ratio, "sizeUnits": "em", "collapsible": False, "collapsed": False, @@ -124,8 +124,8 @@ def __convert_rectangles(soup, image_dir): ratio = Icons.calculate_ratio(path) img = BeautifulSoup("", "xml").img img.attrs = { - "height": 1.0 if ratio > 1.0 else ratio, - "width": ratio if ratio > 1.0 else 1.0, + "height": 1.0, + "width": ratio, "sizeUnits": "em", "collapsible": False, "collapsed": False,