mirror of
https://github.com/ciromattia/kcc
synced 2026-07-18 10:46:12 +00:00
Overhauled Panel View support
This commit is contained in:
+45
-31
@@ -129,34 +129,47 @@ def buildHTML(path, imgfile):
|
||||
"}'></a></div>\n"])
|
||||
if options.quality == 2:
|
||||
imgfilepv = string.split(imgfile, ".")
|
||||
imgfilepv[0] = imgfilepv[0].split("_kccx")[0].replace("_kccnh", "").replace("_kccnv", "")
|
||||
imgfilepv[0] = imgfilepv[0].split("_kccxl")[0].replace("_kccnh", "").replace("_kccnv", "")
|
||||
imgfilepv[0] += "_kcchq"
|
||||
imgfilepv = string.join(imgfilepv, ".")
|
||||
else:
|
||||
imgfilepv = imgfile
|
||||
if "_kccx" in filename[0]:
|
||||
xy = string.split(filename[0], "_kccx")[1]
|
||||
x = string.split(xy, "_kccy")[0].lstrip("0")
|
||||
y = string.split(xy, "_kccy")[1].lstrip("0")
|
||||
if x != "":
|
||||
x = "-" + str(float(x)/100) + "%"
|
||||
if "_kccxl" in filename[0]:
|
||||
borders = filename[0].split('_kccxl')[1]
|
||||
borders = re.findall('[0-9]{1,6}', borders)
|
||||
xl = borders[0].lstrip("0")
|
||||
yu = borders[1].lstrip("0")
|
||||
xr = borders[2].lstrip("0")
|
||||
yd = borders[3].lstrip("0")
|
||||
if xl != "":
|
||||
xl = "-" + str(xl) + "px"
|
||||
else:
|
||||
x = "0%"
|
||||
if y != "":
|
||||
y = "-" + str(float(y)/100) + "%"
|
||||
xl = "0px"
|
||||
if xr != "":
|
||||
xr = "-" + str(xr) + "px"
|
||||
else:
|
||||
y = "0%"
|
||||
xr = "0px"
|
||||
if yu != "":
|
||||
yu = "-" + str(yu) + "px"
|
||||
else:
|
||||
yu = "0px"
|
||||
if yd != "":
|
||||
yd = "-" + str(yd) + "px"
|
||||
else:
|
||||
yd = "0px"
|
||||
else:
|
||||
x = "0%"
|
||||
y = "0%"
|
||||
boxStyles = {"BoxTL": "left:" + x + ";top:" + y + ";",
|
||||
"BoxTR": "right:" + x + ";top:" + y + ";",
|
||||
"BoxBL": "left:" + x + ";bottom:" + y + ";",
|
||||
"BoxBR": "right:" + x + ";bottom:" + y + ";",
|
||||
"BoxT": "left:-25%;top:" + y + ";",
|
||||
"BoxB": "left:-25%;bottom:" + y + ";",
|
||||
"BoxL": "left:" + x + ";top:-25%;",
|
||||
"BoxR": "right:" + x + ";top:-25%;",
|
||||
xl = "0px"
|
||||
yu = "0px"
|
||||
xr = "0px"
|
||||
yd = "0px"
|
||||
boxStyles = {"BoxTL": "left:" + xl + ";top:" + yu + ";",
|
||||
"BoxTR": "right:" + xr + ";top:" + yu + ";",
|
||||
"BoxBL": "left:" + xl + ";bottom:" + yd + ";",
|
||||
"BoxBR": "right:" + xr + ";bottom:" + yd + ";",
|
||||
"BoxT": "left:-25%;top:" + yu + ";",
|
||||
"BoxB": "left:-25%;bottom:" + yd + ";",
|
||||
"BoxL": "left:" + xl + ";top:-25%;",
|
||||
"BoxR": "right:" + xr + ";top:-25%;",
|
||||
"BoxC": "right:-25%;top:-25%;"
|
||||
}
|
||||
for box in boxes:
|
||||
@@ -295,7 +308,7 @@ def getImageFileName(imgfile):
|
||||
return filename
|
||||
|
||||
|
||||
def applyImgOptimization(img, opt, overrideQuality=5):
|
||||
def applyImgOptimization(img, opt, hqImage=None):
|
||||
if not img.fill:
|
||||
img.getImageFill(opt.webtoon)
|
||||
if not opt.webtoon:
|
||||
@@ -303,8 +316,9 @@ def applyImgOptimization(img, opt, overrideQuality=5):
|
||||
if opt.cutpagenumbers and not opt.webtoon:
|
||||
img.cutPageNumber()
|
||||
img.optimizeImage(opt.gamma)
|
||||
if overrideQuality != 5:
|
||||
img.resizeImage(opt.upscale, opt.stretch, opt.bordersColor, overrideQuality)
|
||||
if hqImage:
|
||||
img.resizeImage(opt.upscale, opt.stretch, opt.bordersColor, 0)
|
||||
img.calculateBorder(hqImage)
|
||||
else:
|
||||
img.resizeImage(opt.upscale, opt.stretch, opt.bordersColor, opt.quality)
|
||||
if opt.forcepng and not opt.forcecolor:
|
||||
@@ -378,12 +392,12 @@ def fileImgProcess(work):
|
||||
applyImgOptimization(img1, opt)
|
||||
img1.saveToDir(dirpath, opt.forcepng, opt.forcecolor, wipe)
|
||||
if opt.quality == 2:
|
||||
img3 = image.ComicPage(split[0], opt.profileData, img0.fill)
|
||||
applyImgOptimization(img3, opt, 0)
|
||||
img3.saveToDir(dirpath, opt.forcepng, opt.forcecolor, True)
|
||||
img4 = image.ComicPage(split[1], opt.profileData, img1.fill)
|
||||
applyImgOptimization(img4, opt, 0)
|
||||
img4.saveToDir(dirpath, opt.forcepng, opt.forcecolor, True)
|
||||
img0b = image.ComicPage(split[0], opt.profileData, img0.fill)
|
||||
applyImgOptimization(img0b, opt, img0)
|
||||
img0b.saveToDir(dirpath, opt.forcepng, opt.forcecolor, True)
|
||||
img1b = image.ComicPage(split[1], opt.profileData, img1.fill)
|
||||
applyImgOptimization(img1b, opt, img1)
|
||||
img1b.saveToDir(dirpath, opt.forcepng, opt.forcecolor, True)
|
||||
else:
|
||||
applyImgOptimization(img, opt)
|
||||
img.saveToDir(dirpath, opt.forcepng, opt.forcecolor, wipe)
|
||||
@@ -392,7 +406,7 @@ def fileImgProcess(work):
|
||||
if img.rotated:
|
||||
img2.image = img2.image.rotate(90)
|
||||
img2.rotated = True
|
||||
applyImgOptimization(img2, opt, 0)
|
||||
applyImgOptimization(img2, opt, img)
|
||||
img2.saveToDir(dirpath, opt.forcepng, opt.forcecolor, True)
|
||||
except StandardError:
|
||||
return str(sys.exc_info()[1])
|
||||
|
||||
Reference in New Issue
Block a user