Posted by & filed under ebooks, epub.

[Today's guest post is by Keith Fahlgren. - Liza]

The three ePub specifications (OPF, OPS, and OCF) include a lot of detail on ebook metadata and markup, but do not include a technique for describing covers. Despite this omission (a fix is being discussed), there are some widely adopted approaches for marking up covers that will make the cover display correctly in most (but not all) ePub reading systems.

Ensuring the widest interoperability for your cover means including an XHTML cover page (as the first “flow”), a cover image, and bits of OPF metadata to refer to these items using consistent names.

Cover as XHTML

To get started, here’s an extremely minimal XHTML cover page that serves only to reference the cover image. This file should be named cover.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Cover</title>
    <style type="text/css"> img { max-width: 100%; } </style>
  </head>
  <body>
    <div id="cover-image">
      <img src="the_cover.jpg" alt="Title of this Thing, Second Edition"/>
    </div>
  </body>
</html>

Cover as image

Next, make sure the cover image itself, probably in JPEG (it’s a photo) or PNG (it isn’t) format, is scaled to less than 1000px in width and height. Choosing the perfect size for ebook images is still an open question given the growing range of screen sizes, but shrinking to 1000px should ensure that you don’t trigger a (historical) bug that crashed a popular mobile reading system by giving it a cover too large in size.

Covered in metadata

The real fun¡ is in the OPF file. First, make sure you have references to both the image and XHTML covers in your OPF manifest. The id attributes below are important to note:

Using the same value as the id attribute for the XHTML cover, add an initial itemref to the spine element that refers to the cover page but is not linear. This tells reading systems (like ADE) what position the XHTML cover should have in the document (must be first to trigger cover behavior), but asks that it not be displayed to the reader as part of the “linear reading order of the publication.”

The cover image also gets a special bit of metadata: a reference as a meta element inside the OPF metadata block. It’s critical that this use name="cover" as a signal to reading systems that would prefer to show covers as images rather than covers as XHTML:

Finally, it’s a good choice to include an OPF guide reference to your XHTML cover as a final hint to reading systems of what’s going on:

<guide>
  <reference href="cover.html" type="cover" title="Cover"/>

If you’ve gone to all this trouble to include a cover in your ebook, please don’t forget that readers expect it to be nice & in color.

Other approaches

Adobe’s EPUB Best Practices recommends a SVG-based approach to cover images. While it’s an interesting technique that can integrate well with Adobe Digital Editions, I haven’t found it to be widely supported.

Tags:

6 Responses to “Best practices in ePub cover images”

  1. Peter Sorotokin

    This is workable, but I would add body { oeb-column-number:1; }, so that cover is never displayed using multiple columns.

  2. Scott Ainsworth

    This method works with the ePub support in iTunes 9.1.

  3. Charles

    Using the same value as the id attribute for the XHTML cover, add an initial itemref to the spine element that refers to the cover page but is not linear. This tells reading systems (like ADE) what position the XHTML cover should have in the document (must be first to trigger cover behavior), but asks that it not be displayed to the reader as part of the “linear reading order of the publication.”

    By setting linear=”no” you run the risk that the reader won’t see the cover at all on some reading systems. It’s safe to leave this as linear=”yes” for ADE on the desktop and devices without it showing the cover twice.

Trackbacks/Pingbacks

  1.  Sarah Ettritch » Converting Word Files to ePub Files
  2.  Self-Publishing Adventure » Converting Word Files to ePub Files
  3.  Joho the Blog » Getting EPub wrong every possible way