Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default file output format #41

Merged
merged 3 commits into from
Mar 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions kcc/comic2ebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions kcc/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def initialize(self):
'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),
Expand All @@ -110,7 +110,7 @@ def initialize(self):
'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",
Expand Down Expand Up @@ -168,8 +168,8 @@ def convert(self):
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())
Expand Down
8 changes: 4 additions & 4 deletions kcc/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ def __init__(self, source, device):
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))

Expand Down