A command-line tool to convert EPUB files to CBZ format (comic book archive format).
epub2cbz is a Go application that extracts images from EPUB files and packages them into CBZ (Comic Book ZIP) archives. This tool is particularly useful for converting digital comic books or manga from EPUB format to CBZ format for use with comic book readers.
- Extract images from EPUB files
- Preserve page order when extracting images
- Convert to CBZ format (ZIP archive with .cbz extension)
- Recursive directory processing (optional, disabled by default)
- Preserve directory structure in output (when processing directories recursively)
- Generate ComicInfo.xml metadata file (when EPUB contains metadata)
To build from source:
- Make sure you have Go installed (version 1.16 or higher)
- Clone the repository:
git clone <repository-url> cd epub2cbz
- Build the binary:
go build
./epub2cbz [-r] [-v] [-h] [-j <num>] <input.epub> [output.cbz]./epub2cbz -r [-v] [-h] [-j <num>] <input_directory> [output_directory]./epub2cbz [-v] [-h] [-j <num>] <input_directory> [output_directory]-r(boolean): Process subdirectories recursively. Default isfalse.-v(boolean): Show version information.-h(boolean): Show help message.-j(integer): Number of parallel jobs to run. Defaults to the number of CPU cores.
-
Convert a single file:
./epub2cbz my_comic.epub my_comic.cbz
-
Convert a single file with automatic output name:
./epub2cbz my_comic.epub # Creates my_comic.cbz in the same directory -
Convert all EPUB files in a directory and subdirectories:
./epub2cbz -r /path/to/epubs /path/to/output
-
Convert all EPUB files in a directory using 4 parallel jobs:
./epub2cbz -r -j 4 /path/to/epubs /path/to/output
-
Convert only EPUB files in the top directory (not subdirectories, default):
./epub2cbz /path/to/epubs /path/to/output
The tool creates CBZ files with images named in sequential order (e.g., page001.jpg, page002.png, etc.) to ensure proper reading order in comic book readers.
When processing directories recursively, the output directory structure mirrors the input structure.
When EPUB files contain metadata (title, creator, publisher, series, etc.), the tool will automatically generate a ComicInfo.xml file in the output CBZ archive. This metadata enhances compatibility with comic book readers that support metadata display and organization.
The ComicInfo.xml file is only generated when the source EPUB contains useful metadata, avoiding unnecessary empty metadata files in the archive.