From 02b9081e37fdbdeef9bcaf1e386df41350163fb1 Mon Sep 17 00:00:00 2001 From: Paweł Jastrzębski Date: Sat, 4 Feb 2017 10:31:09 +0100 Subject: Improved compatibility with non-Kindle devices --- kindlecomicconverter/comic2ebook.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 9580dab..404ca11 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -106,6 +106,7 @@ def buildHTML(path, imgfile, imgfilepath): if not os.path.exists(htmlpath): os.makedirs(htmlpath) htmlfile = os.path.join(htmlpath, filename[0] + '.xhtml') + imgsize = Image.open(os.path.join(head, "Images", postfix, imgfile)).size f = open(htmlfile, "w", encoding='UTF-8') f.writelines(["\n", "\n", @@ -116,14 +117,15 @@ def buildHTML(path, imgfile, imgfilepath): "\n" "\n", - "\n"]) + "\n", + "
\n", + "\n
\n"]) if options.iskindle and options.panelview: - sizeTmp = Image.open(os.path.join(head, "Images", postfix, imgfile)).size if options.autoscale: - size = (getPanelViewResolution(sizeTmp, deviceres)) + size = (getPanelViewResolution(imgsize, deviceres)) else: - size = (int(sizeTmp[0] * 1.5), int(sizeTmp[1] * 1.5)) + size = (int(imgsize[0] * 1.5), int(imgsize[1] * 1.5)) if size[0] - deviceres[0] < deviceres[0] * 0.01: noHorizontalPV = True else: @@ -356,9 +358,6 @@ def buildEPUB(path, chapterNames, tomeNumber): "display: block;\n", "margin: 0;\n", "padding: 0;\n", - "background-position: center center;\n", - "background-repeat: no-repeat;\n", - "background-size: auto auto;\n", "}\n", "#PV {\n", "position: absolute;\n", @@ -671,6 +670,11 @@ def getDirectorySize(start_path='.'): return total_size +def getTopMargin(deviceres, size): + y = int((deviceres[1] - size[1]) / 2) / deviceres[1] * 100 + return str(round(y, 1)) + + def getPanelViewResolution(imageSize, deviceRes): scale = float(deviceRes[0]) / float(imageSize[0]) return int(deviceRes[0]), int(scale * imageSize[1]) -- cgit 1.4.1