A Docker image for converting eBooks using Calibre with KFX support.
KFX is Amazon's proprietary eBook format used for Kindle devices.
Because Amazon's Kindle Previewer 3 is the only way currently to convert books into KFX using Calibre KFX Input and KFX Output plugins, and it's not available on Linux, so I run it under docker using Wine.
To use the Docker image, you can build it locally using the Dockerfile provided in this repository, or you can pull the image from Docker Hub using the following command:
docker pull yshalsager/calibre-with-kfxOnce you have the Docker image, you can run it using the following command:
docker run --rm -it -v "/path/to/local/folder:/app:rw" yshalsager/calibre-with-kfx [input_file] [output_file] [extra args]- Convert to azw3 with extra arguments:
docker run --rm -it -v "$(pwd):/app:rw" yshalsager/calibre-with-kfx epub30-spec.epub epub30-spec.azw3 --dont-compress - Convert to KFX:
docker run --rm -it -v "$(pwd):/app:rw" yshalsager/calibre-with-kfx epub30-spec.epub epub30-spec.kfx - Convert to KFX with approximate page numbers (auto):
docker run --rm -it -v "$(pwd):/app:rw" yshalsager/calibre-with-kfx book.epub book.kfx --pages 0
When converting to KFX, extra args are passed to the KFX Output plugin (calibre-debug -r "KFX Output" -- ...). Useful flags include:
--pages Ncreate approximate page numbers if missing (0= auto)--bookmark as EBOK (vs default PDOC)--asin BXXXXXXXXXset an ASIN--logsinclude Kindle Previewer conversion logs--qualityinclude Kindle Previewer quality report--timeoutstop conversions lasting over ~15 minutes
When converting from KFX to other formats, this image uses ebook-convert normally. Any ebook-convert CLI options can be passed as extra args.
The KFX Input plugin also provides a separate CLI (useful for print replica PDF extraction, CBZ creation, resource unpacking, etc):
docker run --rm -it -v "$(pwd):/app:rw" --entrypoint calibre-debug yshalsager/calibre-with-kfx \
-r "KFX Input" -- /app/book.kfx --helpCommon KFX Input CLI flags:
--epub(default),--epub2--pdfextract/produce PDF (print replica, comics/children's)--cbzcreate CBZ (print replica, comics/children's)--unpackextract resources to a ZIP--json-contentcreate JSON content/position file--coverforce a generic EPUB cover if missing
KFX Input has one calibre "Convert Books" option: allow_conversion_with_errors (default off). It also has plugin preferences used by its CLI/From-KFX UI (for example splitting landscape comic images when creating PDF).
The docker image versions are tagged with build date and time. There's a GitHub release for each tag that lists versions of each component of the image, like base OS, Calibre and its plugins, and Kindle Previewer.
Whenever any component gets updated, a new image is built and pushed.