A simple ASP.NET photo album
In June, Dmitry posted a very simple photo album on his blog. I immediately liked it because it's both easy to set-up (just drop the ashx file into your web site's photo directory) and to manage (no need to upload images one by one using a clumsy web upload field, just upload new photos using ftp or the file system). It's also nice to browse. Sure, there are no fancy ratings or comments features, you can't add titles or descriptions, but frankly, I didn't need all these features.
Still, I wanted to change a few things so I went ahead and added the following to Dmitry's handler:
- XHTML output
- CSS styling
- EXIF meta-data reading and displaying
- Sorting by date shot
- Stacked photos folder icons (uses default.jpg if it exists)
- Folder names respect casing and special characters
- In-handler pseudo-config (just modify the handler's configuration block with any text editor)
- Thumbnail caching on disk or in memory
The thumbnail caching on disk is an essential improvement because if you have a large number of heavy pictures, memory won't be the right place to cache. If the handler is configured to save on disk (which is the default), the thumbnails are stored in the application's temporary folder, the very same place where pages are compiled. This means that you don't need to set writing permissions, but it also means that you need to run in high or full trust. If you can't do that, you should configure the handler to cache in memory or not at all.
The handler is under a shared source licence, which means that you can do pretty much what you want with it. It uses the Metadata public domain library by Drew Noakes and adapted for .NET by Renaud Ferret to extract the EXIF information from the jpeg files. This library can be downloaded from http://renaud91.free.fr/MetaDataExtractor. Please use the dll from the workspace below, though, as I've made a small correction. I've also sent the correction to Renaud, but he may not publish a new version immediately...
Download the code for the handler here:
Special thanks should go to Dmitry Robsman and David Ebbo.
UPDATE: the handler is now hosted on Codeplex.