Skip to content

Instantly share code, notes, and snippets.

@nmerouze
Created January 15, 2010 14:51
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 nmerouze/278104 to your computer and use it in GitHub Desktop.
Save nmerouze/278104 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta charset="utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script>
$(function() {
var canvas = document.createElement("canvas");
var img = new Image();
img.onload = function() {
canvas.width = img.width;
canvas.height = img.height;
canvas.getContext('2d').drawImage(img, 0, 0);
var imgBase64 = canvas.toDataURL();
$("body").append($("<img/>").attr("src", imgBase64));
}
img.src = "http://a1.twimg.com/profile_images/227161380/redme.jpg";
});
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment