Created
June 24, 2011 00:19
-
-
Save cfleschhut/1043953 to your computer and use it in GitHub Desktop.
Quick base64 image encoding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adjust image selector in fn-call | |
// and run this from the (firebug, etc.) console | |
(function(imgObj) { | |
var imgsrc = imgObj.src; | |
var canvas = document.createElement("canvas"), | |
ctx = canvas.getContext("2d"); | |
canvas.width = imgObj.width; | |
canvas.height = imgObj.height; | |
var newimg = new Image(); | |
newimg.src = imgsrc; | |
newimg.addEventListener("load", function() { | |
ctx.drawImage(newimg, 0, 0); | |
window.location = canvas.toDataURL(); | |
}, false); | |
})(document.images[0]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment