mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 01:36:27 +00:00
Fixed Panel View bugs
This commit is contained in:
@@ -105,9 +105,9 @@ def buildHTML(path, imgfile):
|
||||
elif noHorizontalPV and not noVerticalPV:
|
||||
if rotatedPage:
|
||||
if options.righttoleft:
|
||||
order = [2, 1]
|
||||
else:
|
||||
order = [1, 2]
|
||||
else:
|
||||
order = [2, 1]
|
||||
else:
|
||||
order = [1, 2]
|
||||
boxes = ["BoxT", "BoxB"]
|
||||
@@ -166,11 +166,11 @@ def buildHTML(path, imgfile):
|
||||
"BoxTR": "right:" + xr + ";top:" + yu + ";",
|
||||
"BoxBL": "left:" + xl + ";bottom:" + yd + ";",
|
||||
"BoxBR": "right:" + xr + ";bottom:" + yd + ";",
|
||||
"BoxT": "left:" + xl + ";top:" + yu + ";",
|
||||
"BoxB": "left:" + xl + ";bottom:" + yd + ";",
|
||||
"BoxL": "left:" + xl + ";top:" + yu + ";",
|
||||
"BoxR": "right:" + xr + ";top:" + yu + ";",
|
||||
"BoxC": "left:" + xl + ";top:" + yu + ";"
|
||||
"BoxT": "left:-25%;top:" + yu + ";",
|
||||
"BoxB": "left:-25%;bottom:" + yd + ";",
|
||||
"BoxL": "left:" + xl + ";top:-25%;",
|
||||
"BoxR": "right:" + xr + ";top:-25%;",
|
||||
"BoxC": "left:-25%;top:-25%;"
|
||||
}
|
||||
for box in boxes:
|
||||
f.writelines(["<div id=\"" + box + "-Panel-Parent\" class=\"target-mag-parent\"><div id=\"",
|
||||
@@ -318,11 +318,14 @@ def applyImgOptimization(img, opt, hqImage=None):
|
||||
img.optimizeImage(opt.gamma)
|
||||
if hqImage:
|
||||
img.resizeImage(opt.upscale, opt.stretch, opt.bordersColor, 0)
|
||||
img.calculateBorder(hqImage)
|
||||
img.calculateBorder(hqImage, True)
|
||||
else:
|
||||
img.resizeImage(opt.upscale, opt.stretch, opt.bordersColor, opt.quality)
|
||||
if opt.panelview and opt.quality != 2:
|
||||
img.calculateBorder(img)
|
||||
if opt.panelview:
|
||||
if opt.quality == 0:
|
||||
img.calculateBorder(img)
|
||||
elif opt.quality == 1:
|
||||
img.calculateBorder(img, True)
|
||||
if opt.forcepng and not opt.forcecolor:
|
||||
img.quantizeImage()
|
||||
|
||||
|
||||
12
kcc/image.py
12
kcc/image.py
@@ -239,7 +239,7 @@ class ComicPage:
|
||||
else:
|
||||
return int(round(float(x)/float(img.image.size[1]), 4) * 10000 * 1.5)
|
||||
|
||||
def calculateBorder(self, sourceImage):
|
||||
def calculateBorder(self, sourceImage, isHQ=False):
|
||||
if self.fill == 'white':
|
||||
# This code trigger only when sourceImage is already saved. So we can break color quantization.
|
||||
if sourceImage.image.mode == 'P':
|
||||
@@ -248,16 +248,18 @@ class ComicPage:
|
||||
else:
|
||||
border = sourceImage.image.getbbox()
|
||||
if border is not None:
|
||||
if isHQ:
|
||||
multiplier = 1.0
|
||||
else:
|
||||
multiplier = 1.5
|
||||
self.border = [self.calculateBorderPercent(border[0], sourceImage, True),
|
||||
self.calculateBorderPercent(border[1], sourceImage, False),
|
||||
self.calculateBorderPercent((sourceImage.image.size[0] - border[2]), sourceImage, True),
|
||||
self.calculateBorderPercent((sourceImage.image.size[1] - border[3]), sourceImage, False)]
|
||||
if int((border[2] - border[0]) * 1.5) < self.size[0]:
|
||||
if int((border[2] - border[0]) * multiplier) < self.size[0]:
|
||||
self.noHPV = True
|
||||
self.border[0] /= 2
|
||||
if int((border[3] - border[1]) * 1.5) < self.size[1]:
|
||||
if int((border[3] - border[1]) * multiplier) < self.size[1]:
|
||||
self.noVPV = True
|
||||
self.border[1] /= 2
|
||||
else:
|
||||
self.border = [0, 0, 0, 0]
|
||||
self.noHPV = True
|
||||
|
||||
Reference in New Issue
Block a user