1
0
mirror of https://github.com/ciromattia/kcc synced 2026-01-07 22:09:32 +00:00

Fixed single empty page on end of book.

This commit is contained in:
Paweł Jastrzębski
2013-03-04 19:52:38 +01:00
parent c7f38a574f
commit e92ee81617
2 changed files with 6 additions and 3 deletions

View File

@@ -192,7 +192,7 @@ def buildOPF(profile, dstdir, title, filelist, cover=None, righttoleft=False):
mt = 'image/jpeg'
f.write("<item id=\"img_" + uniqueid + "\" href=\"" + os.path.join(folder, path[1]) + "\" media-type=\""
+ mt + "\"/>\n")
if options.profile == 'K4' or options.profile == 'KHD':
if (options.profile == 'K4' or options.profile == 'KHD') and splittedSomething:
f.write("<item id=\"blank-page\" href=\"Text\\blank.html\" media-type=\"application/xhtml+xml\"/>\n")
f.write("</manifest>\n<spine toc=\"ncx\">\n")
for entry in reflist:
@@ -260,6 +260,8 @@ def applyImgOptimization(img, isSplit=False, toRight=False):
def dirImgProcess(path):
global options
global splittedSomething
splittedSomething = False
for (dirpath, dirnames, filenames) in os.walk(path):
for afile in filenames:
@@ -271,6 +273,7 @@ def dirImgProcess(path):
img = image.ComicPage(os.path.join(dirpath, afile), options.profile)
split = img.splitPage(dirpath, options.righttoleft, options.rotate)
if split is not None:
splittedSomething = True
if options.verbose:
print "Splitted " + afile
if options.righttoleft:
@@ -322,7 +325,7 @@ def genEpubStruct(path):
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
filelist.sort(key=lambda name: (alphanum_key(name[0].lower()), alphanum_key(name[1].lower())))
buildOPF(options.profile, path, options.title, filelist, cover, options.righttoleft)
if options.profile == 'K4' or options.profile == 'KHD':
if (options.profile == 'K4' or options.profile == 'KHD') and splittedSomething:
filelist.append(buildBlankHTML(os.path.join(path, 'OEBPS', 'Text')))

View File

@@ -163,7 +163,7 @@ class ComicPage:
if (float(self.image.size[0]) / float(self.image.size[1])) < ratioDev:
diff = int(self.image.size[1] * ratioDev) - self.image.size[0]
if isSplit and (profile == 'K4' or profile == 'KHD'):
diff = 2
diff = 2
self.image = ImageOps.expand(self.image, border=(diff / 2, 0), fill=fill)
elif (float(self.image.size[0]) / float(self.image.size[1])) > ratioDev:
diff = int(self.image.size[0] / ratioDev) - self.image.size[1]