mirror of
https://github.com/ciromattia/kcc
synced 2025-12-15 18:56:28 +00:00
Fixed the skipped/missed images and/or panels
This commit is contained in:
@@ -1078,10 +1078,7 @@ def makeBook(source, qtgui=None):
|
|||||||
getComicInfo(os.path.join(path, "OEBPS", "Images"), source)
|
getComicInfo(os.path.join(path, "OEBPS", "Images"), source)
|
||||||
detectCorruption(os.path.join(path, "OEBPS", "Images"), source)
|
detectCorruption(os.path.join(path, "OEBPS", "Images"), source)
|
||||||
if options.webtoon:
|
if options.webtoon:
|
||||||
if image.ProfileData.Profiles[options.profile][1][1] > 1024:
|
y = image.ProfileData.Profiles[options.profile][1][1]
|
||||||
y = 1024
|
|
||||||
else:
|
|
||||||
y = image.ProfileData.Profiles[options.profile][1][1]
|
|
||||||
comic2panel.main(['-y ' + str(y), '-i', '-m', path], qtgui)
|
comic2panel.main(['-y ' + str(y), '-i', '-m', path], qtgui)
|
||||||
print("Processing images...")
|
print("Processing images...")
|
||||||
if GUI:
|
if GUI:
|
||||||
@@ -1222,7 +1219,7 @@ def makeMOBI(work, qtgui=None):
|
|||||||
threadNumber = 1
|
threadNumber = 1
|
||||||
elif 2 < availableMemory <= 4:
|
elif 2 < availableMemory <= 4:
|
||||||
threadNumber = 2
|
threadNumber = 2
|
||||||
elif 4 < availableMemory <= 8:
|
elif 4 < availableMemory:
|
||||||
threadNumber = 4
|
threadNumber = 4
|
||||||
else:
|
else:
|
||||||
threadNumber = None
|
threadNumber = None
|
||||||
|
|||||||
@@ -57,9 +57,8 @@ def mergeDirectory(work):
|
|||||||
if len(images) > 0:
|
if len(images) > 0:
|
||||||
targetWidth = max(set(sizes), key=sizes.count)
|
targetWidth = max(set(sizes), key=sizes.count)
|
||||||
for i in images:
|
for i in images:
|
||||||
if i[1] <= targetWidth:
|
targetHeight += i[2]
|
||||||
targetHeight += i[2]
|
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:
|
if targetHeight > 131072:
|
||||||
@@ -68,8 +67,10 @@ def mergeDirectory(work):
|
|||||||
y = 0
|
y = 0
|
||||||
for i in imagesValid:
|
for i in imagesValid:
|
||||||
img = Image.open(i).convert('RGB')
|
img = Image.open(i).convert('RGB')
|
||||||
if img.size[0] < targetWidth:
|
if img.size[0] < targetWidth or img.size[0] > targetWidth:
|
||||||
img = ImageOps.fit(img, (targetWidth, img.size[1]), method=Image.BICUBIC, centering=(0.5, 0.5))
|
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))
|
result.paste(img, (0, y))
|
||||||
y += img.size[1]
|
y += img.size[1]
|
||||||
os.remove(i)
|
os.remove(i)
|
||||||
@@ -100,6 +101,8 @@ def splitImage(work):
|
|||||||
name = work[1]
|
name = work[1]
|
||||||
opt = work[2]
|
opt = work[2]
|
||||||
filePath = os.path.join(path, name)
|
filePath = os.path.join(path, name)
|
||||||
|
Image.warnings.simplefilter('error', Image.DecompressionBombWarning)
|
||||||
|
Image.MAX_IMAGE_PIXELS = 1000000000
|
||||||
imgOrg = Image.open(filePath).convert('RGB')
|
imgOrg = Image.open(filePath).convert('RGB')
|
||||||
imgProcess = Image.open(filePath).convert('1')
|
imgProcess = Image.open(filePath).convert('1')
|
||||||
widthImg, heightImg = imgOrg.size
|
widthImg, heightImg = imgOrg.size
|
||||||
@@ -113,11 +116,16 @@ def splitImage(work):
|
|||||||
panelDetected = False
|
panelDetected = False
|
||||||
panels = []
|
panels = []
|
||||||
while yWork < heightImg:
|
while yWork < heightImg:
|
||||||
tmpImg = imgProcess.crop([0, yWork, widthImg, yWork + 4])
|
tmpImg = imgProcess.crop([4, yWork, widthImg-4, yWork + 4])
|
||||||
solid = detectSolid(tmpImg)
|
solid = detectSolid(tmpImg)
|
||||||
if not solid and not panelDetected:
|
if not solid and not panelDetected:
|
||||||
panelDetected = True
|
panelDetected = True
|
||||||
panelY1 = yWork - 2
|
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:
|
if solid and panelDetected:
|
||||||
panelDetected = False
|
panelDetected = False
|
||||||
panelY2 = yWork + 6
|
panelY2 = yWork + 6
|
||||||
|
|||||||
Reference in New Issue
Block a user