1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-24 07:01:51 +00:00

Merge pull request #23 from ciromattia/AcidWeb-Scrapbook

Added option to rotate images instead spliting.
This commit is contained in:
Ciro Mattia Gonano
2013-03-02 09:59:12 -08:00
3 changed files with 35 additions and 29 deletions

10
.gitignore vendored
View File

@@ -1,5 +1,5 @@
/*.pyc
/*.cbz
/*.cbr
/.idea
/build
*.pyc
*.cbz
*.cbr
.idea
build

View File

@@ -227,7 +227,7 @@ def dirImgProcess(path):
else:
print ".",
img = image.ComicPage(os.path.join(dirpath, afile), options.profile)
split = img.splitPage(dirpath, options.righttoleft)
split = img.splitPage(dirpath, options.righttoleft, options.rotate)
if split is not None:
if options.verbose:
print "Splitted " + afile
@@ -333,6 +333,8 @@ def main(argv=None):
+ "is not like the device's one [default=False]")
parser.add_option("--no-cut-page-numbers", action="store_false", dest="cutpagenumbers", default=True,
help="Do not try to cut page numbering on images [default=True]")
parser.add_option("--rotate", action="store_true", dest="rotate", default=False,
help="Disable page spliting. Instead rotate images [default=False]")
options, args = parser.parse_args(argv)
if len(args) != 1:
parser.print_help()

View File

@@ -159,12 +159,16 @@ class ComicPage:
self.image = ImageOps.fit(self.image, self.size, method=method, centering=(0.5, 0.5))
return self.image
def splitPage(self, targetdir, righttoleft=False):
def splitPage(self, targetdir, righttoleft=False, rotate=False):
width, height = self.image.size
dstwidth, dstheight = self.size
#print "Image is %d x %d" % (width,height)
# only split if origin is not oriented the same as target
if (width > height) != (dstwidth > dstheight):
if rotate:
self.image = self.image.rotate(90)
return None
else:
if width > height:
# source is landscape, so split by the width
leftbox = (0, 0, width / 2, height)