Skip to content

[Bug]: EPUB cover extraction misses many valid EPUB3 files (meta cover + cover-image property) #126

@devnoname120

Description

@devnoname120

I’m testing kiwilan/php-ebook v3.0.09 for cover extraction, and EPUB cover detection looks incomplete.

Environment

  • PHP 8.1.34
  • kiwilan/php-ebook 3.0.09

What works

What doesn’t work

These EPUBs are valid and include a cover, but Ebook::read($path, 'epub')->getCover() is null:

Repro

<?php
require 'vendor/autoload.php';

use Kiwilan\Ebook\Ebook;

$urls = [
  'https://www.gutenberg.org/cache/epub/11/pg11-images-3.epub',
  'https://www.gutenberg.org/cache/epub/74/pg74-images-3.epub',
];

foreach ($urls as $url) {
  $path = __DIR__ . '/' . basename($url);
  file_put_contents($path, file_get_contents($url));

  $ebook = Ebook::read($path, 'epub');
  $hasCover = $ebook?->getCover() !== null ? 'yes' : 'no';

  echo basename($url) . " cover=" . $hasCover . PHP_EOL;
}

Expected

getCover() should return a cover for EPUBs that declare it via standard OPF metadata, including:

  • <meta name="cover" content="...">
  • manifest item with properties="cover-image"

Actual

For many EPUBs (above), getCover() is null.

For example in pg11-images-3.epub, OEBPS/content.opf contains:

  • <meta name="cover" content="id-5148086459379704571"/>
  • <item ... id="id-5148086459379704571" ... properties="cover-image"/>

But no cover is returned.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions