mirror of
https://github.com/ciromattia/kcc
synced 2025-12-15 18:56:28 +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,
|
||||
options.nopanelviewhq)
|
||||
img.optimizeImage(options.gamma)
|
||||
if not options.notquantize:
|
||||
if options.forcepng:
|
||||
img.quantizeImage()
|
||||
|
||||
|
||||
@@ -337,17 +337,17 @@ def dirImgProcess(path):
|
||||
facing = "left"
|
||||
img0 = image.ComicPage(split[0], options.profile)
|
||||
applyImgOptimization(img0, True, toRight1)
|
||||
img0.saveToDir(dirpath, options.notquantize)
|
||||
img0.saveToDir(dirpath, options.forcepng)
|
||||
img1 = image.ComicPage(split[1], options.profile)
|
||||
applyImgOptimization(img1, True, toRight2)
|
||||
img1.saveToDir(dirpath, options.notquantize)
|
||||
img1.saveToDir(dirpath, options.forcepng)
|
||||
else:
|
||||
if facing == "right":
|
||||
facing = "left"
|
||||
else:
|
||||
facing = "right"
|
||||
applyImgOptimization(img)
|
||||
img.saveToDir(dirpath, options.notquantize)
|
||||
img.saveToDir(dirpath, options.forcepng)
|
||||
|
||||
|
||||
def genEpubStruct(path):
|
||||
@@ -560,8 +560,8 @@ def main(argv=None):
|
||||
help="Disable high quality Panel View [Default=False]")
|
||||
parser.add_option("--noprocessing", action="store_false", dest="imgproc", 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,
|
||||
help="Disable image quantization [Default=False]")
|
||||
parser.add_option("--forcepng", action="store_true", dest="forcepng", 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",
|
||||
help="Apply gamma correction to linearize the image [Default=Auto]")
|
||||
parser.add_option("--upscale", action="store_true", dest="upscale", default=False,
|
||||
|
||||
@@ -96,7 +96,7 @@ class MainWindow:
|
||||
'Bmangastyle': IntVar(None, 0),
|
||||
'Cnopanelviewhq': IntVar(None, 0),
|
||||
'Dimage_preprocess': IntVar(None, 0),
|
||||
'Enotquantize': IntVar(None, 0),
|
||||
'Eforcepng': IntVar(None, 0),
|
||||
'Fimage_gamma': DoubleVar(None, 0.0),
|
||||
'Gimage_upscale': IntVar(None, 0),
|
||||
'Himage_stretch': IntVar(None, 0),
|
||||
@@ -110,7 +110,7 @@ class MainWindow:
|
||||
'Bmangastyle': "Manga mode",
|
||||
'Cnopanelviewhq': "Disable high quality Panel View",
|
||||
'Dimage_preprocess': "Disable image optimizations",
|
||||
'Enotquantize': "Disable image quantization",
|
||||
'Eforcepng': "Create PNG files instead JPEG",
|
||||
'Fimage_gamma': "Custom gamma correction",
|
||||
'Gimage_upscale': "Allow image upscaling",
|
||||
'Himage_stretch': "Stretch images",
|
||||
@@ -168,8 +168,8 @@ class MainWindow:
|
||||
argv.append("--nopanelviewhq")
|
||||
if self.options['Dimage_preprocess'].get() == 1:
|
||||
argv.append("--noprocessing")
|
||||
if self.options['Enotquantize'].get() == 1:
|
||||
argv.append("--nodithering")
|
||||
if self.options['Eforcepng'].get() == 1:
|
||||
argv.append("--forcepng")
|
||||
if self.options['Fimage_gamma'].get() != 0.0:
|
||||
argv.append("--gamma")
|
||||
argv.append(self.options['Fimage_gamma'].get())
|
||||
|
||||
@@ -113,15 +113,15 @@ class ComicPage:
|
||||
raise RuntimeError('Cannot read image file %s' % source)
|
||||
self.image = self.image.convert('RGB')
|
||||
|
||||
def saveToDir(self, targetdir, notquantize):
|
||||
def saveToDir(self, targetdir, forcepng):
|
||||
filename = os.path.basename(self.origFileName)
|
||||
try:
|
||||
self.image = self.image.convert('L') # convert to grayscale
|
||||
os.remove(os.path.join(targetdir, filename))
|
||||
if notquantize:
|
||||
self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + ".jpg"), "JPEG")
|
||||
else:
|
||||
if forcepng:
|
||||
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:
|
||||
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user