-
Notifications
You must be signed in to change notification settings - Fork 0
Creating CBT Files
riomoo edited this page Feb 4, 2026
·
3 revisions
This guide covers multiple methods for creating CBT (Comic Book TAR) files with or without encryption.
- Bash shell (Linux/Mac/WSL)
- OpenSSL
- Standard Unix tools (tar, sha256sum, xxd)
The cbt.sh script is included in the scripts-bash/comic-scripts/ directory:
chmod +x scripts-bash/comic-scripts/cbt.sh./scripts-bash/comic-scripts/cbt.sh create -i /path/to/comic/images -o mycomic.cbtExample:
./scripts-bash/comic-scripts/cbt.sh create -i ./my-comic-pages-folder -o amazing-comic.cbtThis will:
- Create a TAR archive from all files in the directory
- Save it as
amazing-comic.cbt - Display list of files added
./scripts-bash/comic-scripts/cbt.sh create -i /path/to/comic/images -o mycomic.cbt -p "your-password"Example:
./scripts-bash/comic-scripts/cbt.sh create -i ./my-comic-pages-folder -o secret-comic.cbt -p "super-secret-123"This will:
- Create a TAR archive
- Encrypt it using AES-256-CFB
- Save the encrypted CBT file
Unencrypted:
./scripts-bash/comic-scripts/cbt.sh extract -i mycomic.cbt -o ./extractedEncrypted:
./scripts-bash/comic-scripts/cbt.sh extract -i secret-comic.cbt -o ./extracted -p "your-password"Usage:
Create: cbt.sh create -i <input_directory> -o <output_file> [-p <password>]
Extract: cbt.sh extract -i <input_file> -o <output_directory> [-p <password>]
Options:
-i Input directory/file
-o Output file/directory
-p Password for encryption/decryption (optional)
- Go 1.25.2 or higher
go build -o cbt scripts-go/cbt.go./cbt -input /path/to/images -output mycomic.cbtExample:
./cbt -input ./comic-pages-folder -output "My Amazing Comic.cbt"./cbt -input /path/to/images -output mycomic.cbt -password "your-password"Example:
./cbt -input ./comic-pages-folder -output "Secret Comic.cbt" -password "super-secret-123"Usage: cbt -input <directory> -output <file.cbt> [-password <password>]
Flags:
-input string
Input directory containing comic files
-output string
Output .cbt file
-password string
Password for encryption (leave empty for no encryption)
cd /path/to/comic/images
tar -cf ../mycomic.cbt *-
Create TAR archive:
tar -cf temp.tar * -
Encrypt using OpenSSL:
# Generate key from password KEY=$(echo -n "your-password" | sha256sum | cut -d' ' -f1) # Generate random IV openssl rand -out iv.bin 16 # Encrypt openssl enc -aes-256-cfb -K "$KEY" -iv $(xxd -p -c 256 iv.bin) -in temp.tar -out temp.enc # Combine IV and encrypted data cat iv.bin temp.enc > mycomic.cbt # Cleanup rm temp.tar iv.bin temp.enc
comic-pages/
├── 001.jpg
├── 002.jpg
├── 003.jpg
├── ...
└── ComicInfo.xml
Use zero-padded numbers for proper sorting:
- ✅
001.jpg,002.jpg,003.jpg - ❌
1.jpg,2.jpg,3.jpg
Always include metadata for best results:
<?xml version="1.0" encoding="utf-8"?>
<ComicInfo>
<Title>My Comic Title</Title>
<Series>My Series</Series>
<Number>1</Number>
<Writer>Author Name</Writer>
<Artist>Artist Name</Artist>
<Publisher>Publisher</Publisher>
<Genre>Action, Adventure</Genre>
<Year>2024</Year>
<PageCount>24</PageCount>
</ComicInfo>Create batch-cbt.sh:
#!/bin/bash
PASSWORD="your-default-password"
for dir in */; do
dirname="${dir%/}"
echo "Processing: $dirname"
./cbt.sh create -i "$dir" -o "${dirname}.cbt" -p "$PASSWORD"
done
echo "Batch creation complete!"Usage:
chmod +x batch-cbt.sh
./batch-cbt.shStore passwords securely with GPG:
#!/bin/bash
# Store password encrypted
echo "my-secret-password" | gpg -e -r your@email.com > password.gpg
# Use in script
PASSWORD=$(gpg -qd password.gpg)
./cbt.sh create -i ./comic -o comic.cbt -p "$PASSWORD"- Upload to Gopherbook via web UI
- Or place in watch folder:
cp mycomic.cbt ./watch/[username]/
# Should fail if encrypted
tar -tf mycomic.cbt
# Should succeed if unencrypted
tar -tf mycomic.cbt./cbt.sh extract -i mycomic.cbt -o test-extract -p "password"
ls test-extract/Convert PDF or images to comic pages:
# Convert PDF to images
magick convert -density 300 comic.pdf page-%03d.jpg
# Create CBT
./cbt.sh create -i . -o comic.cbt# Optimize JPEGs
for img in *.jpg; do
mogrify -quality 85 -strip "$img"
done
# Create optimized CBT
./cbt.sh create -i . -o optimized-comic.cbt -p "password"chmod +x scripts-bash/cbt.shEnsure required tools are installed:
# Ubuntu/Debian
sudo apt install tar openssl xxd coreutils
# Fedora
sudo dnf install tar openssl vim-common coreutils
# macOS
brew install gnu-tar opensslVerify OpenSSL version:
openssl versionShould be OpenSSL 1.1.1 or higher.
- CBT File Format - Technical details
Tip: Use the bash script for simplicity, or the Go program for cross-platform compatibility.