< Day Day Up > |
Hack 51. Browse the World Wide Photo AlbumTake a random stroll through the world's photo album using some clever Google Image searches (and, optionally, a smidge of programming know-how). The proliferation of digital cameras and growing popularity of camera phones are turning the Web into a worldwide photo album. It's not only the holiday snaps of your Aunt Minnie or minutiae of your moblogging friend's day that are available to you. You can actually take a stroll through the publicly accessible albums of perfect strangers if you know where to look. Happily, Google has copies, and a couple of hacks know just where to look. 3.5.1. Random Personal Picture FinderDigital photo files have relatively standard filenames (e.g., DSC01018.JPG) by default and are usually uploaded to the Web without being renamed. The Random Personal Picture Finder (http://www.diddly.com/random) sports a clever little snippet of JavaScript code that simply generates one of these filenames at random and queries Google Images for it. The result, shown in Figure 3-3, is something like looking through the world's photo album: people eating, working, posing, and snapping photos of their cats, furniture, or toes. And since it's a normal Google Images search, you can click on any photo to see the story behind it, and the other photos nearby. Neat, huh? Figure 3-3. The Random Personal Picture Finder
The code behind the scenes, as I mentioned, is really very simple—a swatch of JavaScript (view the source of http://www.diddly.com/random/random.html in your browser to see the JavaScript bits for yourself) and list of camera types and their respective filename structures (http://www.diddly.com/random/about.html). You're simply redirected to Google Images with generated search query in tow. A smidge of Python illustrates just how simple it is to generate a link to some random collection of photos shot with a Canon digital camera: $ python Python 2.3 (#1, Sep 13 2003, 00:49:11) [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from random import randint >>> linkform = 'http://images.google.com/images?q=IMG_%s.jpg' >>> print linkform % str(randint(1, 9999)).zfill(4) http://images.google.com/images?q=IMG_7931.jpg You can easily use this as the basis of a CGI script that acts in the same manner as the Random Personal Picture Finder does. 3.5.2. WebCollageAnd if you think the Random Personal Picture Finder is fun, you'll love Jamie Zawinski's WebCollage (http://www.jwz.org/webcollage/), a Perl script that finds random pages, strips them of their images, and puts these images together to create a collage. The collage is remixed and added to once a minute, your browser reloading a fresh version every so often (or just hit Shift-Reload on your browser yourself to speed up the process). Figure 3-4 shows a WebCollage snapshot in time. Figure 3-4. A typical WebCollage snapshot of random pictures gleaned through Internet searchClick on any one element and you'll be taken to the page that the image is from. You can grab the Perl source (http://www.jwz.org/webcollage/webcollage) and generate a page similar to Jamie's like so: $ webcollage -size '800x600' -imagemap
~/public_html/collage where 800x600 is the size and ~/public_html/collage is the path to and file you'd like to save the image map as. WebCollage is also included in Zawinski's XScreenSaver (http://www.jwz.org/xscreensaver), a screensaver system for computers running the X Windows System (usually some brand of Unix).
—Aaron Swartz |
< Day Day Up > |