diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index cac4854..8af411c 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -163,18 +163,15 @@ def buildOPF(profile, dstdir, title, filelist, cover=None, righttoleft=False): ]) if options.landscapemode: f.writelines(["\n", - "\n" - ]) + "\n"]) else: f.writelines(["\n", - "\n" - ]) + "\n"]) f.writelines(["\n", "\n", "\n", "\n\n\n" - ]) + "media-type=\"application/x-dtbncx+xml\"/>\n"]) if cover is not None: filename = getImageFileName(cover.replace(os.path.join(dstdir, 'OEBPS'), '').lstrip('/').lstrip('\\\\')) if '.png' == filename[1]: @@ -207,7 +204,8 @@ def buildOPF(profile, dstdir, title, filelist, cover=None, righttoleft=False): splitCountUsed = 1 for entry in reflist: if entry.endswith("-1"): - if ((righttoleft and facing == 'left') or (not righttoleft and facing == 'right')) and options.landscapemode: + if ((righttoleft and facing == 'left') or (not righttoleft and facing == 'right')) and\ + options.landscapemode: f.write("\n") splitCountUsed += 1 if options.landscapemode: @@ -227,7 +225,7 @@ def buildOPF(profile, dstdir, title, filelist, cover=None, righttoleft=False): if options.landscapemode: f.write("\n") else: - f.write("\n") + f.write("\n") if facing == 'right': facing = 'left' else: @@ -317,8 +315,10 @@ def dirImgProcess(path): if options.fakepanelview or options.fakepanelviewlandscape: img0 = image.ComicPage(split[0], options.profile) img1 = image.ComicPage(split[1], options.profile) - splitA = img0.splitPageFakePanelView(dirpath, options.righttoleft, options.fakepanelviewlandscape) - splitB = img1.splitPageFakePanelView(dirpath, options.righttoleft, options.fakepanelviewlandscape) + splitA = img0.splitPageFakePanelView(dirpath, options.righttoleft, + options.fakepanelviewlandscape) + splitB = img1.splitPageFakePanelView(dirpath, options.righttoleft, + options.fakepanelviewlandscape) for img in splitA: tempImg = image.ComicPage(img, options.profile) applyImgOptimization(tempImg) @@ -326,7 +326,7 @@ def dirImgProcess(path): for img in splitB: tempImg = image.ComicPage(img, options.profile) applyImgOptimization(tempImg) - tempImg.saveToDir(dirpath, options.notquantize) + tempImg.saveToDir(dirpath, options.notquantize) else: img0 = image.ComicPage(split[0], options.profile) applyImgOptimization(img0, True, toRight1) @@ -522,6 +522,7 @@ def main(argv=None): rmtree(path) return epubpath + def checkOptions(): global options if options.profile == 'K4' or options.profile == 'KHD': diff --git a/kcc/image.py b/kcc/image.py index a555c76..89be1cc 100755 --- a/kcc/image.py +++ b/kcc/image.py @@ -141,7 +141,8 @@ class ComicPage: palImg.putpalette(self.palette) self.image = self.image.quantize(palette=palImg) - def resizeImage(self, upscale=False, stretch=False, black_borders=False, fakePanelViewLandscape=False, isSplit=False, toRight=False, landscapeMode=False): + def resizeImage(self, upscale=False, stretch=False, black_borders=False, fakePanelViewLandscape=False, + isSplit=False, toRight=False, landscapeMode=False): method = Image.ANTIALIAS if black_borders: fill = 'black' @@ -222,12 +223,11 @@ class ComicPage: else: return None - def splitPageFakePanelView(self, targetdir, righttoleft=False, fakePanelWiewLandscape=False): width, height = self.image.size if fakePanelWiewLandscape: - topbox = (0, 0, width, ((height / 2) + (height/9))) - bottombox = (0, ((height / 2) - (height/9)), width, height) + topbox = (0, 0, width, ((height / 2) + (height / 9))) + bottombox = (0, ((height / 2) - (height / 9)), width, height) filename = os.path.splitext(os.path.basename(self.origFileName)) file1 = targetdir + '/' + filename[0] + '-1' + filename[1] file2 = targetdir + '/' + filename[0] + '-2' + filename[1] @@ -241,10 +241,10 @@ class ComicPage: raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e)) return file1, file2 else: - topleftbox = (0, 0, ((width / 2) + (width/9)), ((height / 2) + (height/9))) - toprightbox = ((width / 2) - (width/9)), 0, width, ((height / 2) + (height/9)) - bottomleftbox = (0, ((height / 2) - (height/9)), ((width / 2) + (width/9)), height) - bototmrightbox = (((width / 2) - (width/9)), ((height / 2) - (height/9)), width, height) + topleftbox = (0, 0, ((width / 2) + (width / 9)), ((height / 2) + (height / 9))) + toprightbox = ((width / 2) - (width / 9)), 0, width, ((height / 2) + (height / 9)) + bottomleftbox = (0, ((height / 2) - (height / 9)), ((width / 2) + (width / 9)), height) + bototmrightbox = (((width / 2) - (width / 9)), ((height / 2) - (height / 9)), width, height) filename = os.path.splitext(os.path.basename(self.origFileName)) file0 = targetdir + '/' + filename[0] + '-0' + filename[1] file1 = targetdir + '/' + filename[0] + '-1' + filename[1] @@ -274,7 +274,6 @@ class ComicPage: raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e)) return file0, file1, file2, file3, file4 - # def frameImage(self): # foreground = tuple(self.palette[:3]) # background = tuple(self.palette[-3:])