1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 01:36:27 +00:00

Fixed the skipped/missed images and/or panels

This commit is contained in:
Fulya
2021-05-15 14:08:36 -04:00
parent 4ec4c9966c
commit 6519eb0453
2 changed files with 16 additions and 11 deletions

View File

@@ -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

View File

@@ -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