mirror of
https://github.com/ciromattia/kcc
synced 2025-12-16 03:06:33 +00:00
Webtoon mode improvements
This commit is contained in:
@@ -65,26 +65,31 @@ def getImageHistogram(image):
|
|||||||
for i in range(11):
|
for i in range(11):
|
||||||
black += RBGW[i]
|
black += RBGW[i]
|
||||||
if white > black:
|
if white > black:
|
||||||
return 0
|
return False
|
||||||
else:
|
else:
|
||||||
return 1
|
return True
|
||||||
|
|
||||||
|
|
||||||
def getImageFill(image):
|
def getImageFill(image):
|
||||||
imageSize = image.size
|
imageSize = image.size
|
||||||
imageT = image.crop((0, 0, imageSize[0], 1))
|
imageT = image.crop((0, 0, imageSize[0], 1))
|
||||||
imageB = image.crop((0, imageSize[1]-1, imageSize[0], imageSize[1]))
|
imageB = image.crop((0, imageSize[1]-1, imageSize[0], imageSize[1]))
|
||||||
imageL = image.crop((0, 0, 1, imageSize[1]))
|
|
||||||
imageR = image.crop((imageSize[0]-1, 0, imageSize[0], imageSize[1]))
|
|
||||||
fill = 0
|
fill = 0
|
||||||
fill += getImageHistogram(imageT)
|
fill += getImageHistogram(imageT)
|
||||||
fill += getImageHistogram(imageB)
|
fill += getImageHistogram(imageB)
|
||||||
fill += getImageHistogram(imageL)
|
if fill == 2:
|
||||||
fill += getImageHistogram(imageR)
|
|
||||||
if fill > 2:
|
|
||||||
return 'KCCFB'
|
return 'KCCFB'
|
||||||
else:
|
elif fill == 0:
|
||||||
return 'KCCFW'
|
return 'KCCFW'
|
||||||
|
else:
|
||||||
|
imageL = image.crop((0, 0, 1, imageSize[1]))
|
||||||
|
imageR = image.crop((imageSize[0]-1, 0, imageSize[0], imageSize[1]))
|
||||||
|
fill += getImageHistogram(imageL)
|
||||||
|
fill += getImageHistogram(imageR)
|
||||||
|
if fill >= 2:
|
||||||
|
return 'KCCFB'
|
||||||
|
else:
|
||||||
|
return 'KCCFW'
|
||||||
|
|
||||||
|
|
||||||
def sanitizePanelSize(panel, options):
|
def sanitizePanelSize(panel, options):
|
||||||
@@ -168,12 +173,14 @@ def splitImage(work):
|
|||||||
while ImageStat.Stat(image.crop([0, y1, widthImg, y2])).var[0] >= threshold and y2 < heightImg:
|
while ImageStat.Stat(image.crop([0, y1, widthImg, y2])).var[0] >= threshold and y2 < heightImg:
|
||||||
y1 += delta
|
y1 += delta
|
||||||
y2 += delta
|
y2 += delta
|
||||||
|
if y1 + delta >= heightImg:
|
||||||
|
y1 = heightImg - 1
|
||||||
y2Temp = y1
|
y2Temp = y1
|
||||||
if options.debug:
|
if options.debug:
|
||||||
draw.line([(0, y1Temp), (widthImg, y1Temp)], fill=(0, 255, 0))
|
draw.line([(0, y1Temp), (widthImg, y1Temp)], fill=(0, 255, 0))
|
||||||
draw.line([(0, y2Temp), (widthImg, y2Temp)], fill=(255, 0, 0))
|
draw.line([(0, y2Temp), (widthImg, y2Temp)], fill=(255, 0, 0))
|
||||||
panelHeight = y2Temp - y1Temp
|
panelHeight = y2Temp - y1Temp
|
||||||
if y2Temp < heightImg:
|
if panelHeight > delta:
|
||||||
# Panels that can't be cut nicely will be forcefully splitted
|
# Panels that can't be cut nicely will be forcefully splitted
|
||||||
panelsCleaned = sanitizePanelSize([y1Temp, y2Temp, panelHeight], options)
|
panelsCleaned = sanitizePanelSize([y1Temp, y2Temp, panelHeight], options)
|
||||||
for panel in panelsCleaned:
|
for panel in panelsCleaned:
|
||||||
|
|||||||
Reference in New Issue
Block a user