Skip to content
Open
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
18 changes: 12 additions & 6 deletions kindlecomicconverter/comic2ebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,20 +1368,26 @@ def detectSuboptimalProcessing(tmppath, orgpath):
path = os.path.join(root, name)
pathOrg = orgpath + path.split('OEBPS' + os.path.sep + 'Images')[1]
if os.path.getsize(path) == 0:
rmtree(os.path.join(tmppath, '..', '..'), True)
raise RuntimeError('Image file %s is corrupted.' % pathOrg)
# A single corrupt (zero-byte) page should not fail the whole book;
# skip it and continue with the remaining pages.
os.remove(path)
print('WARNING: Skipping corrupt (empty) image %s' % pathOrg)
continue
try:
img = Image.open(path)
imageNumber += 1
# count images smaller than device resolution
if options.profileData[1][0] > img.size[0] and options.profileData[1][1] > img.size[1]:
imageSmaller += 1
except Exception as err:
rmtree(os.path.join(tmppath, '..', '..'), True)
if 'decoder' in str(err) and 'not available' in str(err):
rmtree(os.path.join(tmppath, '..', '..'), True)
raise RuntimeError('Pillow was compiled without JPG and/or PNG decoder.')
else:
raise RuntimeError('Image file %s is corrupted. Error: %s' % (pathOrg, str(err)))
# A single corrupt/unreadable page should not fail the whole book;
# skip it and continue with the remaining pages.
os.remove(path)
print('WARNING: Skipping corrupt image %s (%s)' % (pathOrg, str(err)))
continue
else:
try:
if os.path.exists(os.path.join(root, name)):
Expand Down Expand Up @@ -1840,7 +1846,7 @@ def makeBook(source, qtgui=None, job_progress=''):
# Strip the fusion_0001_ sort prefix from makeFusion if present
chapterNames = {k: sub(r'^fusion_\d{4}_', '', v) for k, v in chapterNames.items()}
cover = None
if not options.webtoon:
if not options.webtoon and cover_path:
cover = image.Cover(cover_path, options)

x, y = image.ProfileData.Profiles[options.profile][1]
Expand Down