mirror of
https://github.com/ciromattia/kcc
synced 2026-01-30 08:57:40 +00:00
MAJOR Landscape Mode improvement
No idea how this change will impact Non-Kindle devices but quality increase of spitted pages is amazing.
This commit is contained in:
@@ -289,11 +289,11 @@ def isInFilelist(filename, filelist):
|
||||
return seen
|
||||
|
||||
|
||||
def applyImgOptimization(img, isSplit=False, toRight=False):
|
||||
def applyImgOptimization(img, isSplit=False):
|
||||
img.cropWhiteSpace(10.0)
|
||||
if options.cutpagenumbers:
|
||||
img.cutPageNumber()
|
||||
img.resizeImage(options.upscale, options.stretch, options.black_borders, isSplit, toRight, options.landscapemode,
|
||||
img.resizeImage(options.upscale, options.stretch, options.black_borders, isSplit, options.landscapemode,
|
||||
options.panelviewhq)
|
||||
img.optimizeImage(options.gamma)
|
||||
if not options.notquantize:
|
||||
@@ -322,12 +322,6 @@ def dirImgProcess(path):
|
||||
if split is not None:
|
||||
if options.verbose:
|
||||
print "Splitted " + afile
|
||||
if options.righttoleft:
|
||||
toRight1 = False
|
||||
toRight2 = True
|
||||
else:
|
||||
toRight1 = True
|
||||
toRight2 = False
|
||||
if options.righttoleft:
|
||||
if facing == "left":
|
||||
splitCount += 1
|
||||
@@ -337,10 +331,10 @@ def dirImgProcess(path):
|
||||
splitCount += 1
|
||||
facing = "left"
|
||||
img0 = image.ComicPage(split[0], options.profile)
|
||||
applyImgOptimization(img0, True, toRight1)
|
||||
applyImgOptimization(img0, True)
|
||||
img0.saveToDir(dirpath, options.notquantize)
|
||||
img1 = image.ComicPage(split[1], options.profile)
|
||||
applyImgOptimization(img1, True, toRight2)
|
||||
applyImgOptimization(img1, True)
|
||||
img1.saveToDir(dirpath, options.notquantize)
|
||||
else:
|
||||
if facing == "right":
|
||||
|
||||
12
kcc/image.py
12
kcc/image.py
@@ -143,8 +143,8 @@ class ComicPage:
|
||||
palImg.putpalette(self.palette)
|
||||
self.image = self.image.quantize(palette=palImg)
|
||||
|
||||
def resizeImage(self, upscale=False, stretch=False, black_borders=False, isSplit=False, toRight=False,
|
||||
landscapeMode=False, panelViewHQ=False):
|
||||
def resizeImage(self, upscale=False, stretch=False, black_borders=False, isSplit=False, landscapeMode=False,
|
||||
panelViewHQ=False):
|
||||
method = Image.ANTIALIAS
|
||||
if black_borders:
|
||||
fill = 'black'
|
||||
@@ -157,20 +157,12 @@ class ComicPage:
|
||||
if self.image.size[0] <= self.size[0] and self.image.size[1] <= self.size[1]:
|
||||
if not upscale:
|
||||
if isSplit and landscapeMode:
|
||||
borderw = (self.size[0] - self.image.size[0])
|
||||
borderh = (self.size[1] - self.image.size[1]) / 2
|
||||
self.image = ImageOps.expand(self.image, border=(0, borderh), fill=fill)
|
||||
tempImg = Image.new(self.image.mode, (self.image.size[0] + borderw, self.image.size[1]), fill)
|
||||
if toRight:
|
||||
tempImg.paste(self.image, (borderw, 0))
|
||||
else:
|
||||
tempImg.paste(self.image, (0, 0))
|
||||
self.image = tempImg
|
||||
else:
|
||||
borderw = (self.size[0] - self.image.size[0]) / 2
|
||||
borderh = (self.size[1] - self.image.size[1]) / 2
|
||||
self.image = ImageOps.expand(self.image, border=(borderw, borderh), fill=fill)
|
||||
return self.image
|
||||
else:
|
||||
method = Image.NEAREST
|
||||
if stretch:
|
||||
|
||||
Reference in New Issue
Block a user