mirror of
https://github.com/ciromattia/kcc
synced 2026-10-15 05:52:33 +00:00
+12
-7
@@ -342,17 +342,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)
|
img0.saveToDir(dirpath, options.forcepng, options.forcecolor)
|
||||||
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)
|
img1.saveToDir(dirpath, options.forcepng, options.forcecolor)
|
||||||
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)
|
img.saveToDir(dirpath, options.forcepng, options.forcecolor)
|
||||||
|
|
||||||
|
|
||||||
def genEpubStruct(path):
|
def genEpubStruct(path):
|
||||||
@@ -586,7 +586,8 @@ def main(argv=None):
|
|||||||
usage = "Usage: %prog [options] comic_file|comic_folder"
|
usage = "Usage: %prog [options] comic_file|comic_folder"
|
||||||
parser = OptionParser(usage=usage, version=__version__)
|
parser = OptionParser(usage=usage, version=__version__)
|
||||||
parser.add_option("-p", "--profile", action="store", dest="profile", default="KHD",
|
parser.add_option("-p", "--profile", action="store", dest="profile", default="KHD",
|
||||||
help="Device profile (Choose one among K1, K2, K3, K4NT, K4T, KDX, KDXG or KHD) [Default=KHD]")
|
help="Device profile (Choose one among K1, K2, K3, K4NT, K4T, KDX, KDXG, KHD, KF, KFHD, KFHD8) "
|
||||||
|
"[Default=KHD]")
|
||||||
parser.add_option("-t", "--title", action="store", dest="title", default="defaulttitle",
|
parser.add_option("-t", "--title", action="store", dest="title", default="defaulttitle",
|
||||||
help="Comic title [Default=filename]")
|
help="Comic title [Default=filename]")
|
||||||
parser.add_option("-m", "--manga-style", action="store_true", dest="righttoleft", default=False,
|
parser.add_option("-m", "--manga-style", action="store_true", dest="righttoleft", default=False,
|
||||||
@@ -655,8 +656,7 @@ def getOutputFilename(srcpath, wantedname, ext):
|
|||||||
elif os.path.isdir(srcpath):
|
elif os.path.isdir(srcpath):
|
||||||
filename = os.path.abspath(options.output) + "/" + os.path.basename(srcpath) + ext
|
filename = os.path.abspath(options.output) + "/" + os.path.basename(srcpath) + ext
|
||||||
else:
|
else:
|
||||||
filename = os.path.abspath(options.output) + "/" \
|
filename = os.path.abspath(options.output) + "/" + os.path.basename(os.path.splitext(srcpath)[0]) + ext
|
||||||
+ os.path.basename(os.path.splitext(srcpath)[0]) + ext
|
|
||||||
elif os.path.isdir(srcpath):
|
elif os.path.isdir(srcpath):
|
||||||
filename = srcpath + ext
|
filename = srcpath + ext
|
||||||
else:
|
else:
|
||||||
@@ -678,8 +678,13 @@ def checkOptions():
|
|||||||
else:
|
else:
|
||||||
#Virtual Panel View
|
#Virtual Panel View
|
||||||
options.panelview = False
|
options.panelview = False
|
||||||
if options.profile == 'K1' or options.profile == 'K2' or options.profile == 'KDX' or options.profile == 'KDXG':
|
if options.profile == 'K1' or options.profile == 'K2' or options.profile == 'KDX' or options.profile == 'KDXG'\
|
||||||
|
or options.profile == 'KF' or options.profile == 'KFHD' or options.profile == 'KFHD8':
|
||||||
options.nopanelviewhq = True
|
options.nopanelviewhq = True
|
||||||
|
if options.profile == 'KF' or options.profile == 'KFHD' or options.profile == 'KFHD8':
|
||||||
|
options.forcecolor = True
|
||||||
|
else:
|
||||||
|
options.forcecolor = False
|
||||||
|
|
||||||
|
|
||||||
def getEpubPath():
|
def getEpubPath():
|
||||||
|
|||||||
+11
-4
@@ -84,7 +84,10 @@ class ProfileData:
|
|||||||
'K4T': ("Kindle Touch", (600, 800), Palette16, 1.8, (900, 1200)),
|
'K4T': ("Kindle Touch", (600, 800), Palette16, 1.8, (900, 1200)),
|
||||||
'KHD': ("Kindle Paperwhite", (758, 1024), Palette16, 1.8, (1137, 1536)),
|
'KHD': ("Kindle Paperwhite", (758, 1024), Palette16, 1.8, (1137, 1536)),
|
||||||
'KDX': ("Kindle DX", (824, 1200), Palette15, 1.8, (1236, 1800)),
|
'KDX': ("Kindle DX", (824, 1200), Palette15, 1.8, (1236, 1800)),
|
||||||
'KDXG': ("Kindle DXG", (824, 1200), Palette16, 1.8, (1236, 1800))
|
'KDXG': ("Kindle DXG", (824, 1200), Palette16, 1.8, (1236, 1800)),
|
||||||
|
'KF': ("Kindle Fire", (600, 1024), Palette16, 1.0, (900, 1536)),
|
||||||
|
'KFHD': ("Kindle Fire HD 7\"", (800, 1280), Palette16, 1.0, (1200, 1920)),
|
||||||
|
'KFHD8': ("Kindle Fire HD 8.9\"", (1200, 1920), Palette16, 1.0, (1800, 2880))
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileLabels = {
|
ProfileLabels = {
|
||||||
@@ -95,7 +98,10 @@ class ProfileData:
|
|||||||
"Kindle 4/Touch": 'K4T',
|
"Kindle 4/Touch": 'K4T',
|
||||||
"Kindle Paperwhite": 'KHD',
|
"Kindle Paperwhite": 'KHD',
|
||||||
"Kindle DX": 'KDX',
|
"Kindle DX": 'KDX',
|
||||||
"Kindle DXG": 'KDXG'
|
"Kindle DXG": 'KDXG',
|
||||||
|
"Kindle Fire": 'KF',
|
||||||
|
"Kindle Fire HD 7\"": 'KFHD',
|
||||||
|
"Kindle Fire HD 8.9\"": 'KFHD8'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -113,10 +119,11 @@ 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):
|
def saveToDir(self, targetdir, forcepng, color):
|
||||||
filename = os.path.basename(self.origFileName)
|
filename = os.path.basename(self.origFileName)
|
||||||
try:
|
try:
|
||||||
self.image = self.image.convert('L') # convert to grayscale
|
if not color:
|
||||||
|
self.image = self.image.convert('L') # convert to grayscale
|
||||||
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] + ".png"), "PNG")
|
||||||
|
|||||||
Reference in New Issue
Block a user