Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 12-13-2010, 06:39 PM   #1
cscotts
Junior Member
cscotts began at the beginning.
 
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
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:

Code:
def rationalize_cover(self, opf, log)
specifically, near the end of the function:

Code:
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:
Code:
    if (islinux or isfreebsd) and ':' not in os.environ.get('DISPLAY', ''):
        return False
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" ?

Thanks!
cscotts is offline   Reply With Quote
Old 12-13-2010, 08:29 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
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
kovidgoyal is offline   Reply With Quote
Advert
Old 12-13-2010, 08:59 PM   #3
cscotts
Junior Member
cscotts began at the beginning.
 
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.
cscotts is offline   Reply With Quote
Old 12-13-2010, 09:06 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
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.
kovidgoyal is offline   Reply With Quote
Old 12-13-2010, 09:59 PM   #5
cscotts
Junior Member
cscotts began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Dec 2010
Device: Kindle, iPad
Quote:
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.
So in my OPF file I have lines:

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"/>
Are those lines not good enough, or somehow non-standard? It seems like if I do an EPUB->EPUB convert calibre basically just replaces the "cover.html" with "titlepage.xhtml" and wraps the cover <img> tag in a <svg> tag.


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
cscotts is offline   Reply With Quote
Advert
Old 12-13-2010, 10:13 PM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Use xvfb.
kovidgoyal is offline   Reply With Quote
Old 12-13-2010, 11:24 PM   #7
cscotts
Junior Member
cscotts began at the beginning.
 
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.
cscotts is offline   Reply With Quote
Old 12-14-2010, 12:21 AM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
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
kovidgoyal is offline   Reply With Quote
Reply

Tags
command line, epub, mobi, python

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 03:41 AM.


MobileRead.com is a privately owned, operated and funded community.