1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-12 17:26:23 +00:00

Fixes to grayscale pages in forcecolor mode (#978)

* Fix bit depth of non-color pages in forcecolor mode

* Optimization for JPEG non-color pages in forcecolor mode
This commit is contained in:
Adrian
2025-06-19 01:12:12 +03:00
committed by GitHub
parent 2fa90c9f59
commit e9f0310b94
2 changed files with 8 additions and 4 deletions

View File

@@ -304,8 +304,6 @@ class ComicPage:
def saveToDir(self):
try:
flags = []
if not self.opt.forcecolor and not self.opt.forcepng:
self.image = self.image.convert('L')
if self.rotated:
flags.append('Rotated')
if self.fill != 'white':
@@ -353,6 +351,12 @@ class ComicPage:
else:
self.image = ImageOps.autocontrast(Image.eval(self.image, lambda a: int(255 * (a / 255.) ** gamma)))
def convertToGrayscaleOrQuantize(self):
if self.opt.forcepng:
self.quantizeImage()
else:
self.image = self.image.convert('L')
def quantizeImage(self):
palImg = Image.new('P', (1, 1))
palImg.putpalette(self.palette)