Repository navigation
convert CBZ comic ZIP archives to fixed-layout EPUB - #3892
Conversation
| // https://github.com/readium/readium-lcp-server/blob/e2c484f571a8013faf13a335c007890150751d79/pack/pack.go#L265-L267 | ||
| // const doDeflate = (zipPath: string) => !/\.(PDF|PNG|JPE?G|MPE?G|HEIC|WEBP|MP3|MP4|WAV|OGG|AVI)$/i.test(zipPath); | ||
| const doDeflate = (_zipPath: string) => true; | ||
| const doDeflate = (zipPath: string) => zipPath !== "mimetype"; |
There was a problem hiding this comment.
EPUB’s mimetype entry has special ZIP requirements:
- It must be the first archive entry.
- Its content must be exactly
application/epub+zip. - It must be stored without compression.
createZip() previously compressed every entry. With:
const doDeflate = (zipPath: string) => zipPath !== "mimetype";Yazl uses ZIP method STORE (method === 0) for the root mimetype file while continuing to deflate every other resource. The accompanying buffersFirst option ensures it is also written first.
The condition matches only the exact root entry named mimetype, so existing WebPub and customization archives are otherwise unchanged. Without it, the converted file may render but is not a conforming EPUB and can fail validation or be rejected by stricter readers.
There was a problem hiding this comment.
Official reference: W3C EPUB 3.3 — §4.3.3 OCF ZIP container media type identification.
It requires that the mimetype file:
- Is the first ZIP entry.
- Contains exactly application/epub+zip.
- Is not compressed or encrypted.
- Has no ZIP-header extra field.
Fixes #3816
.cbzfiles through the file picker, drag-and-drop, CLI import, and OS file associations.mimetypeentry.1,2, and10appear in the expected order.ComicInfo.xmlmetadata:Tested with samples from https://www.contrapositivediary.com/?p=1197 and https://github.com/clach04/sample_reading_media