Skip to content

Instantly share code, notes, and snippets.

@spite
Created March 1, 2018 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spite/12e458ea49be527e0691ed32bdc6d2b9 to your computer and use it in GitHub Desktop.
Save spite/12e458ea49be527e0691ed32bdc6d2b9 to your computer and use it in GitHub Desktop.
Capture canvas and download as WebP with quality
canvas.toBlob( e => {
const url = URL.createObjectURL(e);
const link = document.createElement('a');
link.setAttribute('href',url);
link.setAttribute('download','image.webp');
link.click();
console.log(url);},
'image/webp',
0.5 // quality
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment