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

Merged DX/DXG profiles. Fixed PNG quantification.

This commit is contained in:
Paweł Jastrzębski
2013-10-07 12:34:44 +02:00
parent 279f70a6bd
commit 5077f60881
4 changed files with 12 additions and 15 deletions

View File

@@ -69,7 +69,7 @@ Usage: comic2ebook.py [options] comic_file|comic_folder
Options: Options:
MAIN: MAIN:
-p PROFILE, --profile=PROFILE -p PROFILE, --profile=PROFILE
Device profile (Choose one among K1, K2, K345, KDX, KDXG, KHD, KF, KFHD, KFHD8, KFHDX, KFHDX8, KFA) [Default=KHD] Device profile (Choose one among K1, K2, K345, KDX, KHD, KF, KFHD, KFHD8, KFHDX, KFHDX8, KFA) [Default=KHD]
-q QUALITY, --quality=QUALITY -q QUALITY, --quality=QUALITY
Quality of Panel View. 0 - Normal 1 - High 2 - Ultra [Default=0] Quality of Panel View. 0 - Normal 1 - High 2 - Ultra [Default=0]
-m, --manga-style Manga style (Right-to-left reading and splitting) -m, --manga-style Manga style (Right-to-left reading and splitting)

View File

@@ -255,7 +255,7 @@ class WorkerThread(QtCore.QThread):
mobiPath = item.replace('.epub', '.mobi') mobiPath = item.replace('.epub', '.mobi')
shutil.move(mobiPath, mobiPath + '_toclean') shutil.move(mobiPath, mobiPath + '_toclean')
try: try:
if profile in ['K345', 'KHD', 'KF', 'KFHD', 'KFHD8', 'KFHDX', 'KFHDX8', 'KFA']: if profile in ['K345', 'KHD', 'KF', 'KFHD', 'KFHD8', 'KFHDX8', 'KFA']:
newKindle = True newKindle = True
else: else:
newKindle = False newKindle = False
@@ -534,7 +534,7 @@ class Ui_KCC(object):
GUI.BasicModeButton.setEnabled(True) GUI.BasicModeButton.setEnabled(True)
GUI.AdvModeButton.setEnabled(True) GUI.AdvModeButton.setEnabled(True)
self.modeBasic() self.modeBasic()
if value in [9, 11, 12, 13, 14]: if value in [9, 11, 12, 13]:
GUI.QualityBox.setChecked(False) GUI.QualityBox.setChecked(False)
GUI.QualityBox.setEnabled(False) GUI.QualityBox.setEnabled(False)
self.QualityBoxDisabled = True self.QualityBoxDisabled = True

View File

@@ -800,7 +800,7 @@ def main(argv=None, qtGUI=None):
customProfileOptions = OptionGroup(parser, "CUSTOM PROFILE") customProfileOptions = OptionGroup(parser, "CUSTOM PROFILE")
otherOptions = OptionGroup(parser, "OTHER") otherOptions = OptionGroup(parser, "OTHER")
mainOptions.add_option("-p", "--profile", action="store", dest="profile", default="KHD", mainOptions.add_option("-p", "--profile", action="store", dest="profile", default="KHD",
help="Device profile (Choose one among K1, K2, K345, KDX, KDXG, KHD, KF, KFHD, KFHD8, KFHDX," help="Device profile (Choose one among K1, K2, K345, KDX, KHD, KF, KFHD, KFHD8, KFHDX,"
" KFHDX8, KFA) [Default=KHD]") " KFHDX8, KFA) [Default=KHD]")
mainOptions.add_option("-q", "--quality", type="int", dest="quality", default="0", mainOptions.add_option("-q", "--quality", type="int", dest="quality", default="0",
help="Quality of Panel View. 0 - Normal 1 - High 2 - Ultra [Default=0]") help="Quality of Panel View. 0 - Normal 1 - High 2 - Ultra [Default=0]")
@@ -945,7 +945,7 @@ def checkOptions():
else: else:
options.forcecolor = False options.forcecolor = False
# Older Kindle don't need higher resolution files due lack of Panel View. # Older Kindle don't need higher resolution files due lack of Panel View.
if options.profile == 'K1' or options.profile == 'K2' or options.profile == 'KDX' or options.profile == 'KDXG': if options.profile == 'K1' or options.profile == 'K2' or options.profile == 'KDX':
options.quality = 0 options.quality = 0
options.panelview = False options.panelview = False
# Webtoon mode mandatory options # Webtoon mode mandatory options

View File

@@ -85,8 +85,7 @@ class ProfileData:
'K2': ("Kindle 2", (600, 670), Palette15, 1.8, (900, 1005)), 'K2': ("Kindle 2", (600, 670), Palette15, 1.8, (900, 1005)),
'K345': ("Kindle", (600, 800), Palette16, 1.8, (900, 1200)), 'K345': ("Kindle", (600, 800), Palette16, 1.8, (900, 1200)),
'KHD': ("Kindle Paperwhite", (758, 1024), Palette16, 1.8, (1137, 1536)), 'KHD': ("Kindle Paperwhite", (758, 1024), Palette16, 1.8, (1137, 1536)),
'KDX': ("Kindle DX", (824, 1000), Palette15, 1.8, (1236, 1500)), 'KDX': ("Kindle DX/DXG", (824, 1000), Palette16, 1.8, (1236, 1500)),
'KDXG': ("Kindle DXG", (824, 1000), Palette16, 1.8, (1236, 1500)),
'KF': ("Kindle Fire", (600, 1024), PalleteNull, 1.0, (900, 1536)), 'KF': ("Kindle Fire", (600, 1024), PalleteNull, 1.0, (900, 1536)),
'KFHD': ("K. Fire HD 7\"", (800, 1280), PalleteNull, 1.0, (1200, 1920)), 'KFHD': ("K. Fire HD 7\"", (800, 1280), PalleteNull, 1.0, (1200, 1920)),
'KFHD8': ("K. Fire HD 8.9\"", (1200, 1920), PalleteNull, 1.0, (1800, 2880)), 'KFHD8': ("K. Fire HD 8.9\"", (1200, 1920), PalleteNull, 1.0, (1800, 2880)),
@@ -101,8 +100,7 @@ class ProfileData:
"Kindle 2": 'K2', "Kindle 2": 'K2',
"Kindle": 'K345', "Kindle": 'K345',
"Kindle Paperwhite": 'KHD', "Kindle Paperwhite": 'KHD',
"Kindle DX": 'KDX', "Kindle DX/DXG": 'KDX',
"Kindle DXG": 'KDXG',
"Kindle Fire": 'KF', "Kindle Fire": 'KF',
"K. Fire HD 7\"": 'KFHD', "K. Fire HD 7\"": 'KFHD',
"K. Fire HD 8.9\"": 'KFHD8', "K. Fire HD 8.9\"": 'KFHD8',
@@ -126,8 +124,7 @@ class ProfileData:
"Separator", "Separator",
"Kindle 1", "Kindle 1",
"Kindle 2", "Kindle 2",
"Kindle DX", "Kindle DX/DXG",
"Kindle DXG",
"Kindle Fire" "Kindle Fire"
] ]
@@ -168,8 +165,8 @@ class ComicPage:
def saveToDir(self, targetdir, forcepng, color, wipe): def saveToDir(self, targetdir, forcepng, color, wipe):
try: try:
suffix = "" suffix = ""
if not color: if not color and not forcepng:
self.image = self.image.convert('L') # convert to grayscale self.image = self.image.convert('L')
if self.rotated: if self.rotated:
suffix += "_kccrot" suffix += "_kccrot"
if wipe: if wipe:
@@ -200,13 +197,13 @@ class ComicPage:
self.image = ImageOps.autocontrast(Image.eval(self.image, lambda a: 255 * (a / 255.) ** gamma)) self.image = ImageOps.autocontrast(Image.eval(self.image, lambda a: 255 * (a / 255.) ** gamma))
def quantizeImage(self): def quantizeImage(self):
self.image = self.image.convert('L') # convert to grayscale
self.image = self.image.convert("RGB") # convert back to RGB
colors = len(self.palette) / 3 colors = len(self.palette) / 3
if colors < 256: if colors < 256:
self.palette += self.palette[:3] * (256 - colors) self.palette += self.palette[:3] * (256 - colors)
palImg = Image.new('P', (1, 1)) palImg = Image.new('P', (1, 1))
palImg.putpalette(self.palette) palImg.putpalette(self.palette)
self.image = self.image.convert('L')
self.image = self.image.convert('RGB')
self.image = self.image.quantize(palette=palImg) self.image = self.image.quantize(palette=palImg)
def resizeImage(self, upscale=False, stretch=False, bordersColor=None, qualityMode=0): def resizeImage(self, upscale=False, stretch=False, bordersColor=None, qualityMode=0):