Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ah, I just realized that this simply prints text out in a gif... it doesn't encode text in the gif and then decode it in the browser into text that javascript could manipulate. Too bad. I wonder if that's possible...


It is possible, as you can now get the raw pixel data of an image by copying it to a canvas and using getImageData.

    <img src="test.gif" id="img">

    <script type=text/javascript>
    var img = document.getElementById("img");
    var canvas = document.createElement("canvas");
    canvas.width = img.width;
    canvas.height = img.height;

    var ctx = canvas.getContext("2d");
    ctx.drawImage(img, 0, 0);

    var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
    </script>
Then you can do whatever you want with the pixel data.


This would be a great step in some kind of rube goldberg inspired website.


Unfortunately not on IE6, and this would require both canvas support and CORS. I think most browsers that support that also support true web sockets.


Encoding data into images is certainly possible, albeit sometimes a PITA.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: