In an attempt to improve Karussell's answer, this version should be a cross-browser, freezes all images, including those that have the wrong file (for example, automatic image loading pages), and does not contradict the function of the original image, allowing the right-click of the original, as if it moved.
I would make him detect animations, but this is much more intense than just freezing them independently.
function createElement(type, callback) { var element = document.createElement(type); callback(element); return element; } function freezeGif(img) { var width = img.width, height = img.height, canvas = createElement('canvas', function(clone) { clone.width = width; clone.height = height; }), attr, i = 0; var freeze = function() { canvas.getContext('2d').drawImage(img, 0, 0, width, height); for (i = 0; i < img.attributes.length; i++) { attr = img.attributes[i]; if (attr.name !== '"') {
Makaze Jul 11 '14 at 21:47 2014-07-11 21:47
source share