diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 02eed1c..ed2d9f2 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -888,8 +888,7 @@ def chunk_process(path, mode, parent): firstTome = False return output - -def detectCorruption(tmppath, orgpath): +def detectSuboptimalProcessing(tmppath, orgpath): imageNumber = 0 imageSmaller = 0 alreadyProcessed = False @@ -905,9 +904,6 @@ def detectCorruption(tmppath, orgpath): raise RuntimeError('Image file %s is corrupted.' % pathOrg) try: img = Image.open(path) - img.verify() - img = Image.open(path) - img.load() imageNumber += 1 if options.profileData[1][0] > img.size[0] and options.profileData[1][1] > img.size[1]: imageSmaller += 1 @@ -1179,7 +1175,7 @@ def makeBook(source, qtgui=None): path = getWorkFolder(source) print("Checking images...") getComicInfo(os.path.join(path, "OEBPS", "Images"), source) - detectCorruption(os.path.join(path, "OEBPS", "Images"), source) + detectSuboptimalProcessing(os.path.join(path, "OEBPS", "Images"), source) if options.webtoon: y = image.ProfileData.Profiles[options.profile][1][1] comic2panel.main(['-y ' + str(y), '-i', '-m', path], qtgui) diff --git a/kindlecomicconverter/image.py b/kindlecomicconverter/image.py index 91d0a8a..4398c89 100755 --- a/kindlecomicconverter/image.py +++ b/kindlecomicconverter/image.py @@ -141,7 +141,13 @@ class ComicPageParser: self.source = source self.size = self.opt.profileData[1] self.payload = [] - self.image = Image.open(os.path.join(source[0], source[1])).convert('RGB') + + # Detect corruption in source image, let caller catch any exceptions triggered. + srcImgPath = os.path.join(source[0], source[1]) + self.image = Image.open(srcImgPath) + self.image.verify() + self.image = Image.open(srcImgPath).convert('RGB') + self.color = self.colorCheck() self.fill = self.fillCheck() # backwards compatibility for Pillow >9.1.0