Optimize EPUB images for e-ink displays using MozJPEG WASM.
- 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
// 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 tablenpm install
npm run devnpm run buildOutput goes to dist/ folder.
- Push to GitHub/GitLab
- Go to Cloudflare Pages
- Create new project → Connect repository
- Build settings:
- Build command:
npm run build - Build output directory:
dist
- Build command:
npm run build
npx wrangler pages deploy distBuild locally, then drag dist/ folder to Cloudflare Pages dashboard.
epub-optimizer-pro/
├── index.html
├── package.json
├── vite.config.js
└── src/
├── main.js
├── mozjpeg-encoder.js # wasm-mozjpeg wrapper
└── style.css
Uses wasm-mozjpeg:
- 34 KiB gzipped
- Grayscale, RGB, YCbCr output support
- Full MozJPEG control
| 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° |
| 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 |
MIT