mirror of
https://github.com/ciromattia/kcc
synced 2025-12-20 21:22:05 +00:00
Merge pull request #41 from ciromattia/kcc-outputformat2
Change default file output format
This commit is contained in:
@@ -297,7 +297,7 @@ def applyImgOptimization(img, isSplit=False, toRight=False):
|
|||||||
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,
|
||||||
options.nopanelviewhq)
|
options.nopanelviewhq)
|
||||||
img.optimizeImage(options.gamma)
|
img.optimizeImage(options.gamma)
|
||||||
if not options.notquantize:
|
if options.forcepng:
|
||||||
img.quantizeImage()
|
img.quantizeImage()
|
||||||
|
|
||||||
|
|
||||||
@@ -337,17 +337,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.notquantize)
|
img0.saveToDir(dirpath, options.forcepng)
|
||||||
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.notquantize)
|
img1.saveToDir(dirpath, options.forcepng)
|
||||||
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.notquantize)
|
img.saveToDir(dirpath, options.forcepng)
|
||||||
|
|
||||||
|
|
||||||
def genEpubStruct(path):
|
def genEpubStruct(path):
|
||||||
@@ -560,8 +560,8 @@ def main(argv=None):
|
|||||||
help="Disable high quality Panel View [Default=False]")
|
help="Disable high quality Panel View [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("--forcepng", action="store_true", dest="forcepng", default=False,
|
||||||
help="Disable image quantization [Default=False]")
|
help="Create PNG files instead JPEG (For non-Kindle devices) [Default=False]")
|
||||||
parser.add_option("--gamma", type="float", dest="gamma", default="0.0",
|
parser.add_option("--gamma", type="float", dest="gamma", default="0.0",
|
||||||
help="Apply gamma correction to linearize the image [Default=Auto]")
|
help="Apply gamma correction to linearize the image [Default=Auto]")
|
||||||
parser.add_option("--upscale", action="store_true", dest="upscale", default=False,
|
parser.add_option("--upscale", action="store_true", dest="upscale", default=False,
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class MainWindow:
|
|||||||
'Bmangastyle': IntVar(None, 0),
|
'Bmangastyle': IntVar(None, 0),
|
||||||
'Cnopanelviewhq': IntVar(None, 0),
|
'Cnopanelviewhq': IntVar(None, 0),
|
||||||
'Dimage_preprocess': IntVar(None, 0),
|
'Dimage_preprocess': IntVar(None, 0),
|
||||||
'Enotquantize': IntVar(None, 0),
|
'Eforcepng': IntVar(None, 0),
|
||||||
'Fimage_gamma': DoubleVar(None, 0.0),
|
'Fimage_gamma': DoubleVar(None, 0.0),
|
||||||
'Gimage_upscale': IntVar(None, 0),
|
'Gimage_upscale': IntVar(None, 0),
|
||||||
'Himage_stretch': IntVar(None, 0),
|
'Himage_stretch': IntVar(None, 0),
|
||||||
@@ -110,7 +110,7 @@ class MainWindow:
|
|||||||
'Bmangastyle': "Manga mode",
|
'Bmangastyle': "Manga mode",
|
||||||
'Cnopanelviewhq': "Disable high quality Panel View",
|
'Cnopanelviewhq': "Disable high quality Panel View",
|
||||||
'Dimage_preprocess': "Disable image optimizations",
|
'Dimage_preprocess': "Disable image optimizations",
|
||||||
'Enotquantize': "Disable image quantization",
|
'Eforcepng': "Create PNG files instead JPEG",
|
||||||
'Fimage_gamma': "Custom gamma correction",
|
'Fimage_gamma': "Custom gamma correction",
|
||||||
'Gimage_upscale': "Allow image upscaling",
|
'Gimage_upscale': "Allow image upscaling",
|
||||||
'Himage_stretch': "Stretch images",
|
'Himage_stretch': "Stretch images",
|
||||||
@@ -168,8 +168,8 @@ class MainWindow:
|
|||||||
argv.append("--nopanelviewhq")
|
argv.append("--nopanelviewhq")
|
||||||
if self.options['Dimage_preprocess'].get() == 1:
|
if self.options['Dimage_preprocess'].get() == 1:
|
||||||
argv.append("--noprocessing")
|
argv.append("--noprocessing")
|
||||||
if self.options['Enotquantize'].get() == 1:
|
if self.options['Eforcepng'].get() == 1:
|
||||||
argv.append("--nodithering")
|
argv.append("--forcepng")
|
||||||
if self.options['Fimage_gamma'].get() != 0.0:
|
if self.options['Fimage_gamma'].get() != 0.0:
|
||||||
argv.append("--gamma")
|
argv.append("--gamma")
|
||||||
argv.append(self.options['Fimage_gamma'].get())
|
argv.append(self.options['Fimage_gamma'].get())
|
||||||
|
|||||||
@@ -113,15 +113,15 @@ 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, notquantize):
|
def saveToDir(self, targetdir, forcepng):
|
||||||
filename = os.path.basename(self.origFileName)
|
filename = os.path.basename(self.origFileName)
|
||||||
try:
|
try:
|
||||||
self.image = self.image.convert('L') # convert to grayscale
|
self.image = self.image.convert('L') # convert to grayscale
|
||||||
os.remove(os.path.join(targetdir, filename))
|
os.remove(os.path.join(targetdir, filename))
|
||||||
if notquantize:
|
if forcepng:
|
||||||
self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + ".jpg"), "JPEG")
|
|
||||||
else:
|
|
||||||
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")
|
||||||
|
else:
|
||||||
|
self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + ".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))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user