johnfactotum / foliate-js

Render e-books in the browser
https://johnfactotum.github.io/foliate-js/reader.html
MIT License
318 stars 43 forks source link

EPUB: Find cover in non-conformant epub3 #20

Closed versalinyaa closed 3 months ago

versalinyaa commented 4 months ago

Some epubs from Kobo violate the epub spec in how they specify the cover image. Instead of defining an <item> with attribute [properties="cover-image"], they use attribute [id="cover"].

johnfactotum commented 4 months ago

Thanks. I'd be a bit hesitant to do this though. Looking at Kobo's spec it does not appear that this is something supported by Kobo. And the problem is that the value of id attribute should not be semantically significant. If you treat it that way it could break things for other books.

A similar thing exists in GNOME's EPUB thumbnailer, where it looks for images that are named "cover". Although it does work for some books, it just strikes me as a bad idea because there are perfectly valid reasons for a coverless book to contain a file named cover.jpg.