1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-16 03:06:33 +00:00

Expanded autoscale option

This commit is contained in:
Paweł Jastrzębski
2016-11-21 15:59:14 +01:00
parent 88f005824c
commit aa00ea3aa2

View File

@@ -80,9 +80,6 @@ def main(argv=None):
makeBook(source) makeBook(source)
return 0 return 0
def calculateZoomImageSize(imageSize, deviceRes):
scale = float(deviceRes[0])/float(imageSize[0])
return (float(deviceRes[0]), scale * imageSize[1])
def buildHTML(path, imgfile, imgfilepath): def buildHTML(path, imgfile, imgfilepath):
imgfilepath = md5Checksum(imgfilepath) imgfilepath = md5Checksum(imgfilepath)
@@ -124,14 +121,15 @@ def buildHTML(path, imgfile, imgfilepath):
"url('", "../" * backref, "Images/", postfix, imgfile, "'); " + additionalStyle + "\">\n"]) "url('", "../" * backref, "Images/", postfix, imgfile, "'); " + additionalStyle + "\">\n"])
if options.iskindle and options.panelview: if options.iskindle and options.panelview:
sizeTmp = Image.open(os.path.join(head, "Images", postfix, imgfile)).size sizeTmp = Image.open(os.path.join(head, "Images", postfix, imgfile)).size
size = (int(sizeTmp[0] * 1.5), int(sizeTmp[1] * 1.5))
if options.autoscale: if options.autoscale:
size = calculateZoomImageSize(sizeTmp, deviceres) size = (getPanelViewResolution(sizeTmp, deviceres))
if size[0] <= deviceres[0]: else:
size = (int(sizeTmp[0] * 1.5), int(sizeTmp[1] * 1.5))
if size[0] - deviceres[0] < deviceres[0] * 0.01:
noHorizontalPV = True noHorizontalPV = True
else: else:
noHorizontalPV = False noHorizontalPV = False
if size[1] <= deviceres[1]: if size[1] - deviceres[1] < deviceres[1] * 0.01:
noVerticalPV = True noVerticalPV = True
else: else:
noVerticalPV = False noVerticalPV = False
@@ -674,6 +672,11 @@ def getDirectorySize(start_path='.'):
return total_size return total_size
def getPanelViewResolution(imageSize, deviceRes):
scale = float(deviceRes[0]) / float(imageSize[0])
return int(deviceRes[0]), int(scale * imageSize[1])
def getPanelViewSize(deviceres, size): def getPanelViewSize(deviceres, size):
x = int(deviceres[0] / 2 - size[0] / 2) / deviceres[0] * 100 x = int(deviceres[0] / 2 - size[0] / 2) / deviceres[0] * 100
y = int(deviceres[1] / 2 - size[1] / 2) / deviceres[1] * 100 y = int(deviceres[1] / 2 - size[1] / 2) / deviceres[1] * 100
@@ -931,11 +934,10 @@ def makeParser():
mainOptions.add_option("-p", "--profile", action="store", dest="profile", default="KV", mainOptions.add_option("-p", "--profile", action="store", dest="profile", default="KV",
help="Device profile (Available options: K1, K2, K3, K45, KDX, KPW, KV, KoMT, KoG, KoGHD," help="Device profile (Available options: K1, K2, K3, K45, KDX, KPW, KV, KoMT, KoG, KoGHD,"
" KoA, KoAHD, KoAH2O, KoAO) [Default=KV]") " KoA, KoAHD, KoAH2O, KoAO) [Default=KV]")
mainOptions.add_option("-a", "--auto-scale", action="store_true", dest="autoscale", default=False,
help="Auto scale image in panel view by width. The zoom-in mode will have two view ports"
"(top and bottom)")
mainOptions.add_option("-m", "--manga-style", action="store_true", dest="righttoleft", default=False, mainOptions.add_option("-m", "--manga-style", action="store_true", dest="righttoleft", default=False,
help="Manga style (right-to-left reading and splitting)") help="Manga style (right-to-left reading and splitting)")
mainOptions.add_option("-2", "--two-panel", action="store_true", dest="autoscale", default=False,
help="Display two not four panels in Panel View mode")
mainOptions.add_option("-w", "--webtoon", action="store_true", dest="webtoon", default=False, mainOptions.add_option("-w", "--webtoon", action="store_true", dest="webtoon", default=False,
help="Webtoon processing mode"), help="Webtoon processing mode"),