1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 09:46:25 +00:00

Webstrip mode improvements

This commit is contained in:
Paweł Jastrzębski
2013-08-13 10:30:53 +02:00
parent 877a859ef4
commit ff91eb1407

View File

@@ -53,7 +53,8 @@ def getImageFileName(imgfile):
return filename return filename
def getImageFill(histogram): def getImageHistogram(image):
histogram = image.histogram()
RBGW = [] RBGW = []
for i in range(256): for i in range(256):
RBGW.append(histogram[i] + histogram[256 + i] + histogram[512 + i]) RBGW.append(histogram[i] + histogram[256 + i] + histogram[512 + i])
@@ -69,6 +70,18 @@ def getImageFill(histogram):
return 'KCCFB' return 'KCCFB'
def getImageFill(image):
imageSize = image.size
imageT = image.crop((0, 0, imageSize[0], 1))
imageB = image.crop((0, imageSize[1]-1, imageSize[0], imageSize[1]))
imageT = getImageHistogram(imageT)
imageB = getImageHistogram(imageB)
if imageT == imageB:
return imageT
else:
return 'KCCFW'
def sanitizePanelSize(panel, options): def sanitizePanelSize(panel, options):
newPanels = [] newPanels = []
if panel[2] > 1.5 * options.height: if panel[2] > 1.5 * options.height:
@@ -171,7 +184,7 @@ def splitImage(work):
newPage.paste(panelImg, (0, targetHeight)) newPage.paste(panelImg, (0, targetHeight))
targetHeight += panels[panel][2] targetHeight += panels[panel][2]
newPage.save(os.path.join(path, fileExpanded[0] + '-' + newPage.save(os.path.join(path, fileExpanded[0] + '-' +
str(pageNumber) + '-' + getImageFill(newPage.histogram()) + '.png'), 'PNG') str(pageNumber) + '-' + getImageFill(newPage) + '.png'), 'PNG')
pageNumber += 1 pageNumber += 1
os.remove(os.path.join(path, name)) os.remove(os.path.join(path, name))