mirror of
https://github.com/ciromattia/kcc
synced 2026-04-21 00:18:56 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10037a3c9d | ||
|
|
b0374e127d | ||
|
|
894dbfc8a2 |
@@ -324,8 +324,8 @@ def buildOPF(dstdir, title, filelist, originalpath, cover=None):
|
||||
f.write("<meta name=\"cover\" content=\"cover\"/>\n")
|
||||
if options.iskindle and options.profile != 'Custom':
|
||||
f.writelines(["<meta name=\"fixed-layout\" content=\"true\"/>\n",
|
||||
"<meta name=\"original-resolution\" content=\"",
|
||||
str(deviceres[0]) + "x" + str(deviceres[1]) + "\"/>\n",
|
||||
# "<meta name=\"original-resolution\" content=\"",
|
||||
# str(deviceres[0]) + "x" + str(deviceres[1]) + "\"/>\n",
|
||||
"<meta name=\"book-type\" content=\"comic\"/>\n",
|
||||
"<meta name=\"primary-writing-mode\" content=\"" + writingmode + "\"/>\n",
|
||||
"<meta name=\"zero-gutter\" content=\"true\"/>\n",
|
||||
|
||||
@@ -194,8 +194,10 @@ class ComicPageParser:
|
||||
new_image.paste(pageone, (0, 0))
|
||||
new_image.paste(pagetwo, (0, height))
|
||||
self.payload.append(['N', self.source, new_image, self.fill])
|
||||
elif (width > height) != (dstwidth > dstheight) and width <= dstheight and height <= dstwidth \
|
||||
and not self.opt.webtoon and self.opt.splitter == 1:
|
||||
elif self.opt.webtoon:
|
||||
self.payload.append(['N', self.source, self.image, self.fill])
|
||||
# rotate only TODO dead code?
|
||||
elif (width > height) != (dstwidth > dstheight) and width <= dstheight and height <= dstwidth and self.opt.splitter == 1:
|
||||
spread = self.image
|
||||
if not self.opt.norotate:
|
||||
if not self.opt.rotateright:
|
||||
@@ -203,8 +205,10 @@ class ComicPageParser:
|
||||
else:
|
||||
spread = spread.rotate(-90, Image.Resampling.BICUBIC, True)
|
||||
self.payload.append(['R', self.source, spread, self.fill])
|
||||
elif (width > height) != (dstwidth > dstheight) and not self.opt.webtoon:
|
||||
if self.opt.splitter != 1 and width / height < 2:
|
||||
# elif wide enough to split
|
||||
elif (width > height) != (dstwidth > dstheight) and width / height > 1.16:
|
||||
# if (split) or (split and rotate)
|
||||
if self.opt.splitter != 1 and width / height < 1.75:
|
||||
if width > height:
|
||||
leftbox = (0, 0, int(width / 2), height)
|
||||
rightbox = (int(width / 2), 0, width, height)
|
||||
@@ -219,7 +223,9 @@ class ComicPageParser:
|
||||
pagetwo = self.image.crop(rightbox)
|
||||
self.payload.append(['S1', self.source, pageone, self.fill])
|
||||
self.payload.append(['S2', self.source, pagetwo, self.fill])
|
||||
if self.opt.splitter > 0 or (self.opt.splitter == 0 and width / height >= 2):
|
||||
|
||||
# if (rotate) or (split and rotate)
|
||||
if self.opt.splitter > 0 or (self.opt.splitter == 0 and width / height >= 1.75):
|
||||
spread = self.image
|
||||
if not self.opt.norotate:
|
||||
if not self.opt.rotateright:
|
||||
@@ -602,12 +608,30 @@ class Cover:
|
||||
self.image = self.image.crop((w/6, 0, w/2 - w * 0.02, h))
|
||||
else:
|
||||
self.image = self.image.crop((w/2 + w * 0.02, 0, 5/6 * w, h))
|
||||
elif w / h > 1.83:
|
||||
self.smartcover = True
|
||||
if self.options.righttoleft:
|
||||
self.image = self.image.crop((w * .19, 0, w * .575, h))
|
||||
else:
|
||||
self.image = self.image.crop((w * .425, 0, .81 * w, h))
|
||||
elif w / h > 1.7:
|
||||
self.smartcover = True
|
||||
if self.options.righttoleft:
|
||||
self.image = self.image.crop((w * .2, 0, w * .583, h))
|
||||
else:
|
||||
self.image = self.image.crop((w * .417, 0, .8 * w, h))
|
||||
elif w / h > 1.34:
|
||||
self.smartcover = True
|
||||
if self.options.righttoleft:
|
||||
self.image = self.image.crop((0, 0, w/2 - w * 0.03, h))
|
||||
else:
|
||||
self.image = self.image.crop((w/2 + w * 0.03, 0, w, h))
|
||||
elif w / h > 1.0:
|
||||
self.smartcover = True
|
||||
if self.options.righttoleft:
|
||||
self.image = self.image.crop((w * .36, 0, w, h))
|
||||
else:
|
||||
self.image = self.image.crop((w, 0, .64 * w, h))
|
||||
|
||||
def save_to_folder(self, target, tomeid, len_tomes=0):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user