Skip to content

Instantly share code, notes, and snippets.

@mattn
Created May 12, 2010 00:06
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 mattn/398050 to your computer and use it in GitHub Desktop.
Save mattn/398050 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>DCT</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.getJSON("http://to-data-uri.appspot.com/?callback=?", {url:"http://a1.twimg.com/profile_images/801507702/img_bigger.jpg"}, function(data) {
$("<img/>").load(function() {
var ctx = $("<canvas/>").attr({
width: this.width,
height: this.height
})[0].getContext("2d");
ctx.drawImage(this, 0, 0);
var data = ctx.getImageData(0, 0, this.width, this.height);
alert(data.data.length == data.width * data.height * 4);
}).attr('src', data.result)
});
});
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment