1
0
mirror of https://github.com/ciromattia/kcc synced 2026-01-04 20:39:28 +00:00

Multiprocessing - final final touches + Code cleanup (close #39)

This commit is contained in:
Paweł Jastrzębski
2013-05-28 11:24:37 +02:00
parent 6c468a5291
commit 28dcab8ee8
3 changed files with 7 additions and 78 deletions

View File

@@ -174,6 +174,7 @@ The app relies and includes the following scripts/binaries:
* Filenames slugifications (#28, #31, #9, #8)
####2.10:
* Multiprocessing support
* Kindle Fire support (color ePub/Mobi)
* Panel View support for horizontal content
* Fixed panel order for horizontal pages when --rotate is enabled

View File

@@ -315,15 +315,6 @@ def getImageFileName(imgfile):
return filename
def isInFilelist(filename, filelist):
filename = os.path.splitext(filename)
seen = False
for item in filelist:
if filename[0] == item[0]:
seen = True
return seen
def applyImgOptimization(img, isSplit, toRight, options):
img.cropWhiteSpace(10.0)
if options.cutpagenumbers:
@@ -355,6 +346,7 @@ def dirImgProcess(path):
if (page + pagenumbermodifier) % 2 == 0:
splitCount += 1
pagenumbermodifier += 1
pagenumbermodifier += 1
def fileImgProcess(work):
@@ -403,8 +395,8 @@ def genEpubStruct(path):
sanitizeTree(os.path.join(path, 'OEBPS', 'Images'))
os.mkdir(os.path.join(path, 'OEBPS', 'Text'))
f = open(os.path.join(path, 'OEBPS', 'Text', 'style.css'), 'w')
#DON'T COMPRESS CSS. KINDLE WILL FAIL TO PARSE IT.
#Generic Panel View support + Margins fix for Non-Kindle devices.
# DON'T COMPRESS CSS. KINDLE WILL FAIL TO PARSE IT.
# Generic Panel View support + Margins fix for Non-Kindle devices.
f.writelines(["@page {\n",
"margin-bottom: 0;\n",
"margin-top: 0\n",
@@ -527,13 +519,6 @@ def genEpubStruct(path):
for afile in filenames:
filename = getImageFileName(afile)
if filename is not None:
if "credit" in afile.lower():
os.rename(os.path.join(dirpath, afile), os.path.join(dirpath, 'ZZZ999_' + afile))
afile = 'ZZZ999_' + afile
if "+" in afile.lower() or "#" in afile.lower():
newfilename = afile.replace('+', '_').replace('#', '_')
os.rename(os.path.join(dirpath, afile), os.path.join(dirpath, newfilename))
afile = newfilename
filelist.append(buildHTML(dirpath, afile))
if not chapter:
chapterlist.append((dirpath.replace('Images', 'Text'), filelist[-1][1]))
@@ -612,11 +597,11 @@ def sanitizeTree(filetree):
def Copyright():
print ('comic2ebook v%(__version__)s. '
'Written 2012 by Ciro Mattia Gonano.' % globals())
'Written 2013 by Ciro Mattia Gonano and Pawel Jastrzebski.' % globals())
def Usage():
print "Generates HTML, NCX and OPF for a Comic ebook from a bunch of images."
print "Generates EPUB/CBZ comic ebook from a bunch of images."
parser.print_help()
@@ -743,6 +728,7 @@ def getEpubPath():
global epub_path
return epub_path
if __name__ == "__main__":
Copyright()
main(sys.argv[1:])

View File

@@ -327,61 +327,3 @@ class ComicPage:
self.image = self.image.crop((0, 0, widthImg - diff, heightImg))
# print "New size: %sx%s"%(self.image.size[0],self.image.size[1])
return self.image
# def addProgressbar(self, file_number, files_totalnumber, size, howoften):
# if file_number // howoften != float(file_number) / howoften:
# return self.image
# white = (255, 255, 255)
# black = (0, 0, 0)
# widthDev, heightDev = size
# widthImg, heightImg = self.image.size
# pastePt = (
# max(0, (widthDev - widthImg) / 2),
# max(0, (heightDev - heightImg) / 2)
# )
# imageBg = Image.new('RGB', size, white)
# imageBg.paste(self.image, pastePt)
# self.image = imageBg
# widthImg, heightImg = self.image.size
# draw = ImageDraw.Draw(self.image)
# #Black rectangle
# draw.rectangle([(0, heightImg - 3), (widthImg, heightImg)], outline=black, fill=black)
# #White rectangle
# draw.rectangle([(widthImg * file_number / files_totalnumber, heightImg - 3), (widthImg - 1, heightImg)],
# outline=black, fill=white)
# #Making notches
# for i in range(1, 10):
# if i <= (10 * file_number / files_totalnumber):
# notch_colour = white # White
# else:
# notch_colour = black # Black
# draw.line([(widthImg * float(i) / 10, heightImg - 3), (widthImg * float(i) / 10, heightImg)],
# fill=notch_colour)
# #The 50%
# if i == 5:
# draw.rectangle([(widthImg / 2 - 1, heightImg - 5), (widthImg / 2 + 1, heightImg)],
# outline=black, fill=notch_colour)
# return self.image
#
# def frameImage(self):
# foreground = tuple(self.palette[:3])
# background = tuple(self.palette[-3:])
# widthDev, heightDev = self.size
# widthImg, heightImg = self.image.size
# pastePt = (
# max(0, (widthDev - widthImg) / 2),
# max(0, (heightDev - heightImg) / 2)
# )
# corner1 = (
# pastePt[0] - 1,
# pastePt[1] - 1
# )
# corner2 = (
# pastePt[0] + widthImg + 1,
# pastePt[1] + heightImg + 1
# )
# imageBg = Image.new(self.image.mode, self.size, background)
# imageBg.paste(self.image, pastePt)
# draw = ImageDraw.Draw(imageBg)
# draw.rectangle([corner1, corner2], outline=foreground)
# self.image = imageBg