Skip to content

Epub Cover Page Variants

Kevin Routley edited this page Jan 19, 2023 · 4 revisions

The contents.opf file is used to specify the contents of the EPUB file, including a cover page. Unfortunately, EPUB files are not consistent in how they specify the cover info. This is due to changing EPUB standards over time, and differences between EPUB authoring programs. [Note too that the .opf might not be called contents.opf; it first had to be found by examining META-INF/container.xml].

Here I will attempt to describe the different EPUB cover page specifications DarkThumbs attempts to handle. The following examples are all taken from real EPUB files.

  1. <meta> tag and matching <item> tag. Match happens by id value. Example:
<meta name="cover" content="cover"/>
<item href="cover.jpeg" id="cover" media-type="image/jpeg"/>
  1. <meta> tag contains the cover file path. Note: this must be handled as a "fall-through" case of #1, because the id to match for might "look" like an image path. Example:
<meta name="cover" content="Images/cover.jpg" />

and a counter-example, which must be handled as case #1 above:

<meta content="cover.jpg" name="cover"/>
<item href="images/cover.jpg" id="cover.jpg" media-type="image/jpeg"/>
  1. Added for V1.2 : No useful <meta> tag but an <item> tag with an id value of "cover-image". Example:
<item href="EPUB/images/9781284157468_FC.jpg" id="cover-image" media-type="image/jpeg"/>
  1. TBD : No useful <meta> tag but an <item> tag with an id value of "cover".
<item id="cover" href="cover.xhtml" media-type="application/xhtml+xml" />

Note the href is to an (x)html file. The cover file may be found in the referenced file using an <img> tag:

<img class="cover-image" src="Images/37b858a6-f3e9-4df3-a4aa-be9255a82a21.png"/>
  1. A <manifest> entry with an id value of cover-image. Epub V3.0 support. For example:
<manifest>
    <item id="toc" properties="nav" href="TOC.xhtml" media-type="application/xhtml+xml"/>
    <item id="cover-image" properties="cover-image" href="images/a-christmas-carol.jpg" media-type="image/jpeg"/>
  1. An ebook from "Standard Ebooks": the cover image may be a SVG file. Check to see if the SVG file has an embedded, base64-encoded JPEG file. If so, decode that embedded file. [At this time, Microsoft Windows doesn't provide SVG support in their image library.]

  2. None of the above. DarkThumbs will use the first image file with the name "cover".

  3. None of the above. DarkThumbs will use the first image file (obeying the "Sort" option).