npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@eivu/ts-comic-compress

v1.0.0

Published

Compresses comic books (CBR or CBZ extension) by using webp and decreasing the target height

Readme

TypeScript Comic Compress

A TypeScript/Node.js command-line tool that compresses comic books (CBR or CBZ extension) by converting images to WebP format and optionally resizing them. Also supports PDF files.

This is a TypeScript port of the Rust-based compress_comics project.

Features

  • ✅ Supports CBR and CBZ comic archive formats
  • ✅ Supports PDF files (converts to CBZ)
  • ✅ Converts images to WebP format for better compression
  • ✅ Optional image resizing (maintains aspect ratio)
  • ✅ Recursive directory processing
  • ✅ Parallel processing support
  • ✅ Progress reporting with detailed statistics
  • ✅ Skip existing files option
  • ✅ Rename original files option

Installation

npm install
npm run build

Or install globally:

npm install -g .

Usage

npm start -- [options]

Or if installed globally:

comic-compress [options]

Command Line Options

  -i, --input <FILE/FOLDER>     The file or folder to convert (required)
  -o, --output <FOLDER>         Base path of the output (will be in output/subfolders if the recursive option is enabled), default: converted_comics
  -r, --recursive               Recursively traverse the input folder (include all subfolders)
  -s, --skip                    Skip processing file if it already exists in the output folder
  -q, --quality <number>        Quality to use for the webp files (0-100), default: 75
  -p, --parallel                Run in parallel, utilizing all computing resources
  --rename-original             Rename original files to *_original instead of copying
  --height <number>             Target height for images (maintains aspect ratio). If not specified, images are not resized
  -m, --move-original           Move successfully compressed objects to a subfolder named done
  -h, --help                    Display help for command

Examples

Process a single file:

npm start -- -i comic.cbz -o output

Process a folder recursively:

npm start -- -i ./comics -o ./compressed -r

Process with custom quality and resize:

npm start -- -i comic.cbz -o output -q 80 --height 1200

Process in parallel and skip existing files:

npm start -- -i ./comics -o ./compressed -r -p -s

Rename original files (creates backup):

npm start -- -i comic.cbz -o output --rename-original

Output

The tool provides detailed progress information and a summary report:

📊 Processing Summary:
──────────────────────────────────────────────────
📖 Comic1.cbz: 45.2% savings (23 images processed, 2 skipped) (15.2 MB saved)
📖 Comic2.cbz: 38.7% savings (18 images processed, 1 skipped) (12.8 MB saved)

🎯 Overall Results:
   Total files processed: 2
   Total images processed: 41
   Total images skipped: 3
   Overall size reduction: 42.1%
   Original size: 125.43 MB
   Compressed size: 72.65 MB
   Space saved: 52.78 MB

Technical Details

  • Language: TypeScript/Node.js
  • Image Processing: Sharp library (high-quality Lanczos3 resampling)
  • Compression: WebP lossy compression with configurable quality
  • Archive Format: ZIP-based CBZ files (universal comic reader compatibility)
  • CBR Support: Processes both ZIP-based and RAR-based CBR files (automatically detects format)
  • PDF Support: Extracts embedded images from PDF files and converts to CBZ format
  • RAR Support: Full support for RAR archives using node-unrar-js
  • Threading: Parallel file processing support

Supported File Formats

Input Formats

  • CBZ: ZIP archives containing images
  • CBR: RAR or ZIP archives containing images (automatically detects and handles both formats)
  • PDF: PDF files with embedded images (converted to CBZ)

Image Formats (within archives)

  • JPEG/JPG: Converted to WebP
  • PNG: Converted to WebP
  • WebP: Kept as-is (skipped)

Limitations

  • Output uses ZIP compression for CBR files (converts RAR-based CBR files to CBZ format)
  • WebP format may not be supported by very old comic readers
  • PDF processing only extracts embedded raster images (vector graphics are not rasterized)
  • RAR volume archives (multi-part RAR files) are not supported

Building

npm run build

This will compile TypeScript to JavaScript in the dist/ directory.

Testing

This project includes a comprehensive test suite using Jest.

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage report
npm run test:coverage

See TESTING.md for detailed testing documentation.

Development

# Run in development mode
npm run dev -- [options]

# Watch mode (requires ts-node-dev or similar)
npm install -D ts-node-dev
ts-node-dev --respawn src/index.ts [options]

Dependencies

  • commander: Command-line argument parsing
  • sharp: High-performance image processing and WebP conversion
  • yauzl: ZIP file reading
  • yazl: ZIP file writing
  • node-unrar-js: RAR archive extraction
  • pdfjs-dist: PDF file processing
  • fs-extra: Enhanced file system operations
  • chalk: Terminal colors

License

MIT

Credits

Original Rust implementation: erikvullings/compress_comics