WWW::MeGa is a web based media gallery. It should be run from FastCGI (see examples/gallery.fcgi) or mod_perl (not yet tested) because it uses some runtime caching.
Every file will be delievered by the CGI itself. So you don't have to care about setting up picture/thumb dirs.