A few years ago, my friend Andrew bought a digital camera and wrote a simple photo gallery CGI in Perl. I liked it, and used it for a while. After a while, I made some modifications to change his POST requests (intended to hide photo filenames for security) with GET requests to allow me to easily share photos with friends by URL.
Later on, I decided to spend an evening and completely re-write the software, giving a slightly different user interface, and with a different back-end directory structure. My software isn't any more advanced than Andrew's but it meets my needs better.
Make sure you've got NetPBM, Perl5, CGI.pm, Image::Info, and URI::Escape.
For version 1.1 and up, you need a tree like this:
photos photos/index.cgi (included in archive) photos/previews.cgi (also included) photos/.header.html (ditto) photos/.footer.html (yup, included) photos/Gallery 1/lotsofpics.jpg photos/Gallery 1/.rotation (optional) photos/Gallery 1/.descriptions (optional) photos/Gallery 1/.startatlast (optional) photos/Gallery 2/lotsmorepics.jpg
The names of the photo directory and galleries directories are arbitrary; the software doesn't care what they're called.
Run the previews.cgi
script either through your web
browser by typing its URL or from the command line. It doesn't take
any arguments. It will find the photo galleries magically and create
lots of lowres and thumbnail images using netpbm.
Run previews.cgi
every time you add or remove photos.
It will create new thumbnails or remove orphan files as required to
keep everything in sync.
Edit the .header.html
and .footer.html
files
to your preferences if you want to set up some CSS stuff or set the
background colour of the page or something.
Create the optional file ".rotation" in each gallery directory with the following format:
FILENAME DEGREES_TO_ROTATE
The previews.cgi script will rotate the low-res preview and thumbnail images appropriately.
Create the optional file ".descriptions" in each gallery directory with the following format:
FILENAME Description of the image
NOTE: The image filename should not contain spaces. This is because my scripts make stupid assumptions.
NEW in 1.3! -- If you create a file called
.startatlast
in a gallery directory, that gallery will default
to the LAST page instead of the first. This is mainly for those galleries
that get updated (and viewed by family and friends) frequently. People get
bored of seeing the first page of thumbnails all the time. This feature
(and its implementation) was contributed by Andrew Kilpatrick.
Adjust your web server to make index.cgi the default page for that directory, and you should be all set!
None. Public domain. No GPL virus.