Skip to content

zgredex/epub-optimizer-pro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EPUB Optimizer Pro

Optimize EPUB images for e-ink displays using MozJPEG WASM.

Features

  • True Grayscale (Y-only) - No Cb/Cr chroma channels
  • Baseline JPEG - Maximum compatibility
  • Optimized Huffman Tables - Better compression
  • Trellis Quantization - Higher quality at same size
  • 100% Client-side - No server uploads

MozJPEG Encoder Settings

// Using wasm-mozjpeg from 3bl3gamer
mozJpeg.cinfo_set_out_color_space(JCS_GRAYSCALE);  // Y-only, NO chroma
mozJpeg.cinfo_set_optimize_coding(true);            // Optimized Huffman
mozJpeg.cinfo_disable_progression();                // Baseline JPEG
mozJpeg.cinfo_set_trellis(10, true, true, true);    // Trellis quantization
mozJpeg.cinfo_set_quant_table(3);                   // Best quality table

Local Development

npm install
npm run dev

Build for Production

npm run build

Output goes to dist/ folder.

Deploy to Cloudflare Pages

Option 1: Connect Git Repository

  1. Push to GitHub/GitLab
  2. Go to Cloudflare Pages
  3. Create new project → Connect repository
  4. Build settings:
    • Build command: npm run build
    • Build output directory: dist

Option 2: Wrangler CLI

npm run build
npx wrangler pages deploy dist

Option 3: Direct Upload

Build locally, then drag dist/ folder to Cloudflare Pages dashboard.

Project Structure

epub-optimizer-pro/
├── index.html
├── package.json
├── vite.config.js
└── src/
    ├── main.js
    ├── mozjpeg-encoder.js   # wasm-mozjpeg wrapper
    └── style.css

MozJPEG Package

Uses wasm-mozjpeg:

  • 34 KiB gzipped
  • Grayscale, RGB, YCbCr output support
  • Full MozJPEG control

Image Processing Modes

Mode Badge Description
Normal Scale to 480×800, grayscale
H-Split H Rotate + split wide images
V-Split V Split tall images vertically
Rotate R Rotate landscape 90°

Why This Setup?

Feature Canvas toBlob MozJPEG WASM
Colorspace RGB (3 ch) Grayscale (1 ch)
Huffman Standard Optimized
Trellis
Progressive Disabled (baseline)
File size Baseline ~25-35% smaller

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors