I’m very proud of myself tonight. You see, I’m a programmer at heart. Yet it has been a long time since I just programmed something for fun. Not a contest, not a class. Just out of pure usefulness and interest. Here’s the story.
I setup a webcam to watch my room for the day, and some software that uploads the webcam’s image to my server via FTP, 6 times per minute. The software is Active Webcam, and I just used the free evaluation version. Over the course of the day, it generated 6,522 images – way too many to view at once. So I decided to script something to make looking at the images more interesting.
The first obvious problem is that most of the images look exactly the same. Nothing happened during the day, so the images have no easily visible distinction. Yet they are not the same in terms of bits: the brightness has slight variations, the JPEG compression differed, etc. So doing an md5 comparison (which will be the same for files which are the same) doesn’t cut it. I need to actually look at the image data.
Fortunately, PHP has a great built-in image library known as gd. You have to have PHP compiled with it, but my host does, so I suspect most others do, too. After much trial and error, I managed to do the following: Continue reading