DEV Community

Discussion on: Client-Side Image Compression on the Web

Collapse
 
darkain profile image
Vincent Milum Jr

Something to consider is that there are countless different resizing algorithms out there. By relying on the browser's canvas resize, you lose this level of control. Lanczos is what I decided on for quality when I built an image hosting web site. It would be possible to reimplement this using JavaScript, but it would be a considerably sized library for clients to download, and probably perform very poorly using Canvas manipulation.

Collapse
 
ramko9999 profile image
Ramki Pitchala

That is great to know! I haven't heard of Lanczos, I will definitely look into it.

Collapse
 
k776 profile image
Kieran Pilkington • Edited

I guess this would be a good use case for a lazily loaded WebAssembly module then. Make (or use an existing) Lanczos compression WASM module, load it on the page when the user begins selecting the file, when file is selected, pass in the image binary to the WASM function, and use the compressed result.