mirror of
https://github.com/ciromattia/kcc
synced 2026-05-31 11:43:14 +00:00
Merge branch 'master' into kcc-fakepanelview
Apply PEP-8 codestyle
This commit is contained in:
@@ -30,7 +30,7 @@ root = Tk()
|
|||||||
root.resizable(width=False, height=False)
|
root.resizable(width=False, height=False)
|
||||||
root.config(padx=5, pady=5, takefocus=True)
|
root.config(padx=5, pady=5, takefocus=True)
|
||||||
root.title("Kindle Comic Converter v" + __version__)
|
root.title("Kindle Comic Converter v" + __version__)
|
||||||
root.wm_attributes("-topmost", 1)
|
#root.wm_attributes("-topmost", 1)
|
||||||
if platform == 'darwin':
|
if platform == 'darwin':
|
||||||
os.environ['PATH'] = '/usr/local/bin:' + os.environ['PATH']
|
os.environ['PATH'] = '/usr/local/bin:' + os.environ['PATH']
|
||||||
elif platform == 'win32':
|
elif platform == 'win32':
|
||||||
|
|||||||
+5
-2
@@ -130,6 +130,7 @@ def buildNCX(dstdir, title, chapters):
|
|||||||
|
|
||||||
def buildOPF(profile, dstdir, title, filelist, cover=None, righttoleft=False):
|
def buildOPF(profile, dstdir, title, filelist, cover=None, righttoleft=False):
|
||||||
opffile = os.path.join(dstdir, 'OEBPS', 'content.opf')
|
opffile = os.path.join(dstdir, 'OEBPS', 'content.opf')
|
||||||
|
# read the first file resolution
|
||||||
profilelabel, deviceres, palette, gamma = image.ProfileData.Profiles[profile]
|
profilelabel, deviceres, palette, gamma = image.ProfileData.Profiles[profile]
|
||||||
imgres = str(deviceres[0]) + "x" + str(deviceres[1])
|
imgres = str(deviceres[0]) + "x" + str(deviceres[1])
|
||||||
if righttoleft:
|
if righttoleft:
|
||||||
@@ -268,11 +269,11 @@ def isInFilelist(filename, filelist):
|
|||||||
|
|
||||||
|
|
||||||
def applyImgOptimization(img, isSplit=False, toRight=False):
|
def applyImgOptimization(img, isSplit=False, toRight=False):
|
||||||
img.optimizeImage(options.gamma)
|
|
||||||
img.cropWhiteSpace(10.0)
|
img.cropWhiteSpace(10.0)
|
||||||
if options.cutpagenumbers:
|
if options.cutpagenumbers:
|
||||||
img.cutPageNumber()
|
img.cutPageNumber()
|
||||||
img.resizeImage(options.upscale, options.stretch, options.black_borders, options.fakepanelviewlandscape, isSplit, toRight, options.landscapemode)
|
img.resizeImage(options.upscale, options.stretch, options.black_borders, isSplit, toRight)
|
||||||
|
img.optimizeImage(options.gamma)
|
||||||
if not options.notquantize:
|
if not options.notquantize:
|
||||||
img.quantizeImage()
|
img.quantizeImage()
|
||||||
|
|
||||||
@@ -403,6 +404,7 @@ def genEpubStruct(path):
|
|||||||
cover = os.path.join(filelist[-1][0], 'cover' + getImageFileName(filelist[-1][1])[1])
|
cover = os.path.join(filelist[-1][0], 'cover' + getImageFileName(filelist[-1][1])[1])
|
||||||
copyfile(os.path.join(filelist[-1][0], filelist[-1][1]), cover)
|
copyfile(os.path.join(filelist[-1][0], filelist[-1][1]), cover)
|
||||||
buildNCX(path, options.title, chapterlist)
|
buildNCX(path, options.title, chapterlist)
|
||||||
|
# ensure we're sorting files alphabetically
|
||||||
convert = lambda text: int(text) if text.isdigit() else text
|
convert = lambda text: int(text) if text.isdigit() else text
|
||||||
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
|
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
|
||||||
filelist.sort(key=lambda name: (alphanum_key(name[0].lower()), alphanum_key(name[1].lower())))
|
filelist.sort(key=lambda name: (alphanum_key(name[0].lower()), alphanum_key(name[1].lower())))
|
||||||
@@ -502,6 +504,7 @@ def main(argv=None):
|
|||||||
dirImgProcess(path + "/OEBPS/Images/")
|
dirImgProcess(path + "/OEBPS/Images/")
|
||||||
print "\nCreating ePub structure..."
|
print "\nCreating ePub structure..."
|
||||||
genEpubStruct(path)
|
genEpubStruct(path)
|
||||||
|
# actually zip the ePub
|
||||||
if options.output is not None:
|
if options.output is not None:
|
||||||
if options.output.endswith('.epub'):
|
if options.output.endswith('.epub'):
|
||||||
epubpath = os.path.abspath(options.output)
|
epubpath = os.path.abspath(options.output)
|
||||||
|
|||||||
@@ -132,6 +132,8 @@ class ComicPage:
|
|||||||
self.image = ImageOps.autocontrast(Image.eval(self.image, lambda a: 255 * (a / 255.) ** gamma))
|
self.image = ImageOps.autocontrast(Image.eval(self.image, lambda a: 255 * (a / 255.) ** gamma))
|
||||||
|
|
||||||
def quantizeImage(self):
|
def quantizeImage(self):
|
||||||
|
self.image = self.image.convert('L') # convert to grayscale
|
||||||
|
self.image = self.image.convert("RGB") # convert back to RGB
|
||||||
colors = len(self.palette) / 3
|
colors = len(self.palette) / 3
|
||||||
if colors < 256:
|
if colors < 256:
|
||||||
self.palette += self.palette[:3] * (256 - colors)
|
self.palette += self.palette[:3] * (256 - colors)
|
||||||
|
|||||||
Reference in New Issue
Block a user