3 ms·
FWIW, you can do this with a few lines of JS in the browser using canvas.drawImage() from an img element followed by canvas.toBlob().
by DaleCurtis 9mo ago
FWIW, you can do this with a few lines of JS in the browser using canvas.drawImage() from an img element followed by canvas.toBlob().
- fouc 9mo agoThat would require a browser that supports WebP
- theandrewbailey 9mo ago...which is, like, all of them released over the past 5 years: https://caniuse.com/webp https://caniuse.com/webp
- valadaptive 9mo agoFirefox now adds random noise to all canvas readback operations (getImageData, toDataURL, and toBlob).
- DaleCurtis 9mo agoAh, I didn't realize that always happened. I thought it was only if you did something that might have OS specific rendering characteristics (text-draws, etc). Maybe having an ImageEncoder API might be worthwhile after all then https://github.com/w3c/webcodecs/issues/204 https://github.com/w3c/webcodecs/issues/204.