Skip to content

Instantly share code, notes, and snippets.

@bitsgalore bitsgalore/

Last active Aug 29, 2015
What would you like to do?
How to package an epub file using InfoZip


An EPUB is just a ZIP container, but using a ZIP tool directly on a directory with content documents won't usually result in a valid EPUB. This is because the standard requires that:

  1. The mimetype resource must appear as the first file in the container
  2. The mimetype resource must be uncompressed

So to meet these requirements we must ZIP the files in a special way. This gist describes how to do this with InfoZip (which is the default ZIP tool on most Linux systems).

Let's suppose all content files are in a directory called /home/johan/epubPolicyTests/content/epub20_minimal/.

Step 1: go to the content file directory

cd /home/johan/epubPolicyTests/content/epub20_minimal/

Step 2: create new ZIP file, add mimetype resource without compression

zip -X0 /home/johan/epubPolicyTests/build/epub20_minimal.epub mimetype

Step 3: add remaining files to ZIP file with compression

zip -rDX9 /home/johan/epubPolicyTests/build/epub20_minimal.epub * -x mimetype

Step 4: test with epubcheck

epubcheck /home/johan/epubPolicyTests/build/epub20_minimal.epub



Adapted from

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.