Skip to content

Commit

Permalink
Kindle Scribe 1860 max width (#691)
Browse files Browse the repository at this point in the history
* Kindle Scribe 1860 max width

* create kindle_scribe_azw3 var

* clean up code
  • Loading branch information
axu2 authored May 17, 2024
1 parent 6bf662b commit cbc1ed5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 0 additions & 4 deletions kindlecomicconverter/comic2ebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,10 +1098,6 @@ def checkOptions(options):
image.ProfileData.Profiles["Custom"] = newProfile
options.profile = "Custom"
options.profileData = image.ProfileData.Profiles[options.profile]
# kindle scribe conversion to mobi is limited in resolution by kindlegen, same with send to kindle and epub
if options.profile == 'KS' and (options.format == 'MOBI' or options.format == 'EPUB'):
options.profileData = list(options.profileData)
options.profileData[1] = (1440, 1920)
return options


Expand Down
11 changes: 8 additions & 3 deletions kindlecomicconverter/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def __init__(self, options, mode, path, image, color, fill):
_, self.size, self.palette, self.gamma = self.opt.profileData
if self.opt.hq:
self.size = (int(self.size[0] * 1.5), int(self.size[1] * 1.5))
self.kindle_scribe_azw3 = (options.profile == 'KS') and (options.format in ('MOBI', 'EPUB'))
self.image = image
self.color = color
self.fill = fill
Expand Down Expand Up @@ -308,6 +309,9 @@ def quantizeImage(self):
self.image = self.image.quantize(palette=palImg)

def resizeImage(self):
# kindle scribe conversion to mobi is limited in resolution by kindlegen, same with send to kindle and epub
if self.kindle_scribe_azw3:
self.size = (1440, 1920)
ratio_device = float(self.size[1]) / float(self.size[0])
ratio_image = float(self.image.size[1]) / float(self.image.size[0])
method = self.resize_method()
Expand All @@ -326,14 +330,15 @@ def resizeImage(self):
elif self.opt.format == 'CBZ' or self.opt.kfx:
self.image = ImageOps.pad(self.image, self.size, method=method, color=self.fill)
else:
if self.kindle_scribe_azw3:
self.size[0] = 1860
self.image = ImageOps.contain(self.image, self.size, method=method)

def resize_method(self):
if self.image.size[0] <= self.size[0] and self.image.size[1] <= self.size[1]:
method = Image.Resampling.BICUBIC
return Image.Resampling.BICUBIC
else:
method = Image.Resampling.LANCZOS
return method
return Image.Resampling.LANCZOS

def getBoundingBox(self, tmptmg):
min_margin = [int(0.005 * i + 0.5) for i in tmptmg.size]
Expand Down

0 comments on commit cbc1ed5

Please sign in to comment.