1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-26 08:01:52 +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

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)
* Fixed natural sorting for files (#18)
####2.7:
####2.7
* Lots of GUI improvements (#27, #13)
* Added gamma support within --gamma option (defaults to profile-specified gamma) (#26, #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
* 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)
* Prevent output file overwriting the source one: if a duplicate name is detected, append _kcc to the name
* Rarfile library updated to 2.6
@@ -177,6 +177,7 @@ The app relies and includes the following scripts/binaries:
####2.10:
* Kindle Fire support (color ePub/Mobi)
* Panel View support for horizontal content
* Fixed panel order for horizontal pages when --rotate is enabled
## COPYRIGHT

View File

@@ -40,6 +40,10 @@ import pdfjpgextract
def buildHTML(path, imgfile):
filename = getImageFileName(imgfile)
if filename is not None:
if "_rotated" in str(filename):
rotate = True
else:
rotate = False
htmlpath = ''
postfix = ''
backref = 1
@@ -70,7 +74,7 @@ def buildHTML(path, imgfile):
imgfile, "\" class=\"singlePage\"/></div>\n"
])
if options.panelview:
if options.panelviewhorizontal:
if options.panelviewhorizontal or rotate:
if options.righttoleft:
f.writelines(["<div id=\"BoxTL\"><a class=\"app-amzn-magnify\" data-app-amzn-magnify=",
"'{\"targetId\":\"BoxTL-Panel-Parent\", \"ordinal\":1}'></a></div>\n",
@@ -348,7 +352,7 @@ def dirImgProcess(path):
split = None
else:
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:
print "Splitted " + afile
if options.righttoleft:
@@ -365,17 +369,17 @@ def dirImgProcess(path):
facing = "left"
img0 = image.ComicPage(split[0], options.profile)
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)
applyImgOptimization(img1, True, toRight2)
img1.saveToDir(dirpath, options.forcepng, options.forcecolor)
img1.saveToDir(dirpath, options.forcepng, options.forcecolor, split)
else:
if facing == "right":
facing = "left"
else:
facing = "right"
applyImgOptimization(img)
img.saveToDir(dirpath, options.forcepng, options.forcecolor)
img.saveToDir(dirpath, options.forcepng, options.forcecolor, split)
def genEpubStruct(path):
@@ -712,7 +716,7 @@ def checkOptions():
options.forcepng = False
else:
options.forcecolor = False
if options.panelviewhorizontal:
if options.panelviewhorizontal or options.rotate:
options.panelview = True
options.landscapemode = False

View File

@@ -119,16 +119,20 @@ class ComicPage:
raise RuntimeError('Cannot read image file %s' % source)
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)
try:
if not color:
self.image = self.image.convert('L') # convert to grayscale
if sufix == "R":
sufix = "_rotated"
else:
sufix = ""
os.remove(os.path.join(targetdir, filename))
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:
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:
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))
@@ -202,7 +206,7 @@ class ComicPage:
if (width > height) != (dstwidth > dstheight):
if rotate:
self.image = self.image.rotate(90)
return None
return "R"
else:
if width > height:
# source is landscape, so split by the width