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