I'm using calibre to convert from epub files I've generated to (amongst other formats) Kindle/mobi. Using the calibre GUI on both Mac and PC, this works perfectly!
I've been trying to get the same process working on the commandline with calibre compiled under FreeBSD and am having trouble. The cover gets mangled/removed. In the resulting mobi file, the "cover" guide location is gone (ie, on the Kindle the cover is greyed out as a location to Go To) and if I import the converted mobi into the calibre GUI, the cover image shown is a random graphic from later in the book. Very odd!
Example command (does the same thing w/o output-profile):
ebook-convert isbn.epub isbn.mobi --output-profile kindle -v
I'm done some tracking down of the process, and here's what I've found:
The differences seem to be occurring in the file ebooks/epub/input.py and the function:
def rationalize_cover(self, opf, log)
specifically, near the end of the function:
renderer = render_html_svg_workaround(guide_cover, log)
On the GUI, renderer is not None...on the command line, renderer is None.
The divergence seems to occur in ebooks/__init__.py. The function render_html_svg_workaround() ends up calling render_html(path_to_html, width, height) which ends up calling "if not is_ok_to_use_qt(): return None"
not_is_ok_to_use_qt() returns False because it's a commandline with no X:
if (islinux or isfreebsd) and ':' not in os.environ.get('DISPLAY', ''):
Is there anything to be done here? I don't know the QT libraries at all and am not 100% sure I'm following the logic of what's going on. The files I would like to convert have no SVG, just a cover.jpg or cover.png. Is there any option for "don't change the cover at all" ?