mirror of
https://github.com/ciromattia/kcc
synced 2025-12-29 01:21:56 +00:00
Merge branch 'master' into kcc-fakepanelview
Apply PEP-8 codestyle
This commit is contained in:
@@ -163,18 +163,15 @@ def buildOPF(profile, dstdir, title, filelist, cover=None, righttoleft=False):
|
||||
])
|
||||
if options.landscapemode:
|
||||
f.writelines(["<meta name=\"rendition:orientation\" content=\"auto\"/>\n",
|
||||
"<meta name=\"orientation-lock\" content=\"none\"/>\n"
|
||||
])
|
||||
"<meta name=\"orientation-lock\" content=\"none\"/>\n"])
|
||||
else:
|
||||
f.writelines(["<meta name=\"rendition:orientation\" content=\"portrait\"/>\n",
|
||||
"<meta name=\"orientation-lock\" content=\"portrait\"/>\n"
|
||||
])
|
||||
"<meta name=\"orientation-lock\" content=\"portrait\"/>\n"])
|
||||
f.writelines(["<meta name=\"original-resolution\" content=\"", imgres, "\"/>\n",
|
||||
"<meta name=\"primary-writing-mode\" content=\"", writingmode, "\"/>\n",
|
||||
"<meta name=\"rendition:layout\" content=\"pre-paginated\"/>\n",
|
||||
"</metadata>\n<manifest>\n<item id=\"ncx\" href=\"toc.ncx\" ",
|
||||
"media-type=\"application/x-dtbncx+xml\"/>\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("<itemref idref=\"blank-page" + str(splitCountUsed) + "\" properties=\"layout-blank\"/>\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("<itemref idref=\"page_" + entry + "\" properties=\"page-spread-" + facing + "\"/>\n")
|
||||
else:
|
||||
f.write("<itemref idref=\"page_" + entry + "\"/>\n")
|
||||
f.write("<itemref idref=\"page_" + entry + "\"/>\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':
|
||||
|
||||
17
kcc/image.py
17
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:])
|
||||
|
||||
Reference in New Issue
Block a user