A Python script to automatically detect and merge double-page spreads in .cbz manga files, enhancing the reading experience.
- 📂 Automatic Extraction: Unzips
.cbzfiles into a temporary folder. - 🧠 Smart Spread Detection: Analyzes the left and right borders of images to detect spreads.
- Skips merging if either edge is completely black (commonly used for flashbacks or transitions).
- 🖼️ Image Merging: Combines two consecutive pages side by side if they qualify as a spread.
- 📦 CBZ Repackaging: Generates a new
.cbzfile with the suffix_fusedcontaining the merged pages.
- Python 3.x
- Pillow (PIL fork)
pip install pillowpython spread_fuse.py /path/to/file.cbzpython spread_fuse.py /path/to/folderThe script automatically detects whether the input is a file or a folder. All .cbz files in the folder will be processed.
For each .cbz file:
- Pages are extracted into a temporary folder.
- Consecutive images forming a spread are merged.
- A new
.cbzfile is created:original_name_fused.cbz.
- Images are extracted and sorted alphabetically.
- Each image is analyzed:
- If both current and next image have visible (non-white) borders and are not mostly black → they are merged.
- Merged images replace the original pair, and a new
.cbzfile is created with the updated content.
- Spread detection is based on:
- The percentage of black pixels on each border (default threshold: 45%).
- Presence of at least one non-white pixel on both edges.
- Border size and thresholds can be adjusted directly in the script.
Temporary folders are not automatically deleted by default.
You can uncomment theshutil.rmtree(...)lines in the script to enable cleanup after processing.
- GUI support for drag-and-drop usage.
- Command-line arguments to adjust thresholds.
- Support for
.cbrand.rarfiles.
This script is open source. Feel free to use or modify it for personal projects, scanlation teams, or manga reading tools.