formatOf

The format bytes are in, or null when they are none of them.

PDF is a %PDF- marker in the first kilobyte (leading junk is allowed, as it is in real files). EPUB is a ZIP whose first entry is the OCF mimetype, falling back to looking for META-INF/container.xml in the central directory for books that got the first entry wrong. CBZ is any other ZIP whose real entries are all images (packaging noise like ComicInfo.xml and Thumbs.db is ignored), so a photo backup with a readme inside stays unrecognized.

SVG is an <svg> element in the first half kilobyte, checked last so a PDF that happens to embed the text is not mistaken for one.

XPS and OpenXPS are OPC packages with a fixed document sequence (ECMA-388 §9.1.2), checked before the comic heuristic. ZIP checks read the central directory and small package metadata parts.