Eco-Astro Image Squeezer: Design Notes on Browser Image Processing
An image conversion design using WebAssembly codecs and Web Workers, with explicit limits on quality, memory use, and parallel processing.
1. Define quality requirements first
These are design notes for a browser-based image conversion tool. AVIF and WebP support lossy or lossless compression depending on their settings. A smaller file does not, by itself, mean that the original pixels have been preserved exactly. Use the image format guide to choose output formats and quality requirements.
2. Processing flow
- Check the input's actual format, file size, and resolution, and define processing limits.
- Start conversion only after the WebAssembly codec has loaded and initialized.
- Move intensive work to Web Workers, while limiting both worker count and concurrent jobs.
- Report progress, cancellation, failure, and out-of-memory states to the UI, and release buffers and object URLs when finished.
Workers cannot access the DOM directly. Exchange calculation results through messages and update the screen on the main thread. Assign responsibilities using the Web Workers guide.
3. What to validate
For lossless mode, compare decoded pixels. For lossy mode, assess both visual quality and file size. Separately verify preservation of transparency, color profiles, orientation, and animation.
Compression ratios and processing times vary with image content, settings, and device memory. Evaluate measurements from representative images and low-end devices, rather than promising a fixed reduction or an invariably smooth UI.