1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 17:56:30 +00:00

Webstrip mode improvements

This commit is contained in:
Paweł Jastrzębski
2013-08-13 09:25:53 +02:00
parent 3d2554c557
commit f8b29cd967
2 changed files with 21 additions and 16 deletions

View File

@@ -323,8 +323,9 @@ def getImageFileName(imgfile):
def applyImgOptimization(img, isSplit, toRight, options, overrideQuality=5):
img.cropWhiteSpace(10.0)
if options.cutpagenumbers:
if not options.webstrip:
img.cropWhiteSpace(10.0)
if options.cutpagenumbers and not options.webstrip:
img.cutPageNumber()
img.optimizeImage(options.gamma)
if overrideQuality != 5:

View File

@@ -53,6 +53,22 @@ def getImageFileName(imgfile):
return filename
def getImageFill(histogram):
RBGW = []
for i in range(256):
RBGW.append(histogram[i] + histogram[256 + i] + histogram[512 + i])
white = 0
black = 0
for i in range(245, 256):
white += RBGW[i]
for i in range(11):
black += RBGW[i]
if white > black:
return 'KCCFW'
else:
return 'KCCFB'
def sanitizePanelSize(panel, options):
newPanels = []
if panel[2] > 1.5 * options.height:
@@ -95,19 +111,6 @@ def splitImage(work):
debugImage = Image.open(os.path.join(path, name))
draw = ImageDraw.Draw(debugImage)
# Find fill color
white = 0
black = 0
for i in image.getdata():
if i == (255, 255, 255):
white += 1
elif i == (0, 0, 0):
black += 1
if white > black:
fill = 'KCCFW'
else:
fill = 'KCCFB'
# Find panels
y1 = 0
y2 = 10
@@ -167,7 +170,8 @@ def splitImage(work):
panelImg = image.crop([0, panels[panel][0], widthImg, panels[panel][1]])
newPage.paste(panelImg, (0, targetHeight))
targetHeight += panels[panel][2]
newPage.save(os.path.join(path, fileExpanded[0] + '-' + str(pageNumber) + '-' + fill + '.png'), 'PNG')
newPage.save(os.path.join(path, fileExpanded[0] + '-' +
str(pageNumber) + '-' + getImageFill(newPage.histogram()) + '.png'), 'PNG')
pageNumber += 1
os.remove(os.path.join(path, name))