Skip to content

Commit

Permalink
Merge pull request #405 from darodi/kindle_signature
Browse files Browse the repository at this point in the history
Add profile for Kindle Paperwhite 5 (Signature Edition) - fixed for panel view 4/2/HQ
  • Loading branch information
darodi committed Jan 13, 2023
2 parents 4ec4c99 + aa4456b commit 7cac6d4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions kindlecomicconverter/KCC_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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",
Expand Down
15 changes: 6 additions & 9 deletions kindlecomicconverter/comic2ebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
20 changes: 14 additions & 6 deletions kindlecomicconverter/comic2panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions kindlecomicconverter/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
}
Expand Down

0 comments on commit 7cac6d4

Please sign in to comment.