diff --git a/README.md b/README.md index 9a79c3dc..0b734df7 100644 --- a/README.md +++ b/README.md @@ -82,8 +82,8 @@ Options: MAIN: -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] + 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 -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 50e91dda..56b00c56 100644 --- a/kindlecomicconverter/KCC_gui.py +++ b/kindlecomicconverter/KCC_gui.py @@ -916,6 +916,9 @@ def __init__(self, kccapp, kccwindow): '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, @@ -938,6 +941,10 @@ def __init__(self, kccapp, kccwindow): '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, @@ -955,11 +962,14 @@ def __init__(self, kccapp, kccwindow): "Kindle Oasis 2/3", "Kindle Oasis", "Kindle Voyage", + "Kindle PW 5", "Kindle PW 3/4", "Kindle PW 1/2", "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 3fe23332..31ae0760 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -909,8 +909,8 @@ 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," - " KoGHD, KoA, KoAHD, KoAH2O, KoAO, KoF) [Default=KV]") + 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)") mainOptions.add_option("-q", "--hq", action="store_true", dest="hq", default=False, @@ -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' @@ -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 cd5d87ac..b13cb59d 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 diff --git a/kindlecomicconverter/image.py b/kindlecomicconverter/image.py index 35fcfc87..2bcee165 100755 --- a/kindlecomicconverter/image.py +++ b/kindlecomicconverter/image.py @@ -83,6 +83,7 @@ def __init__(self): '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), @@ -91,6 +92,8 @@ def __init__(self): '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), }