Quantcast
Channel: MobileRead Forums
Viewing all articles
Browse latest Browse all 50080

[Conversion Plugin] KFX Input

$
0
0
KFX Conversion Input Plugin

The KFX Input plugin allows books in KFX format to be converted to other e-book formats, such as EPUB, for archival and for reading on alternate devices. Amazon uses KFX format for the delivery of most e-books to customers. It supports advanced features, including Enhanced Typesetting and Page Flip, on Amazon apps and devices. A more in-depth discussion of the KFX format can be found in this thread.

Amazon's KF8 (azw3) format is superior to KFX as a source for conversion. This plugin has limited usefulness as long as KF8 is still easily obtainable.

As delivered by Amazon, books in KFX format are usually composed of multiple KFX container files. The entire set of KFX files that make up the book is required for successful conversion. Since calibre handles all e-book formats as a single file, this plugin accepts a ZIP archive with the extension ".kfx-zip" containing multiple KFX files. This will appear in calibre as KFX-ZIP format.

Alternatively, an entire book's content may be contained within a single monolithic KFX container file with a ".kfx" extension, as produced by the KFX Output plugin. The KFX Input plugin accepts this format (KFX) as an alternative to the multi-container format (KFX-ZIP).

Monolithic KFX is different from the files delivered by Amazon with a ".kfx" extension! Those contain only part of the book's content and cannot be converted individually.

Amazon's Kindle Textbook Creator and Kindle Create software export books in KPF (Kindle Package Format), which is proprietary to Amazon. This plugin will allow conversion of KPF, so that the author has greater control over the finished book.


Installation:

Install the plugin and restart calibre as described in the Introduction to plugins thread.


Usage:

A book must have either KFX, KFX-ZIP, or KPF format for conversion to be possible. The plugin is activated by selecting the proper input format when converting books in calibre.

A command line interface is also available. (See below.)


Producing KFX-ZIP archives for conversion:
Spoiler:

There is currently no software available to produce KFX-ZIP archive files. Each user of this plugin must produce their own for now. Because the procedure for doing this will vary based on the user's system, only general instructions are supplied here.
  • First, the KFX files that make up the book must be located. For Kindle for PC/Mac version 1.19 or greater the "My Kindle Content" folder will contain a sub-folder for each book, named with the ten character ASIN of the book followed by "_EBOK". The ASIN for each book is shown in the "Product details" of the book's Amazon web page.
  • Once the sub-folder of the book is located you can determine if that book is in KFX format by looking for a KFX DRM voucher file in it. A DRM voucher typically has a name containing the word "voucher" in it, such as: "amzn1.drm-voucher.v1.12d0d34e-b0de-11e7-abc4-cec278b6b50a.voucher". Another sign that a book is in KFX format is the presence of a file with the extension ".azw.md".
  • The main KFX file for the book, with an ".azw" extension, will have DRM encryption and must be replaced by an equivalent file that has had DRM removed. KFX is not yet supported by the most commonly used DRM removal tools, however a standalone program that can remove DRM from individual KFX files is available at Apprentice Harper's GitHub. Detailed instructions for DRM removal are not allowed on MobileRead so the process is not described here.
  • Once the book no longer contains DRM, create a ZIP archive of the book folder using a tool such as 7-Zip or WinZip. Extra files are ignored by the plugin so it is safe to include the entire book folder. Afterwards, manually change the file extension of the archive from ".zip" to ".kfx-zip".
  • The KFX-ZIP file can then be added to a calibre book entry using drag-and-drop or the "Add files to selected book records" (Shift-A) function. (If the "Add files" function is used the file type in the dialog must be changed from "Books" to "All files" in order to see KFX-ZIP files.)

A similar process is possible for KFX books from e-ink Kindle devices. In that case the KFX-ZIP archive needs to contain the ".kfx" file from the device's "documents" folder along with the contents of the ".sdr" folder associated with the book.

A software development strategy that could automate the above process is described in this thread. That work is outside of the scope of this plugin.



Command Line Interface:
Spoiler:

The KFX Input plugin command line interface bypasses the calibre conversion pipeline and can result in an EPUB that more closely matches the content and formatting of the original book. Conversion using this method is required for books with special formatting, such as fixed layout comics.

Code:

usage: calibre-debug -r "KFX Input" -- [-h] [-e EPUBVERSION] infile [outfile]

Convert e-book from KFX to EPUB.

positional arguments:
  infile                Pathname of the KFX, KFX-ZIP, or KPF file to be converted to EPUB.
  outfile              Optional pathname of the resulting EPUB file.

optional arguments:
  -h, --help            show this help message and exit
  -e EPUBVERSION, --epubversion EPUBVERSION
                        EPUB version to generate: 2.0, 3.0, 3.1




Limitations:
Spoiler:

The KFX format is undocumented and has changed over time. Some books may fail to convert or result in incorrect content or formatting. If the results of a conversion appear incorrect, it is recommended that the conversion job log be checked for errors and warnings. Please report problems in this MobileRead thread.

KFX is more highly processed than Amazon's KF8 (azw3) format, causing some details of the original e-book provided by the publisher to be lost during conversion, such as the exact HTML tags and styles used in the book. However, all of the text and most of the formatting should be preserved. Images may be reduced in resolution or converted to black and white to match the capabilities of the device on which they are viewed. These limitations make KFX less suitable for archival and conversion when compared with KF8.

All books currently supplied by Amazon in KFX format have DRM. This plugin only supports KFX files without DRM encryption. Removal of DRM must be accomplished by some means before this plugin can be used on Amazon-provided books.

This plugin does not contain a copy of the KFX symbol table. Some error messages may refer to KFX symbols in numeric form (such as $123). Interpreting these is not within the scope of this plugin.

This plugin requires calibre version 2.0 or later. Version 3.9 is later is required for conversion of books from e-ink Kindles containing JPEG-XR images.



Version History:
Spoiler:


Version 1.0.0 - 16 Oct 2017

Initial release.


Attached Files
File Type: zip KFX Input.zip (144.1 KB)

Viewing all articles
Browse latest Browse all 50080

Latest Images

Trending Articles



Latest Images