![]() |
#1 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Dec 2010
Device: Kindle, iPad
|
Command line convert ePub->MOBI mangles cover
Hello,
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): Code:
ebook-convert isbn.epub isbn.mobi --output-profile kindle -v The differences seem to be occurring in the file ebooks/epub/input.py and the function: Code:
def rationalize_cover(self, opf, log) Code:
renderer = render_html_svg_workaround(guide_cover, log) 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: Code:
if (islinux or isfreebsd) and ':' not in os.environ.get('DISPLAY', ''): return False Thanks! |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,163
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Qt needs a connection to the X server to render the epub cover. Use xvfb or set you DISPLAY environment variable and XAUTH permissions correctly
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Dec 2010
Device: Kindle, iPad
|
Thanks very much for the reply; I'll give Xvfb a shot.
Should this situation--running ebook-convert at the console without any X environment be warned against, or should any error flags be thrown? I'd be happy to put together a patch if you think it would be a good idea. Alternatively, would it be a good thing to add a "don't modify cover" flag to be used optionally, or in a fallback situation if there's no X? Could be a totally stupid question, so apologies if so! Thanks again--calibre is a very impressive software package. |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,163
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
There is a warning about it in the conversion log if you run with --verbose
The problem is not cover modification it is that the EPUB file does not have a cover, instead EPUB requires reading system to render the first "screenfull" of the book as the cover. To do this, you need an X connection. |
![]() |
![]() |
![]() |
#5 | |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Dec 2010
Device: Kindle, iPad
|
Quote:
Code:
Metadata section: <meta name="cover" content="my-cover-image"/> Manifest section: <item href="OEBPS/cover.html" id="my-html-cover" media-type="application/xhtml+xml"/> <item href="OEBPS/cover.jpg" id="my-cover-image" media-type="image/jpeg"/> Spine section: <itemref idref="my-html-cover" linear="no" /> Guide section: <reference type="cover" title="Cover" href="cover.html"/> With regards to the command lineoutput, I had gotten the two error messages, and I wasn't really sure what they meant. They result from not being able to render the cover? Code:
Manifest item 'calibre_raster_cover.jpg' not found Guide reference 'calibre_raster_cover.jpg' not found |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,163
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Use xvfb.
|
![]() |
![]() |
![]() |
#7 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Dec 2010
Device: Kindle, iPad
|
Yeah, I tried Xvfb but so far I still haven't gotten the process to work correctly. The cover is included, but calibre_cover.jpg is cropped down to just the top-left corner of the original graphic. This doesn't happen when I run the convert on the same files from the GUI.
|
![]() |
![]() |
![]() |
#8 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,163
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
When you convert in the GUI it uses whatever cover you have set in the GUI. You can achieve the same effect on the CLI by using --cover
|
![]() |
![]() |
![]() |
Tags |
command line, epub, mobi, python |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Disable Cover for Command Line ebook-convert | bcolflesh | Calibre | 9 | 02-21-2013 11:02 AM |
command line mobi generation and covers | DarkAbsynthe | Calibre | 2 | 10-29-2010 10:33 PM |
Command Line Options for ebook-convert | godel10 | Calibre | 14 | 08-08-2009 08:28 AM |
Mobi Creator and the command line | Ortep | Kindle Formats | 1 | 06-11-2009 09:00 AM |
command line vs GUI (PDF->MOBI for K2) | tlc | Calibre | 12 | 02-24-2009 06:20 PM |