mirror of
https://github.com/ciromattia/kcc
synced 2026-09-16 15:57:09 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e68ce380c | ||
|
|
b95cf6e179 | ||
|
|
08070cdd97 | ||
|
|
df3d174437 |
@@ -393,7 +393,10 @@ class WorkerThread(QThread):
|
|||||||
for job in currentJobs:
|
for job in currentJobs:
|
||||||
bookDir.append(job)
|
bookDir.append(job)
|
||||||
try:
|
try:
|
||||||
|
fusion_source_parent = str(Path(bookDir[0]).parent)
|
||||||
comic2ebook.options = comic2ebook.checkOptions(copy(options))
|
comic2ebook.options = comic2ebook.checkOptions(copy(options))
|
||||||
|
if options.output is None:
|
||||||
|
options.output = fusion_source_parent
|
||||||
currentJobs.clear()
|
currentJobs.clear()
|
||||||
currentJobs.append(comic2ebook.makeFusion(bookDir))
|
currentJobs.append(comic2ebook.makeFusion(bookDir))
|
||||||
MW.addMessage.emit('Created fusion at ' + currentJobs[0], 'info', False)
|
MW.addMessage.emit('Created fusion at ' + currentJobs[0], 'info', False)
|
||||||
@@ -557,13 +560,6 @@ class WorkerThread(QThread):
|
|||||||
move(item, GUI.targetDirectory)
|
move(item, GUI.targetDirectory)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
if options.filefusion:
|
|
||||||
for path in currentJobs:
|
|
||||||
if os.path.isfile(path):
|
|
||||||
os.remove(path)
|
|
||||||
elif os.path.isdir(path):
|
|
||||||
rmtree(path, True)
|
|
||||||
comic2ebook.checkPre('LLL-')
|
|
||||||
GUI.progress.content = ''
|
GUI.progress.content = ''
|
||||||
GUI.progress.stop()
|
GUI.progress.stop()
|
||||||
MW.hideProgressBar.emit()
|
MW.hideProgressBar.emit()
|
||||||
|
|||||||
@@ -76,23 +76,19 @@ def main(argv=None):
|
|||||||
print('No matching files found.')
|
print('No matching files found.')
|
||||||
return 1
|
return 1
|
||||||
if options.filefusion:
|
if options.filefusion:
|
||||||
|
fusion_source_parent = str(Path(sources[0]).parent)
|
||||||
fusion_path = makeFusion(list(sources))
|
fusion_path = makeFusion(list(sources))
|
||||||
sources.clear()
|
sources.clear()
|
||||||
sources.append(fusion_path)
|
sources.append(fusion_path)
|
||||||
for source in sources:
|
for source in sources:
|
||||||
source = source.rstrip('\\').rstrip('/')
|
source = source.rstrip('\\').rstrip('/')
|
||||||
options = copy(args)
|
options = copy(args)
|
||||||
|
if options.filefusion and options.output is None:
|
||||||
|
options.output = fusion_source_parent
|
||||||
options = checkOptions(options)
|
options = checkOptions(options)
|
||||||
print('Working on ' + source + '...')
|
print('Working on ' + source + '...')
|
||||||
makeBook(source)
|
makeBook(source)
|
||||||
|
|
||||||
if options.filefusion:
|
|
||||||
for path in sources:
|
|
||||||
if os.path.isfile(path):
|
|
||||||
os.remove(path)
|
|
||||||
elif os.path.isdir(path):
|
|
||||||
rmtree(path, True)
|
|
||||||
checkPre('LLL-')
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@@ -979,10 +975,11 @@ def getWorkFolder(afile, workdir=None):
|
|||||||
manifest_dict[manifest_item.attrib.get('id')] = manifest_item.attrib.get('href')
|
manifest_dict[manifest_item.attrib.get('id')] = manifest_item.attrib.get('href')
|
||||||
ordered_image_paths = []
|
ordered_image_paths = []
|
||||||
for i, spine_item in enumerate(spine):
|
for i, spine_item in enumerate(spine):
|
||||||
if spine_item not in manifest_dict:
|
try:
|
||||||
|
page_path = os.path.join(os.path.dirname(opf_path), manifest_dict[spine_item])
|
||||||
|
page = ET.parse(page_path)
|
||||||
|
except Exception:
|
||||||
continue
|
continue
|
||||||
page_path = os.path.join(os.path.dirname(opf_path), manifest_dict[spine_item])
|
|
||||||
page = ET.parse(page_path)
|
|
||||||
imgs = page.findall(r'.//{*}img') + page.findall(r'.//{*}image')
|
imgs = page.findall(r'.//{*}img') + page.findall(r'.//{*}image')
|
||||||
|
|
||||||
largest_size = 0
|
largest_size = 0
|
||||||
@@ -1690,8 +1687,8 @@ def makeFusion(sources: List[str]):
|
|||||||
raise UserWarning('Fusion requires at least 2 sources. Did you forget to uncheck fusion?')
|
raise UserWarning('Fusion requires at least 2 sources. Did you forget to uncheck fusion?')
|
||||||
start = perf_counter()
|
start = perf_counter()
|
||||||
first_path = Path(sources[0])
|
first_path = Path(sources[0])
|
||||||
|
|
||||||
if True:
|
if options.tempdir:
|
||||||
fusion_parent = first_path.parent
|
fusion_parent = first_path.parent
|
||||||
else:
|
else:
|
||||||
# LLL is after KCC
|
# LLL is after KCC
|
||||||
@@ -1899,11 +1896,11 @@ def makeBook(source, qtgui=None, job_progress=''):
|
|||||||
|
|
||||||
end = perf_counter()
|
end = perf_counter()
|
||||||
print(f"{job_progress}makeBook: {end - start} seconds")
|
print(f"{job_progress}makeBook: {end - start} seconds")
|
||||||
# Clean up temporary workspace
|
|
||||||
try:
|
if options.filefusion:
|
||||||
rmtree(path, True)
|
rmtree(source, True)
|
||||||
except Exception:
|
checkPre('LLL-')
|
||||||
pass
|
|
||||||
return filepath
|
return filepath
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ def mergeDirectory(work):
|
|||||||
imagesValid.append(i[0])
|
imagesValid.append(i[0])
|
||||||
# Silently drop directories that contain too many images
|
# Silently drop directories that contain too many images
|
||||||
# 131072 = GIMP_MAX_IMAGE_SIZE / 4
|
# 131072 = GIMP_MAX_IMAGE_SIZE / 4
|
||||||
if targetHeight > 131072 * 4:
|
if targetHeight > 131072 * 8:
|
||||||
raise RuntimeError(f'Image too tall at {targetHeight} pixels. {targetWidth} pixels wide. Try using separate chapter folders or file fusion.')
|
raise RuntimeError(f'Image too tall at {targetHeight} pixels. {targetWidth} pixels wide. Try using separate chapter folders or file fusion.')
|
||||||
result = Image.new('RGB', (targetWidth, targetHeight))
|
result = Image.new('RGB', (targetWidth, targetHeight))
|
||||||
y = 0
|
y = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user