From 3b0e5cc309c58efd921541cdd1597ac62ffeb5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Thu, 5 Dec 2013 15:41:47 +0100 Subject: [PATCH] Panel View support overhaul - Round 2 --- kcc/comic2ebook.py | 36 ++++++++++++++++++---------------- kcc/image.py | 48 +++++++++++++++++++++++++++++----------------- 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 830fabf..c27ad4a 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -142,35 +142,35 @@ def buildHTML(path, imgfile): xr = borders[2].lstrip("0") yd = borders[3].lstrip("0") if xl != "": - xl = "-" + str(xl) + "px" + xl = "-" + str(float(xl)/100) + "%" else: - xl = "0px" + xl = "0%" if xr != "": - xr = "-" + str(xr) + "px" + xr = "-" + str(float(xr)/100) + "%" else: - xr = "0px" + xr = "0%" if yu != "": - yu = "-" + str(yu) + "px" + yu = "-" + str(float(yu)/100) + "%" else: - yu = "0px" + yu = "0%" if yd != "": - yd = "-" + str(yd) + "px" + yd = "-" + str(float(yd)/100) + "%" else: - yd = "0px" + yd = "0%" else: - xl = "0px" - yu = "0px" - xr = "0px" - yd = "0px" + xl = "0%" + yu = "0%" + xr = "0%" + yd = "0%" boxStyles = {"BoxTL": "left:" + xl + ";top:" + yu + ";", "BoxTR": "right:" + xr + ";top:" + yu + ";", "BoxBL": "left:" + xl + ";bottom:" + yd + ";", "BoxBR": "right:" + xr + ";bottom:" + yd + ";", - "BoxT": "left:-25%;top:" + yu + ";", - "BoxB": "left:-25%;bottom:" + yd + ";", - "BoxL": "left:" + xl + ";top:-25%;", - "BoxR": "right:" + xr + ";top:-25%;", - "BoxC": "right:-25%;top:-25%;" + "BoxT": "left:" + xl + ";top:" + yu + ";", + "BoxB": "left:" + xl + ";bottom:" + yd + ";", + "BoxL": "left:" + xl + ";top:" + yu + ";", + "BoxR": "right:" + xr + ";top:" + yu + ";", + "BoxC": "left:" + xl + ";top:" + yu + ";" } for box in boxes: f.writelines(["
ratioDev: diff = int(self.image.size[0] / ratioDev) - self.image.size[1] self.image = ImageOps.expand(self.image, border=(0, diff / 2), fill=fill) + if self.image.size[0] <= size[0] and self.image.size[1] <= size[1]: + method = Image.BICUBIC + else: + method = Image.ANTIALIAS self.image = ImageOps.fit(self.image, size, method=method, centering=(0.5, 0.5)) return self.image