1
0
mirror of https://github.com/ciromattia/kcc synced 2026-07-24 05:33:15 +00:00

Replace KFX (does not work) with KFX (Send to Kindle EPUB) (#1309)

* add better kfx output

* fix kfx res

* fix bug

* fix bug

* no errors

* kfx defaults to PNG

* KFX 200 MB default

* clarify send to kindle

* fit close images

* adjust

* refactor contain

* initial fixes
This commit is contained in:
Alex Xu
2026-04-26 14:53:28 -07:00
committed by GitHub
parent d5dde46989
commit 1b48a9fc5e
4 changed files with 86 additions and 9 deletions
+17
View File
@@ -61,6 +61,23 @@ def getImageFileName(imgfile):
ext = ext.lower()
return [name, ext]
def get_contain_resolution(image, size):
'''same code as Pillow ImageOps.contain()'''
im_ratio = image.width / image.height
dest_ratio = size[0] / size[1]
if im_ratio != dest_ratio:
if im_ratio > dest_ratio:
new_height = round(image.height / image.width * size[0])
if new_height != size[1]:
size = (size[0], new_height)
else:
new_width = round(image.width / image.height * size[1])
if new_width != size[0]:
size = (new_width, size[1])
return size
def walkSort(dirnames, filenames):
convert = lambda text: int(text) if text.isdigit() else text