mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 01:36:27 +00:00
fix color autocontrast (#1026)
This commit is contained in:
@@ -639,8 +639,8 @@ def imgFileProcessing(work):
|
|||||||
workImg = image.ComicPageParser((dirpath, afile), opt)
|
workImg = image.ComicPageParser((dirpath, afile), opt)
|
||||||
for i in workImg.payload:
|
for i in workImg.payload:
|
||||||
img = image.ComicPage(opt, *i)
|
img = image.ComicPage(opt, *i)
|
||||||
is_not_color = not opt.forcecolor or not img.color
|
is_output_grayscale = not opt.forcecolor or not img.color
|
||||||
if is_not_color:
|
if is_output_grayscale:
|
||||||
img.convertToGrayscale()
|
img.convertToGrayscale()
|
||||||
if opt.cropping == 2 and not opt.webtoon:
|
if opt.cropping == 2 and not opt.webtoon:
|
||||||
img.cropPageNumber(opt.croppingp, opt.croppingm)
|
img.cropPageNumber(opt.croppingp, opt.croppingm)
|
||||||
@@ -649,11 +649,10 @@ def imgFileProcessing(work):
|
|||||||
if opt.interpanelcrop > 0:
|
if opt.interpanelcrop > 0:
|
||||||
img.cropInterPanelEmptySections("horizontal" if opt.interpanelcrop == 1 else "both")
|
img.cropInterPanelEmptySections("horizontal" if opt.interpanelcrop == 1 else "both")
|
||||||
img.gammaCorrectImage()
|
img.gammaCorrectImage()
|
||||||
if is_not_color:
|
img.autocontrastImage()
|
||||||
img.autocontrastImage()
|
|
||||||
img.resizeImage()
|
img.resizeImage()
|
||||||
img.optimizeForDisplay(opt.reducerainbow)
|
img.optimizeForDisplay(opt.reducerainbow)
|
||||||
if is_not_color and opt.forcepng:
|
if is_output_grayscale and opt.forcepng:
|
||||||
img.quantizeImage()
|
img.quantizeImage()
|
||||||
output.append(img.saveToDir())
|
output.append(img.saveToDir())
|
||||||
return output
|
return output
|
||||||
|
|||||||
@@ -353,9 +353,7 @@ class ComicPage:
|
|||||||
self.image = Image.eval(self.image, lambda a: int(255 * (a / 255.) ** gamma))
|
self.image = Image.eval(self.image, lambda a: int(255 * (a / 255.) ** gamma))
|
||||||
|
|
||||||
def autocontrastImage(self):
|
def autocontrastImage(self):
|
||||||
# autocontrast on non grayscale images has unexpected results
|
self.image = ImageOps.autocontrast(self.image, preserve_tone=True)
|
||||||
# since it autocontrasts each color channel separately
|
|
||||||
self.image = ImageOps.autocontrast(self.image)
|
|
||||||
|
|
||||||
def convertToGrayscale(self):
|
def convertToGrayscale(self):
|
||||||
self.image = self.image.convert('L')
|
self.image = self.image.convert('L')
|
||||||
|
|||||||
Reference in New Issue
Block a user