I’m a software developer who runs Scribophile, an online writing group for serious writers, Writerfolio, an online writing portfolio service for freelancers, and Standard Ebooks, an open source project that produces liberated ebooks for the true book lover.

Remove white borders from .mobi ebooks converted with Calibre

I have a Kindle but maintain my entire ebook library as epub files. Because Kindles are dumb, I have to convert my ebooks from epub to mobi so that the Kindle can read them. Calibre does a really good job of this, but every now and then I’d get a cover, or cover thumbnail, that would have a bizarre white border around the image. Sometimes the image would be offset by a top and left border, sometimes by a left and right border—it all seemed pretty random.

After messing around a bit, I discovered the problem. The ebook-convert command-line tool that ships with Calibre doesn’t actually use the cover image in the epub’s metadata. Instead, it opens up the cover page in the epub—usually the first xhtml file in the epub—then takes a “screenshot” of it to use as the cover image. Here’s the problem: if your cover page has margins, or if you, for example, wrapped your cover image tag in a p tag that has a text-indent style, the “screenshot” of the cover page will display those margins!

The solution: explicitly style the HTML in your cover page to remove all margins and text-indent. Then Calibre will take a correct “screenshot” and all will be well.

Beats me why Calibre doesn’t just use the .jpg file specified in the epub metadata!