3
Creating CBT Files
riomoo edited this page 2026-02-04 01:59:57 -05:00
Table of Contents
- Creating CBT Files
- Method 1: Using the cbt.sh Bash Script (Recommended)
- Prerequisites
- Installation
- Creating Unencrypted CBT
- Creating Encrypted CBT
- Extracting CBT Files
- Script Options
- Method 2: Using the cbt.go Program
- Method 3: Manual Creation with TAR
- Directory Structure Best Practices
- Automated Workflow Scripts
- Testing Your CBT Files
- Integration with Comic Creation Tools
- Troubleshooting
- Related Pages
Creating CBT Files
This guide covers multiple methods for creating CBT (Comic Book TAR) files with or without encryption.
Method 1: Using the cbt.sh Bash Script (Recommended)
Prerequisites
- Bash shell (Linux/Mac/WSL)
- OpenSSL
- Standard Unix tools (tar, sha256sum, xxd)
Installation
The cbt.sh script is included in the scripts-bash/comic-scripts/ directory:
chmod +x scripts-bash/comic-scripts/cbt.sh
Creating Unencrypted CBT
./scripts-bash/comic-scripts/cbt.sh create -i /path/to/comic/images -o mycomic.cbt
Example:
./scripts-bash/comic-scripts/cbt.sh create -i ./my-comic-pages-folder -o amazing-comic.cbt
This will:
- Create a TAR archive from all files in the directory
- Save it as
amazing-comic.cbt - Display list of files added
Creating Encrypted CBT
./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
Extracting CBT Files
Unencrypted:
./scripts-bash/comic-scripts/cbt.sh extract -i mycomic.cbt -o ./extracted
Encrypted:
./scripts-bash/comic-scripts/cbt.sh extract -i secret-comic.cbt -o ./extracted -p "your-password"
Script Options
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)
Method 2: Using the cbt.go Program
Prerequisites
- Go 1.25.2 or higher
Building the Tool
go build -o cbt scripts-go/cbt.go
Creating Unencrypted CBT
./cbt -input /path/to/images -output mycomic.cbt
Example:
./cbt -input ./comic-pages-folder -output "My Amazing Comic.cbt"
Creating Encrypted 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"
Program Options
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)
Method 3: Manual Creation with TAR
Creating Unencrypted CBT
cd /path/to/comic/images
tar -cf ../mycomic.cbt *
Creating Encrypted CBT Manually
-
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
Directory Structure Best Practices
Recommended Structure
comic-pages/
├── 001.jpg
├── 002.jpg
├── 003.jpg
├── ...
└── ComicInfo.xml
File Naming
Use zero-padded numbers for proper sorting:
- ✅
001.jpg,002.jpg,003.jpg - ❌
1.jpg,2.jpg,3.jpg
Including ComicInfo.xml
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>
Automated Workflow Scripts
Batch Creation Script
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.sh
Using with GPG-Encrypted Passwords
Store 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"
Testing Your CBT Files
Test with Gopherbook
- Upload to Gopherbook via web UI
- Or place in watch folder:
cp mycomic.cbt ./watch/[username]/
Test Encryption
# Should fail if encrypted
tar -tf mycomic.cbt
# Should succeed if unencrypted
tar -tf mycomic.cbt
Test Extraction
./cbt.sh extract -i mycomic.cbt -o test-extract -p "password"
ls test-extract/
Integration with Comic Creation Tools
ImageMagick Conversion
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 Images Before Packing
# 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"
Troubleshooting
"Permission Denied" Error
chmod +x scripts-bash/cbt.sh
"Command Not Found" Errors
Ensure 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 openssl
Encryption Issues
Verify OpenSSL version:
openssl version
Should be OpenSSL 1.1.1 or higher.
Related Pages
- CBT File Format - Technical details
Tip: Use the bash script for simplicity, or the Go program for cross-platform compatibility.