From 9fdbf095d34db264fa9511da1f79fa7f9782b324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bri=C3=A8re?= Date: Tue, 12 Nov 2019 11:48:48 -0500 Subject: [PATCH 1/4] Add profiles for the Kobo Clara HD and Libra H2O Note: I omitted the "HD" and "H2O" suffixes from the labels to keep things simple, since they do not denote a variation of a preexisting model, as was the case with the Aura. --- README.md | 2 +- kindlecomicconverter/KCC_gui.py | 6 ++++++ kindlecomicconverter/comic2ebook.py | 2 +- kindlecomicconverter/image.py | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a79c3d..f28f196 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Options: -p PROFILE, --profile=PROFILE Device profile (Available options: K1, K2, K34, K578, KDX, KPW, KV, KO, KoMT, KoG, KoGHD, KoA, KoAHD, KoAH2O, - KoAO, KoF) [Default=KV] + KoAO, KoC, KoL, KoF) [Default=KV] -m, --manga-style Manga style (right-to-left reading and splitting) -q, --hq Try to increase the quality of magnification -2, --two-panel Display two not four panels in Panel View mode diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py index 50e91dd..d865ff1 100644 --- a/kindlecomicconverter/KCC_gui.py +++ b/kindlecomicconverter/KCC_gui.py @@ -938,6 +938,10 @@ class KCCGUI(KCC_ui.Ui_mainWindow): 'DefaultUpscale': True, 'Label': 'KoAH2O'}, "Kobo Aura ONE": {'PVOptions': False, 'ForceExpert': False, 'DefaultFormat': 1, 'DefaultUpscale': True, 'Label': 'KoAO'}, + "Kobo Clara HD": {'PVOptions': False, 'ForceExpert': False, 'DefaultFormat': 1, + 'DefaultUpscale': True, 'Label': 'KoC'}, + "Kobo Libra H2O": {'PVOptions': False, 'ForceExpert': False, 'DefaultFormat': 1, + 'DefaultUpscale': True, 'Label': 'KoL'}, "Kobo Forma": {'PVOptions': False, 'ForceExpert': False, 'DefaultFormat': 1, 'DefaultUpscale': True, 'Label': 'KoF'}, "Other": {'PVOptions': False, 'ForceExpert': True, 'DefaultFormat': 1, @@ -960,6 +964,8 @@ class KCCGUI(KCC_ui.Ui_mainWindow): "Kindle", "Separator", "Kobo Forma", + "Kobo Libra H2O", + "Kobo Clara HD", "Kobo Aura ONE", "Kobo Aura H2O", "Kobo Aura HD", diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 3fe2333..0f20b02 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -910,7 +910,7 @@ def makeParser(): mainOptions.add_option("-p", "--profile", action="store", dest="profile", default="KV", help="Device profile (Available options: K1, K2, K34, K578, KDX, KPW, KV, KO, KoMT, KoG," - " KoGHD, KoA, KoAHD, KoAH2O, KoAO, KoF) [Default=KV]") + " KoGHD, KoA, KoAHD, KoAH2O, KoAO, KoC, KoL, KoF) [Default=KV]") mainOptions.add_option("-m", "--manga-style", action="store_true", dest="righttoleft", default=False, help="Manga style (right-to-left reading and splitting)") mainOptions.add_option("-q", "--hq", action="store_true", dest="hq", default=False, diff --git a/kindlecomicconverter/image.py b/kindlecomicconverter/image.py index 35fcfc8..2717a15 100755 --- a/kindlecomicconverter/image.py +++ b/kindlecomicconverter/image.py @@ -91,6 +91,8 @@ class ProfileData: 'KoAHD': ("Kobo Aura HD", (1080, 1440), Palette16, 1.8), 'KoAH2O': ("Kobo Aura H2O", (1080, 1430), Palette16, 1.8), 'KoAO': ("Kobo Aura ONE", (1404, 1872), Palette16, 1.8), + 'KoC': ("Kobo Clara HD", (1072, 1448), Palette16, 1.8), + 'KoL': ("Kobo Libra H2O", (1264, 1680), Palette16, 1.8), 'KoF': ("Kobo Forma", (1440, 1920), Palette16, 1.8), 'OTHER': ("Other", (0, 0), Palette16, 1.8), } From 6519eb04533693f5ec908e69fb1cb5cb382e22a3 Mon Sep 17 00:00:00 2001 From: Fulya Date: Sat, 15 May 2021 14:08:36 -0400 Subject: [PATCH 2/4] Fixed the skipped/missed images and/or panels --- kindlecomicconverter/comic2ebook.py | 7 ++----- kindlecomicconverter/comic2panel.py | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 3fe2333..237d0a2 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -1078,10 +1078,7 @@ def makeBook(source, qtgui=None): getComicInfo(os.path.join(path, "OEBPS", "Images"), source) detectCorruption(os.path.join(path, "OEBPS", "Images"), source) if options.webtoon: - if image.ProfileData.Profiles[options.profile][1][1] > 1024: - y = 1024 - else: - y = image.ProfileData.Profiles[options.profile][1][1] + y = image.ProfileData.Profiles[options.profile][1][1] comic2panel.main(['-y ' + str(y), '-i', '-m', path], qtgui) print("Processing images...") if GUI: @@ -1222,7 +1219,7 @@ def makeMOBI(work, qtgui=None): threadNumber = 1 elif 2 < availableMemory <= 4: threadNumber = 2 - elif 4 < availableMemory <= 8: + elif 4 < availableMemory: threadNumber = 4 else: threadNumber = None diff --git a/kindlecomicconverter/comic2panel.py b/kindlecomicconverter/comic2panel.py index cd5d87a..b13cb59 100644 --- a/kindlecomicconverter/comic2panel.py +++ b/kindlecomicconverter/comic2panel.py @@ -57,9 +57,8 @@ def mergeDirectory(work): if len(images) > 0: targetWidth = max(set(sizes), key=sizes.count) for i in images: - if i[1] <= targetWidth: - targetHeight += i[2] - imagesValid.append(i[0]) + targetHeight += i[2] + imagesValid.append(i[0]) # Silently drop directories that contain too many images # 131072 = GIMP_MAX_IMAGE_SIZE / 4 if targetHeight > 131072: @@ -68,8 +67,10 @@ def mergeDirectory(work): y = 0 for i in imagesValid: img = Image.open(i).convert('RGB') - if img.size[0] < targetWidth: - img = ImageOps.fit(img, (targetWidth, img.size[1]), method=Image.BICUBIC, centering=(0.5, 0.5)) + if img.size[0] < targetWidth or img.size[0] > targetWidth: + widthPercent = (targetWidth / float(img.size[0])) + heightSize = int((float(img.size[1]) * float(widthPercent))) + img = ImageOps.fit(img, (targetWidth, heightSize), method=Image.BICUBIC, centering=(0.5, 0.5)) result.paste(img, (0, y)) y += img.size[1] os.remove(i) @@ -100,6 +101,8 @@ def splitImage(work): name = work[1] opt = work[2] filePath = os.path.join(path, name) + Image.warnings.simplefilter('error', Image.DecompressionBombWarning) + Image.MAX_IMAGE_PIXELS = 1000000000 imgOrg = Image.open(filePath).convert('RGB') imgProcess = Image.open(filePath).convert('1') widthImg, heightImg = imgOrg.size @@ -113,11 +116,16 @@ def splitImage(work): panelDetected = False panels = [] while yWork < heightImg: - tmpImg = imgProcess.crop([0, yWork, widthImg, yWork + 4]) + tmpImg = imgProcess.crop([4, yWork, widthImg-4, yWork + 4]) solid = detectSolid(tmpImg) if not solid and not panelDetected: panelDetected = True panelY1 = yWork - 2 + if heightImg - yWork <= 5: + if not solid and panelDetected: + panelY2 = heightImg + panelDetected = False + panels.append((panelY1, panelY2, panelY2 - panelY1)) if solid and panelDetected: panelDetected = False panelY2 = yWork + 6 From c91be77588917b5f262a7d99eed1046b8c0f1dd3 Mon Sep 17 00:00:00 2001 From: Einlar Date: Sat, 13 Nov 2021 13:50:56 +0100 Subject: [PATCH 3/4] Add profile for Kindle PW5/Signature --- README.md | 2 +- kindlecomicconverter/KCC_gui.py | 4 ++++ kindlecomicconverter/comic2ebook.py | 2 +- kindlecomicconverter/image.py | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f28f196..0b734df 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Options: MAIN: -p PROFILE, --profile=PROFILE Device profile (Available options: K1, K2, K34, K578, - KDX, KPW, KV, KO, KoMT, KoG, KoGHD, KoA, KoAHD, KoAH2O, + KDX, KPW, KPW5, KV, KO, KoMT, KoG, KoGHD, KoA, KoAHD, KoAH2O, KoAO, KoC, KoL, KoF) [Default=KV] -m, --manga-style Manga style (right-to-left reading and splitting) -q, --hq Try to increase the quality of magnification diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py index d865ff1..56b00c5 100644 --- a/kindlecomicconverter/KCC_gui.py +++ b/kindlecomicconverter/KCC_gui.py @@ -916,6 +916,9 @@ class KCCGUI(KCC_ui.Ui_mainWindow): 'DefaultUpscale': True, 'Label': 'KV'}, "Kindle Voyage": {'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, 'DefaultUpscale': True, 'Label': 'KV'}, + "Kindle PW 5": { + 'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, 'DefaultUpscale': True, 'Label': 'KPW5', + }, "Kindle PW 3/4": {'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, 'DefaultUpscale': True, 'Label': 'KV'}, "Kindle PW 1/2": {'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, @@ -959,6 +962,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow): "Kindle Oasis 2/3", "Kindle Oasis", "Kindle Voyage", + "Kindle PW 5", "Kindle PW 3/4", "Kindle PW 1/2", "Kindle", diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 77be0b9..42dc607 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -909,7 +909,7 @@ def makeParser(): otherOptions = OptionGroup(psr, "OTHER") mainOptions.add_option("-p", "--profile", action="store", dest="profile", default="KV", - help="Device profile (Available options: K1, K2, K34, K578, KDX, KPW, KV, KO, KoMT, KoG," + help="Device profile (Available options: K1, K2, K34, K578, KDX, KPW, KPW5, KV, KO, KoMT, KoG," " KoGHD, KoA, KoAHD, KoAH2O, KoAO, KoC, KoL, KoF) [Default=KV]") mainOptions.add_option("-m", "--manga-style", action="store_true", dest="righttoleft", default=False, help="Manga style (right-to-left reading and splitting)") diff --git a/kindlecomicconverter/image.py b/kindlecomicconverter/image.py index 2717a15..2bcee16 100755 --- a/kindlecomicconverter/image.py +++ b/kindlecomicconverter/image.py @@ -83,6 +83,7 @@ class ProfileData: 'KDX': ("Kindle DX/DXG", (824, 1000), Palette16, 1.8), 'KPW': ("Kindle Paperwhite 1/2", (758, 1024), Palette16, 1.8), 'KV': ("Kindle Paperwhite 3/4/Voyage/Oasis", (1072, 1448), Palette16, 1.8), + 'KPW5': ("Kindle Paperwhite 5/Signature Edition", (1236, 1648), Palette16, 1.8), 'KO': ("Kindle Oasis 2/3", (1264, 1680), Palette16, 1.8), 'KoMT': ("Kobo Mini/Touch", (600, 800), Palette16, 1.8), 'KoG': ("Kobo Glo", (768, 1024), Palette16, 1.8), From aa4456bdb1c1d51733e4d89acee0b5b3ad29f097 Mon Sep 17 00:00:00 2001 From: darodi <4682830+darodi@users.noreply.github.com> Date: Sat, 27 Nov 2021 23:57:45 +0100 Subject: [PATCH 4/4] Add profile for Kindle PW5/Signature --- kindlecomicconverter/comic2ebook.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 42dc607..31ae076 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -974,13 +974,13 @@ def checkOptions(): options.bordersColor = None options.kfx = False if options.format == 'Auto': - if options.profile in ['K1', 'K2', 'K34', 'K578', 'KPW', 'KV', 'KO']: + if options.profile in ['K1', 'K2', 'K34', 'K578', 'KPW', 'KPW5', 'KV', 'KO']: options.format = 'MOBI' elif options.profile in ['OTHER', 'KoMT', 'KoG', 'KoGHD', 'KoA', 'KoAHD', 'KoAH2O', 'KoAO']: options.format = 'EPUB' elif options.profile in ['KDX']: options.format = 'CBZ' - if options.profile in ['K1', 'K2', 'K34', 'K578', 'KPW', 'KV', 'KO']: + if options.profile in ['K1', 'K2', 'K34', 'K578', 'KPW', 'KPW5', 'KV', 'KO']: options.iskindle = True if options.white_borders: options.bordersColor = 'white'