Draft of FakePanelView Landscape mode
This commit is contained in:
1 parent
ca5854a8bd
commit
750b55649a
2 files changed
+60
-4
No files matched your search
+35
-3
@@ -274,6 +274,8 @@ def applyImgOptimization(img, isSplit=False, toRight=False):
|
|||||||
img.cutPageNumber()
|
img.cutPageNumber()
|
||||||
if options.fakepanelview:
|
if options.fakepanelview:
|
||||||
img.resizeImage(True, False, options.black_borders, False, False, False)
|
img.resizeImage(True, False, options.black_borders, False, False, False)
|
||||||
|
elif options.fakepanelviewlandscape:
|
||||||
|
img.resizeImage(False, False, options.black_borders, False, False, False, True)
|
||||||
else:
|
else:
|
||||||
img.resizeImage(options.upscale, options.stretch, options.black_borders, isSplit, toRight, options.landscapemode)
|
img.resizeImage(options.upscale, options.stretch, options.black_borders, isSplit, toRight, options.landscapemode)
|
||||||
if not options.notquantize:
|
if not options.notquantize:
|
||||||
@@ -351,6 +353,23 @@ def dirImgProcess(path):
|
|||||||
img14 = image.ComicPage(splitB[4], options.profile)
|
img14 = image.ComicPage(splitB[4], options.profile)
|
||||||
applyImgOptimization(img14)
|
applyImgOptimization(img14)
|
||||||
img14.saveToDir(dirpath, options.notquantize)
|
img14.saveToDir(dirpath, options.notquantize)
|
||||||
|
elif options.fakepanelviewlandscape:
|
||||||
|
img0 = image.ComicPage(split[0], options.profile)
|
||||||
|
splitA = img0.splitPageFakePanelViewLandscape(dirpath, options.righttoleft)
|
||||||
|
img01 = image.ComicPage(splitA[0], options.profile)
|
||||||
|
applyImgOptimization(img01)
|
||||||
|
img01.saveToDir(dirpath, options.notquantize)
|
||||||
|
img02 = image.ComicPage(splitA[1], options.profile)
|
||||||
|
applyImgOptimization(img02)
|
||||||
|
img02.saveToDir(dirpath, options.notquantize)
|
||||||
|
img1 = image.ComicPage(split[1], options.profile)
|
||||||
|
splitB = img1.splitPageFakePanelViewLandscape(dirpath, options.righttoleft)
|
||||||
|
img11 = image.ComicPage(splitB[0], options.profile)
|
||||||
|
applyImgOptimization(img11)
|
||||||
|
img11.saveToDir(dirpath, options.notquantize)
|
||||||
|
img12 = image.ComicPage(splitB[1], options.profile)
|
||||||
|
applyImgOptimization(img12)
|
||||||
|
img12.saveToDir(dirpath, options.notquantize)
|
||||||
else:
|
else:
|
||||||
img0 = image.ComicPage(split[0], options.profile)
|
img0 = image.ComicPage(split[0], options.profile)
|
||||||
applyImgOptimization(img0, True, toRight1)
|
applyImgOptimization(img0, True, toRight1)
|
||||||
@@ -380,6 +399,14 @@ def dirImgProcess(path):
|
|||||||
img4 = image.ComicPage(split[4], options.profile)
|
img4 = image.ComicPage(split[4], options.profile)
|
||||||
applyImgOptimization(img4)
|
applyImgOptimization(img4)
|
||||||
img4.saveToDir(dirpath, options.notquantize)
|
img4.saveToDir(dirpath, options.notquantize)
|
||||||
|
elif options.fakepanelviewlandscape:
|
||||||
|
split = img.splitPageFakePanelViewLandscape(dirpath, options.righttoleft)
|
||||||
|
img1 = image.ComicPage(split[0], options.profile)
|
||||||
|
applyImgOptimization(img1)
|
||||||
|
img1.saveToDir(dirpath, options.notquantize)
|
||||||
|
img2 = image.ComicPage(split[1], options.profile)
|
||||||
|
applyImgOptimization(img2)
|
||||||
|
img2.saveToDir(dirpath, options.notquantize)
|
||||||
else:
|
else:
|
||||||
applyImgOptimization(img)
|
applyImgOptimization(img)
|
||||||
img.saveToDir(dirpath, options.notquantize)
|
img.saveToDir(dirpath, options.notquantize)
|
||||||
@@ -499,6 +526,8 @@ def main(argv=None):
|
|||||||
help="Manga style (Right-to-left reading and splitting) [Default=False]")
|
help="Manga style (Right-to-left reading and splitting) [Default=False]")
|
||||||
parser.add_option("--fakepanelview", action="store_true", dest="fakepanelview", default=False,
|
parser.add_option("--fakepanelview", action="store_true", dest="fakepanelview", default=False,
|
||||||
help="Emulate Panel View feature (For Kindle 4 NT or older) [Default=False]")
|
help="Emulate Panel View feature (For Kindle 4 NT or older) [Default=False]")
|
||||||
|
parser.add_option("--fakepanelviewlandscape", action="store_true", dest="fakepanelviewlandscape", default=False,
|
||||||
|
help="Emulate Panel View feature - Landscape mode (For Kindle 4 NT or older) [Default=False]")
|
||||||
parser.add_option("--noprocessing", action="store_false", dest="imgproc", default=True,
|
parser.add_option("--noprocessing", action="store_false", dest="imgproc", default=True,
|
||||||
help="Do not apply image preprocessing (Page splitting and optimizations) [Default=True]")
|
help="Do not apply image preprocessing (Page splitting and optimizations) [Default=True]")
|
||||||
parser.add_option("--nodithering", action="store_true", dest="notquantize", default=False,
|
parser.add_option("--nodithering", action="store_true", dest="notquantize", default=False,
|
||||||
@@ -559,14 +588,17 @@ def checkOptions():
|
|||||||
options.landscapemode = True
|
options.landscapemode = True
|
||||||
else:
|
else:
|
||||||
options.landscapemode = False
|
options.landscapemode = False
|
||||||
if options.fakepanelview and options.profile == 'KHD':
|
if (options.fakepanelview or options.fakepanelviewlandscape) and options.profile == 'KHD':
|
||||||
options.fakepanelview = False
|
options.fakepanelview = False
|
||||||
if options.fakepanelview and options.landscapemode:
|
options.fakepanelviewlandscape = False
|
||||||
|
if (options.fakepanelview or options.fakepanelviewlandscape) and options.landscapemode:
|
||||||
options.landscapemode = False
|
options.landscapemode = False
|
||||||
if options.fakepanelview:
|
if options.fakepanelview or options.fakepanelviewlandscape:
|
||||||
options.imgproc = True
|
options.imgproc = True
|
||||||
options.rotate = False
|
options.rotate = False
|
||||||
options.nosplitrotate = False
|
options.nosplitrotate = False
|
||||||
|
if options.fakepanelview and options.fakepanelviewlandscape:
|
||||||
|
options.fakepanelviewlandscape = False
|
||||||
|
|
||||||
|
|
||||||
def getEpubPath():
|
def getEpubPath():
|
||||||
|
|||||||
+25
-1
@@ -139,12 +139,14 @@ class ComicPage:
|
|||||||
palImg.putpalette(self.palette)
|
palImg.putpalette(self.palette)
|
||||||
self.image = self.image.quantize(palette=palImg)
|
self.image = self.image.quantize(palette=palImg)
|
||||||
|
|
||||||
def resizeImage(self, upscale=False, stretch=False, black_borders=False, isSplit=False, toRight=False, landscapeMode=False):
|
def resizeImage(self, upscale=False, stretch=False, black_borders=False, isSplit=False, toRight=False, landscapeMode=False, fakepanelviewlandscape=False):
|
||||||
method = Image.ANTIALIAS
|
method = Image.ANTIALIAS
|
||||||
if black_borders:
|
if black_borders:
|
||||||
fill = 'black'
|
fill = 'black'
|
||||||
else:
|
else:
|
||||||
fill = 'white'
|
fill = 'white'
|
||||||
|
if fakepanelviewlandscape:
|
||||||
|
self.image = self.image.rotate(90)
|
||||||
if self.image.size[0] <= self.size[0] and self.image.size[1] <= self.size[1]:
|
if self.image.size[0] <= self.size[0] and self.image.size[1] <= self.size[1]:
|
||||||
if not upscale:
|
if not upscale:
|
||||||
if isSplit and landscapeMode:
|
if isSplit and landscapeMode:
|
||||||
@@ -262,6 +264,28 @@ class ComicPage:
|
|||||||
return file0, file1, file2, file3, file4
|
return file0, file1, file2, file3, file4
|
||||||
|
|
||||||
|
|
||||||
|
def splitPageFakePanelViewLandscape(self, targetdir, righttoleft=False):
|
||||||
|
width, height = self.image.size
|
||||||
|
topbox = (0, 0, width, ((height / 2) + (height/9)))
|
||||||
|
bottombox = (0, ((height / 2) - (height/9)), width, height)
|
||||||
|
filename = os.path.splitext(os.path.basename(self.origFileName))
|
||||||
|
file1 = targetdir + '/' + filename[0] + '-1' + filename[1]
|
||||||
|
file2 = targetdir + '/' + filename[0] + '-2' + filename[1]
|
||||||
|
try:
|
||||||
|
page1 = self.image.crop(topbox)
|
||||||
|
page2 = self.image.crop(bottombox)
|
||||||
|
if page1.mode == "P":
|
||||||
|
page1.save(file1, "PNG")
|
||||||
|
page2.save(file2, "PNG")
|
||||||
|
else:
|
||||||
|
page1.save(file1)
|
||||||
|
page2.save(file2)
|
||||||
|
os.remove(self.origFileName)
|
||||||
|
except IOError as e:
|
||||||
|
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))
|
||||||
|
return file1, file2
|
||||||
|
|
||||||
|
|
||||||
def frameImage(self):
|
def frameImage(self):
|
||||||
foreground = tuple(self.palette[:3])
|
foreground = tuple(self.palette[:3])
|
||||||
background = tuple(self.palette[-3:])
|
background = tuple(self.palette[-3:])
|
||||||
|
|||||||
Reference in new issue
Block a user