1
0
mirror of https://github.com/ciromattia/kcc synced 2026-06-27 08:44:05 +00:00

Fixed panel order for horizontal pages when --rotate is enabled

This commit is contained in:
Paweł Jastrzębski
2013-05-27 15:21:16 +02:00
parent c0610360a3
commit 3e007965b2
3 changed files with 21 additions and 12 deletions
+3 -2
View File
@@ -147,7 +147,7 @@ The app relies and includes the following scripts/binaries:
* Add rendition:layout and rendition:orientation ePub meta tags (supported by new kindlegen 2.8) * Add rendition:layout and rendition:orientation ePub meta tags (supported by new kindlegen 2.8)
* Fixed natural sorting for files (#18) * Fixed natural sorting for files (#18)
####2.7: ####2.7
* Lots of GUI improvements (#27, #13) * Lots of GUI improvements (#27, #13)
* Added gamma support within --gamma option (defaults to profile-specified gamma) (#26, #27) * Added gamma support within --gamma option (defaults to profile-specified gamma) (#26, #27)
* Added --nodithering option to prevent dithering optimizations (#27) * Added --nodithering option to prevent dithering optimizations (#27)
@@ -167,7 +167,7 @@ The app relies and includes the following scripts/binaries:
* Added generic CSS file * Added generic CSS file
* Optimized archive extraction for zip/rar files (#40) * Optimized archive extraction for zip/rar files (#40)
####2.9: ####2.9
* Added support for generating a plain CBZ (skipping all the EPUB/Mobi generation) (#45) * Added support for generating a plain CBZ (skipping all the EPUB/Mobi generation) (#45)
* Prevent output file overwriting the source one: if a duplicate name is detected, append _kcc to the name * Prevent output file overwriting the source one: if a duplicate name is detected, append _kcc to the name
* Rarfile library updated to 2.6 * Rarfile library updated to 2.6
@@ -177,6 +177,7 @@ The app relies and includes the following scripts/binaries:
####2.10: ####2.10:
* Kindle Fire support (color ePub/Mobi) * Kindle Fire support (color ePub/Mobi)
* Panel View support for horizontal content * Panel View support for horizontal content
* Fixed panel order for horizontal pages when --rotate is enabled
## COPYRIGHT ## COPYRIGHT
+10 -6
View File
@@ -40,6 +40,10 @@ import pdfjpgextract
def buildHTML(path, imgfile): def buildHTML(path, imgfile):
filename = getImageFileName(imgfile) filename = getImageFileName(imgfile)
if filename is not None: if filename is not None:
if "_rotated" in str(filename):
rotate = True
else:
rotate = False
htmlpath = '' htmlpath = ''
postfix = '' postfix = ''
backref = 1 backref = 1
@@ -70,7 +74,7 @@ def buildHTML(path, imgfile):
imgfile, "\" class=\"singlePage\"/></div>\n" imgfile, "\" class=\"singlePage\"/></div>\n"
]) ])
if options.panelview: if options.panelview:
if options.panelviewhorizontal: if options.panelviewhorizontal or rotate:
if options.righttoleft: if options.righttoleft:
f.writelines(["<div id=\"BoxTL\"><a class=\"app-amzn-magnify\" data-app-amzn-magnify=", f.writelines(["<div id=\"BoxTL\"><a class=\"app-amzn-magnify\" data-app-amzn-magnify=",
"'{\"targetId\":\"BoxTL-Panel-Parent\", \"ordinal\":1}'></a></div>\n", "'{\"targetId\":\"BoxTL-Panel-Parent\", \"ordinal\":1}'></a></div>\n",
@@ -348,7 +352,7 @@ def dirImgProcess(path):
split = None split = None
else: else:
split = img.splitPage(dirpath, options.righttoleft, options.rotate) split = img.splitPage(dirpath, options.righttoleft, options.rotate)
if split is not None: if split is not None and split is not "R":
if options.verbose: if options.verbose:
print "Splitted " + afile print "Splitted " + afile
if options.righttoleft: if options.righttoleft:
@@ -365,17 +369,17 @@ def dirImgProcess(path):
facing = "left" facing = "left"
img0 = image.ComicPage(split[0], options.profile) img0 = image.ComicPage(split[0], options.profile)
applyImgOptimization(img0, True, toRight1) applyImgOptimization(img0, True, toRight1)
img0.saveToDir(dirpath, options.forcepng, options.forcecolor) img0.saveToDir(dirpath, options.forcepng, options.forcecolor, split)
img1 = image.ComicPage(split[1], options.profile) img1 = image.ComicPage(split[1], options.profile)
applyImgOptimization(img1, True, toRight2) applyImgOptimization(img1, True, toRight2)
img1.saveToDir(dirpath, options.forcepng, options.forcecolor) img1.saveToDir(dirpath, options.forcepng, options.forcecolor, split)
else: else:
if facing == "right": if facing == "right":
facing = "left" facing = "left"
else: else:
facing = "right" facing = "right"
applyImgOptimization(img) applyImgOptimization(img)
img.saveToDir(dirpath, options.forcepng, options.forcecolor) img.saveToDir(dirpath, options.forcepng, options.forcecolor, split)
def genEpubStruct(path): def genEpubStruct(path):
@@ -712,7 +716,7 @@ def checkOptions():
options.forcepng = False options.forcepng = False
else: else:
options.forcecolor = False options.forcecolor = False
if options.panelviewhorizontal: if options.panelviewhorizontal or options.rotate:
options.panelview = True options.panelview = True
options.landscapemode = False options.landscapemode = False
+8 -4
View File
@@ -119,16 +119,20 @@ class ComicPage:
raise RuntimeError('Cannot read image file %s' % source) raise RuntimeError('Cannot read image file %s' % source)
self.image = self.image.convert('RGB') self.image = self.image.convert('RGB')
def saveToDir(self, targetdir, forcepng, color): def saveToDir(self, targetdir, forcepng, color, sufix):
filename = os.path.basename(self.origFileName) filename = os.path.basename(self.origFileName)
try: try:
if not color: if not color:
self.image = self.image.convert('L') # convert to grayscale self.image = self.image.convert('L') # convert to grayscale
if sufix == "R":
sufix = "_rotated"
else:
sufix = ""
os.remove(os.path.join(targetdir, filename)) os.remove(os.path.join(targetdir, filename))
if forcepng: if forcepng:
self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + ".png"), "PNG") self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + sufix + ".png"), "PNG")
else: else:
self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + ".jpg"), "JPEG") self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + sufix + ".jpg"), "JPEG")
except IOError as e: except IOError as e:
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e)) raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))
@@ -202,7 +206,7 @@ class ComicPage:
if (width > height) != (dstwidth > dstheight): if (width > height) != (dstwidth > dstheight):
if rotate: if rotate:
self.image = self.image.rotate(90) self.image = self.image.rotate(90)
return None return "R"
else: else:
if width > height: if width > height:
# source is landscape, so split by the width # source is landscape, so split by the width