1
0
mirror of https://github.com/ciromattia/kcc synced 2026-04-22 17:08:57 +00:00

Compare commits

...

7 Commits

Author SHA1 Message Date
Alex Xu
90c9ba7539 bump 8.0.4 2025-07-10 09:19:57 -07:00
Alex Xu
84da718167 more extraction fixes (#1023) 2025-07-10 09:14:06 -07:00
Alex Xu
fe7559e6a9 Add note about RTL CBZ output 2025-07-10 06:58:03 -07:00
Alex Xu
a79c740387 don't autocontrast color content (#1021) 2025-07-09 13:59:54 -07:00
Alex Xu
bc98eecae9 bump 8.0.3 2025-07-09 11:28:25 -07:00
Alex Xu
e7a07377ef add avif input support (#1019)
* add avif input support

* add avif
2025-07-09 11:27:58 -07:00
Alex Xu
07ef11013a fix cbz metadata (#1018) 2025-07-09 11:14:25 -07:00
9 changed files with 29 additions and 21 deletions

View File

@@ -101,6 +101,8 @@ For flatpak, Docker, and AppImage versions, refer to the wiki: https://github.co
## FAQ ## FAQ
- All options have additional information in tooltips if you hover over the option. - All options have additional information in tooltips if you hover over the option.
- To get the converted book onto your Kindle/Kobo, just drag and drop the mobi/kepub into the documents folder on your Kindle/Kobo via USB - To get the converted book onto your Kindle/Kobo, just drag and drop the mobi/kepub into the documents folder on your Kindle/Kobo via USB
- Right to left mode not working?
- RTL mode only affects splitting order for CBZ output. Your cbz reader itself sets the page turn direction.
- Colors inverted? - Colors inverted?
- Disable Kindle dark mode - Disable Kindle dark mode
- Cannot connect Kindle Scribe or 2024+ Kindle to macOS - Cannot connect Kindle Scribe or 2024+ Kindle to macOS

View File

@@ -4,7 +4,7 @@ channels:
- defaults - defaults
dependencies: dependencies:
- python=3.11 - python=3.11
- Pillow>=5.2.0 - Pillow>=11.3.0
- psutil>=5.9.5 - psutil>=5.9.5
- python-slugify>=1.2.1 - python-slugify>=1.2.1
- raven>=6.0.0 - raven>=6.0.0

View File

@@ -1,4 +1,4 @@
__version__ = '8.0.2' __version__ = '8.0.4'
__license__ = 'ISC' __license__ = 'ISC'
__copyright__ = '2012-2022, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>, darodi' __copyright__ = '2012-2022, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>, darodi'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'

View File

@@ -639,21 +639,22 @@ 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
if is_not_color:
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)
if opt.cropping == 1 and not opt.webtoon: if opt.cropping == 1 and not opt.webtoon:
img.cropMargin(opt.croppingp, opt.croppingm) img.cropMargin(opt.croppingp, opt.croppingm)
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.autocontrastImage() img.gammaCorrectImage()
if is_not_color:
img.autocontrastImage()
img.resizeImage() img.resizeImage()
img.optimizeForDisplay(opt.reducerainbow) img.optimizeForDisplay(opt.reducerainbow)
if opt.forcecolor and img.color: if is_not_color and opt.forcepng:
pass
elif opt.forcepng:
img.quantizeImage() img.quantizeImage()
else:
img.convertToGrayscale()
output.append(img.saveToDir()) output.append(img.saveToDir())
return output return output
except Exception: except Exception:
@@ -820,7 +821,7 @@ def removeNonImages(filetree):
for root, dirs, files in os.walk(filetree): for root, dirs, files in os.walk(filetree):
for name in files: for name in files:
_, ext = getImageFileName(name) _, ext = getImageFileName(name)
if ext not in ('.png', '.jpg', '.jpeg', '.gif', '.webp', '.jp2'): if ext not in ('.png', '.jpg', '.jpeg', '.gif', '.webp', '.jp2', '.avif'):
if os.path.exists(os.path.join(root, name)): if os.path.exists(os.path.join(root, name)):
os.remove(os.path.join(root, name)) os.remove(os.path.join(root, name))
# remove empty nested folders # remove empty nested folders

View File

@@ -74,7 +74,7 @@ class ComicArchive:
if platform.system() == 'Darwin': if platform.system() == 'Darwin':
extraction_commands.append( extraction_commands.append(
['unar', self.filepath, '-f', '-o', targetdir] ['unar', self.filepath, '-D', '-f', '-o', targetdir]
) )
extraction_commands.reverse() extraction_commands.reverse()

View File

@@ -341,16 +341,21 @@ class ComicPage:
image.save(targetPath, 'JPEG', optimize=1, quality=85) image.save(targetPath, 'JPEG', optimize=1, quality=85)
return targetPath return targetPath
def autocontrastImage(self): def gammaCorrectImage(self):
gamma = self.opt.gamma gamma = self.opt.gamma
if gamma < 0.1: if gamma < 0.1:
gamma = self.gamma gamma = self.gamma
if self.gamma != 1.0 and self.color: if self.gamma != 1.0 and self.color:
gamma = 1.0 gamma = 1.0
if gamma == 1.0: if gamma == 1.0:
self.image = ImageOps.autocontrast(self.image) pass
else: else:
self.image = ImageOps.autocontrast(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):
# autocontrast on non grayscale images has unexpected results
# 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')
@@ -358,7 +363,7 @@ class ComicPage:
def quantizeImage(self): def quantizeImage(self):
# remove all color pixels from image, since colorCheck() has some tolerance # remove all color pixels from image, since colorCheck() has some tolerance
# quantize with a small number of color pixels in a mostly b/w image can have unexpected results # quantize with a small number of color pixels in a mostly b/w image can have unexpected results
self.image = self.image.convert("L").convert("RGB") self.image = self.image.convert("RGB")
palImg = Image.new('P', (1, 1)) palImg = Image.new('P', (1, 1))
palImg.putpalette(self.palette) palImg.putpalette(self.palette)

View File

@@ -116,10 +116,10 @@ def dependencyCheck(level):
missing.append('python-slugify 1.2.1+') missing.append('python-slugify 1.2.1+')
try: try:
from PIL import __version__ as pillowVersion from PIL import __version__ as pillowVersion
if Version('5.2.0') > Version(pillowVersion): if Version('11.3.0') > Version(pillowVersion):
missing.append('Pillow 5.2.0+') missing.append('Pillow 11.3.0+')
except ImportError: except ImportError:
missing.append('Pillow 5.2.0+') missing.append('Pillow 11.3.0+')
if len(missing) > 0: if len(missing) > 0:
print('ERROR: ' + ', '.join(missing) + ' is not installed!') print('ERROR: ' + ', '.join(missing) + ' is not installed!')
sys.exit(1) sys.exit(1)

View File

@@ -1,5 +1,5 @@
PySide6>=6.5.1 PySide6>=6.5.1
Pillow>=5.2.0 Pillow>=11.3.0
psutil>=5.9.5 psutil>=5.9.5
requests>=2.31.0 requests>=2.31.0
python-slugify>=1.2.1 python-slugify>=1.2.1

View File

@@ -75,7 +75,7 @@ setuptools.setup(
packages=['kindlecomicconverter'], packages=['kindlecomicconverter'],
install_requires=[ install_requires=[
'pyside6>=6.5.1', 'pyside6>=6.5.1',
'Pillow>=5.2.0', 'Pillow>=11.3.0',
'psutil>=5.9.5', 'psutil>=5.9.5',
'python-slugify>=1.2.1,<9.0.0', 'python-slugify>=1.2.1,<9.0.0',
'raven>=6.0.0', 'raven>=6.0.0',
@@ -83,7 +83,7 @@ setuptools.setup(
'mozjpeg-lossless-optimization>=1.1.2', 'mozjpeg-lossless-optimization>=1.1.2',
'natsort>=8.4.0', 'natsort>=8.4.0',
'distro', 'distro',
'numpy>=1.22.4,<2.0.0' 'numpy>=1.22.4'
], ],
classifiers=[], classifiers=[],
zip_safe=False, zip_safe=False,