diff options
| author | Fulya <[email protected]> | 2021-05-15 14:08:36 -0400 |
|---|---|---|
| committer | Fulya <[email protected]> | 2021-05-15 14:08:36 -0400 |
| commit | 6519eb04533693f5ec908e69fb1cb5cb382e22a3 (patch) | |
| tree | bd6847e05aa68ad6f063c25b47cf29b5a2e08928 | |
| parent | Merge pull request #329 from C0rn3j/master (diff) | |
| download | kcc-6519eb04533693f5ec908e69fb1cb5cb382e22a3.tar.gz kcc-6519eb04533693f5ec908e69fb1cb5cb382e22a3.tar.bz2 kcc-6519eb04533693f5ec908e69fb1cb5cb382e22a3.zip | |
Fixed the skipped/missed images and/or panels
| -rwxr-xr-x | kindlecomicconverter/comic2ebook.py | 7 | ||||
| -rw-r--r-- | kindlecomicconverter/comic2panel.py | 20 |
2 files changed, 16 insertions, 11 deletions
diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 3fe2333..237d0a2 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -1078,10 +1078,7 @@ def makeBook(source, qtgui=None): getComicInfo(os.path.join(path, "OEBPS", "Images"), source) detectCorruption(os.path.join(path, "OEBPS", "Images"), source) if options.webtoon: - if image.ProfileData.Profiles[options.profile][1][1] > 1024: - y = 1024 - else: - y = image.ProfileData.Profiles[options.profile][1][1] + y = image.ProfileData.Profiles[options.profile][1][1] comic2panel.main(['-y ' + str(y), '-i', '-m', path], qtgui) print("Processing images...") if GUI: @@ -1222,7 +1219,7 @@ def makeMOBI(work, qtgui=None): threadNumber = 1 elif 2 < availableMemory <= 4: threadNumber = 2 - elif 4 < availableMemory <= 8: + elif 4 < availableMemory: threadNumber = 4 else: threadNumber = None diff --git a/kindlecomicconverter/comic2panel.py b/kindlecomicconverter/comic2panel.py index cd5d87a..b13cb59 100644 --- a/kindlecomicconverter/comic2panel.py +++ b/kindlecomicconverter/comic2panel.py @@ -57,9 +57,8 @@ def mergeDirectory(work): if len(images) > 0: targetWidth = max(set(sizes), key=sizes.count) for i in images: - if i[1] <= targetWidth: - targetHeight += i[2] - imagesValid.append(i[0]) + targetHeight += i[2] + imagesValid.append(i[0]) # Silently drop directories that contain too many images # 131072 = GIMP_MAX_IMAGE_SIZE / 4 if targetHeight > 131072: @@ -68,8 +67,10 @@ def mergeDirectory(work): y = 0 for i in imagesValid: img = Image.open(i).convert('RGB') - if img.size[0] < targetWidth: - img = ImageOps.fit(img, (targetWidth, img.size[1]), method=Image.BICUBIC, centering=(0.5, 0.5)) + if img.size[0] < targetWidth or img.size[0] > targetWidth: + widthPercent = (targetWidth / float(img.size[0])) + heightSize = int((float(img.size[1]) * float(widthPercent))) + img = ImageOps.fit(img, (targetWidth, heightSize), method=Image.BICUBIC, centering=(0.5, 0.5)) result.paste(img, (0, y)) y += img.size[1] os.remove(i) @@ -100,6 +101,8 @@ def splitImage(work): name = work[1] opt = work[2] filePath = os.path.join(path, name) + Image.warnings.simplefilter('error', Image.DecompressionBombWarning) + Image.MAX_IMAGE_PIXELS = 1000000000 imgOrg = Image.open(filePath).convert('RGB') imgProcess = Image.open(filePath).convert('1') widthImg, heightImg = imgOrg.size @@ -113,11 +116,16 @@ def splitImage(work): panelDetected = False panels = [] while yWork < heightImg: - tmpImg = imgProcess.crop([0, yWork, widthImg, yWork + 4]) + tmpImg = imgProcess.crop([4, yWork, widthImg-4, yWork + 4]) solid = detectSolid(tmpImg) if not solid and not panelDetected: panelDetected = True panelY1 = yWork - 2 + if heightImg - yWork <= 5: + if not solid and panelDetected: + panelY2 = heightImg + panelDetected = False + panels.append((panelY1, panelY2, panelY2 - panelY1)) if solid and panelDetected: panelDetected = False panelY2 = yWork + 6 |