Skip to content

Instantly share code, notes, and snippets.

@vankasteelj
Created November 28, 2016 19:38
Show Gist options
  • Save vankasteelj/f148eb5526580c8dec910fdd16057310 to your computer and use it in GitHub Desktop.
Save vankasteelj/f148eb5526580c8dec910fdd16057310 to your computer and use it in GitHub Desktop.
Freez gif js code
var freezeGif = function (img) {
return new Promise(function (resolve) {
var i = new Image();
i.src = img;
i.onload = function () {
var c = document.createElement('canvas');
var w = c.width = i.width;
var h = c.height = i.height;
c.getContext('2d').drawImage(i, 0, 0, w, h);
resolve(c.toDataURL('image/gif'));
};
});
};
@vankasteelj
Copy link
Author

input url to a gif, output a b64encoded image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment