Bin2Img: Data Visualization with PHP
Update (2010-03-15)
I added some more examples at the bottom of the post.
I've been toying with random numbers recently (more on that another day), and one of the things I wanted to do was find a way to visualize the bits I was generating. The simplest way I could think of is a big bitmap, with each pixel representing a bit and a 0 being white while a 1 is black.
This is an example output of what I came up with, it's a sample run of the first MB of a zip I had laying around. I recommend a click through for the full sized version, it got blurry when I downscaled it.
I chose PHP for the task as I didn't have the time or energy to learn an API in any other language, and I already knew the PHP commands. Here is the source for your perusal. The only tricky bit is accurately reading a byte of raw binary data from file (pro-tip: unpack is essential).
Here are some more data sets:
1Mb from /dev/urandom
dd if=/dev/urandom of=data.bin bs=1kB count=1024
Digits of Pi (as characters)
Data file from here run trough the following to remove newlines and spaces.
cat pi.bin | tr -d ' ' | tr -d '\n' > data.bin
2008 Early Release Toxics Release Inventory data for the state of California
Windows exe from Data.gov