mirror of
https://github.com/ciromattia/kcc
synced 2026-05-26 09:22:13 +00:00
Ultra mode tweaks
This commit is contained in:
@@ -132,16 +132,16 @@ def buildHTML(path, imgfile):
|
|||||||
imgfilepv = imgfile
|
imgfilepv = imgfile
|
||||||
f.writelines(["<div id=\"BoxTL-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxTL-Panel\" class=\"",
|
f.writelines(["<div id=\"BoxTL-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxTL-Panel\" class=\"",
|
||||||
"target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfilepv, "\" alt=\"",
|
"target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfilepv, "\" alt=\"",
|
||||||
imgfile, "\"/></div></div>\n",
|
imgfilepv, "\"/></div></div>\n",
|
||||||
"<div id=\"BoxTR-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxTR-Panel\" class=\"",
|
"<div id=\"BoxTR-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxTR-Panel\" class=\"",
|
||||||
"target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfilepv, "\" alt=\"",
|
"target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfilepv, "\" alt=\"",
|
||||||
imgfile, "\"/></div></div>\n",
|
imgfilepv, "\"/></div></div>\n",
|
||||||
"<div id=\"BoxBL-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxBL-Panel\" class=\"",
|
"<div id=\"BoxBL-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxBL-Panel\" class=\"",
|
||||||
"target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfilepv, "\" alt=\"",
|
"target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfilepv, "\" alt=\"",
|
||||||
imgfile, "\"/></div></div>\n",
|
imgfilepv, "\"/></div></div>\n",
|
||||||
"<div id=\"BoxBR-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxBR-Panel\" class=\"",
|
"<div id=\"BoxBR-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxBR-Panel\" class=\"",
|
||||||
"target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfilepv, "\" alt=\"",
|
"target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfilepv, "\" alt=\"",
|
||||||
imgfile, "\"/></div></div>\n"
|
imgfilepv, "\"/></div></div>\n"
|
||||||
])
|
])
|
||||||
f.writelines(["</div>\n</body>\n</html>"])
|
f.writelines(["</div>\n</body>\n</html>"])
|
||||||
f.close()
|
f.close()
|
||||||
@@ -407,7 +407,7 @@ def fileImgProcess(work):
|
|||||||
if options.nosplitrotate:
|
if options.nosplitrotate:
|
||||||
split = None
|
split = None
|
||||||
else:
|
else:
|
||||||
split = img.splitPage(dirpath, options.righttoleft, options.rotate, wipe)
|
split = img.splitPage(dirpath, options.righttoleft, options.rotate)
|
||||||
if split is not None and split is not "R":
|
if split is not None and split is not "R":
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print "Splitted " + afile
|
print "Splitted " + afile
|
||||||
@@ -425,20 +425,21 @@ def fileImgProcess(work):
|
|||||||
applyImgOptimization(img1, True, toRight2, options)
|
applyImgOptimization(img1, True, toRight2, options)
|
||||||
img1.saveToDir(dirpath, options.forcepng, options.forcecolor, wipe)
|
img1.saveToDir(dirpath, options.forcepng, options.forcecolor, wipe)
|
||||||
if options.quality == 2:
|
if options.quality == 2:
|
||||||
split2 = img.splitPage(dirpath, options.righttoleft, options.rotate, True)
|
img3 = image.ComicPage(split[0], options.profileData)
|
||||||
img3 = image.ComicPage(split2[0], options.profileData)
|
|
||||||
applyImgOptimization(img3, True, toRight1, options, 0)
|
applyImgOptimization(img3, True, toRight1, options, 0)
|
||||||
img3.saveToDir(dirpath, options.forcepng, options.forcecolor, True, "LQ")
|
img3.saveToDir(dirpath, options.forcepng, options.forcecolor, True)
|
||||||
img4 = image.ComicPage(split2[1], options.profileData)
|
img4 = image.ComicPage(split[1], options.profileData)
|
||||||
applyImgOptimization(img4, True, toRight2, options, 0)
|
applyImgOptimization(img4, True, toRight2, options, 0)
|
||||||
img4.saveToDir(dirpath, options.forcepng, options.forcecolor, True, "LQ")
|
img4.saveToDir(dirpath, options.forcepng, options.forcecolor, True)
|
||||||
else:
|
else:
|
||||||
applyImgOptimization(img, False, False, options)
|
applyImgOptimization(img, False, False, options)
|
||||||
img.saveToDir(dirpath, options.forcepng, options.forcecolor, wipe, split)
|
img.saveToDir(dirpath, options.forcepng, options.forcecolor, wipe, split)
|
||||||
if options.quality == 2:
|
if options.quality == 2:
|
||||||
img2 = image.ComicPage(os.path.join(dirpath, afile), options.profileData)
|
img2 = image.ComicPage(os.path.join(dirpath, afile), options.profileData)
|
||||||
|
if split == "R":
|
||||||
|
img2.image = img2.image.rotate(90)
|
||||||
applyImgOptimization(img2, False, False, options, 0)
|
applyImgOptimization(img2, False, False, options, 0)
|
||||||
img2.saveToDir(dirpath, options.forcepng, options.forcecolor, True, str(split) + "LQ")
|
img2.saveToDir(dirpath, options.forcepng, options.forcecolor, True, split)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -137,10 +137,6 @@ class ComicPage:
|
|||||||
self.image = self.image.convert('L') # convert to grayscale
|
self.image = self.image.convert('L') # convert to grayscale
|
||||||
if sufix == "R":
|
if sufix == "R":
|
||||||
sufix = "_kccrotated"
|
sufix = "_kccrotated"
|
||||||
#elif sufix == "NoneLQ":
|
|
||||||
#sufix = ""
|
|
||||||
elif sufix == "RLQ":
|
|
||||||
sufix = "_kccrotated"
|
|
||||||
else:
|
else:
|
||||||
sufix = ""
|
sufix = ""
|
||||||
if wipe:
|
if wipe:
|
||||||
@@ -216,7 +212,7 @@ class ComicPage:
|
|||||||
self.image = ImageOps.fit(self.image, size, method=method, centering=(0.5, 0.5))
|
self.image = ImageOps.fit(self.image, size, method=method, centering=(0.5, 0.5))
|
||||||
return self.image
|
return self.image
|
||||||
|
|
||||||
def splitPage(self, targetdir, righttoleft=False, rotate=False, wipe=False):
|
def splitPage(self, targetdir, righttoleft=False, rotate=False):
|
||||||
width, height = self.image.size
|
width, height = self.image.size
|
||||||
dstwidth, dstheight = self.size
|
dstwidth, dstheight = self.size
|
||||||
#print "Image is %d x %d" % (width,height)
|
#print "Image is %d x %d" % (width,height)
|
||||||
@@ -246,8 +242,7 @@ class ComicPage:
|
|||||||
pagetwo = self.image.crop(rightbox)
|
pagetwo = self.image.crop(rightbox)
|
||||||
pageone.save(fileone)
|
pageone.save(fileone)
|
||||||
pagetwo.save(filetwo)
|
pagetwo.save(filetwo)
|
||||||
if wipe:
|
os.remove(self.origFileName)
|
||||||
os.remove(self.origFileName)
|
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))
|
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))
|
||||||
return fileone, filetwo
|
return fileone, filetwo
|
||||||
|
|||||||
Reference in New Issue
Block a user