mirror of
https://git.pumpin.online/funkpower/catena.git
synced 2026-11-13 23:55:40 +00:00
bookmeta: read an EPUB's cover, by the four routes a package can name one
The cover is the first image reached by EPUB 3's cover-image property, EPUB 2's <meta name="cover"> (by id, or by address where a converter wrote one), the guide's cover page and the first <img> or SVG <image> on it, and last any manifest image whose id or address says cover. A route that names something unusable leaves a note and the next is asked. Addresses are resolved against the document they are written in, with the fragment off and percent-escapes undone; one that climbs out of the archive or carries a scheme is not followed. Every member is read through a bound, checked against the size the archive declares and enforced on the read itself, so an understated entry stops at the cap too. The media type is read off the bytes, now WebP as well, and a manifest that disagrees is a note; bytes that are not an image are no cover. MAX_COVER (16 MiB) is the cap for both formats, so a Kindle cover record larger than that is left out as well.
This commit is contained in:
5 files changed
+819
-23
No files matched your search
@@ -20,6 +20,7 @@ to any of them is a change to a decision rather than to an accident.
|
||||
- [pdfgutter — a page tree that does not add up is refused](#pdfgutter--a-page-tree-that-does-not-add-up-is-refused)
|
||||
- [pdfgutter — a sheet on its side is cut the way it is read](#pdfgutter--a-sheet-on-its-side-is-cut-the-way-it-is-read)
|
||||
- [pdfgutter — an unreadable file is an answer, not a false](#pdfgutter--an-unreadable-file-is-an-answer-not-a-false)
|
||||
- [bookmeta — a cover is what its bytes say it is](#bookmeta--a-cover-is-what-its-bytes-say-it-is)
|
||||
- [Every pattern — two regex engines, two Unicode tables](#every-pattern--two-regex-engines-two-unicode-tables)
|
||||
|
||||
## cuenorm — settings after the end time are the format, not a malformation
|
||||
@@ -243,6 +244,23 @@ answers, and the [contract](contract.md) gives them three different numbers. A
|
||||
caller wanting them collapsed treats 1 and 2 alike; a caller wanting to know
|
||||
which files it failed on can now find out.
|
||||
|
||||
## bookmeta — a cover is what its bytes say it is
|
||||
|
||||
An EPUB's manifest gives every image a media type, and the cover's is not
|
||||
used: the type comes from the image's first bytes, and a disagreement is a
|
||||
note. Elsewhere `bookmeta` reports what the file says rather than what is
|
||||
true, and this is the one place it does not.
|
||||
|
||||
The difference is that a title nobody believes is still a title, while a
|
||||
media type that is wrong is an image that does not open. A caller handed
|
||||
`image/png` for a JPEG writes `cover.png`, serves it as PNG, or hands it to a
|
||||
decoder that refuses it. An image can be replaced by a converter or by hand
|
||||
without its manifest entry changing, and the note keeps what the file said,
|
||||
so nothing is lost by correcting it.
|
||||
|
||||
The same reasoning goes the other way: bytes that are not an image are not a
|
||||
cover, whatever the manifest calls them.
|
||||
|
||||
## Every pattern — two regex engines, two Unicode tables
|
||||
|
||||
Patterns here spell their character classes explicitly rather than leaning on
|
||||
|
||||
Reference in new issue
Block a user