CGI::Application::PhotoGallery - module to provide a simple photo gallery
use CGI::Application::PhotoGallery;
my $webapp = CGI::Application::PhotoGallery->new(
PARAMS => {
photos_dir => '/path/to/photos'
}
);
$webapp->run();
CGI::Application::PhotoGallery is a the CGI::Application manpage module allowing people to create their own simple photo gallery. There is no need to generate your own thumbnails since they are created on the fly (using either the GD or Image::Magick modules).
To use this module you need to create an instance script. It should look like:
#!/usr/bin/perl
use CGI::Application::PhotoGallery;
my $webapp = CGI::Application::PhotoGallery->new(
PARAMS => {
photos_dir => '/path/to/photos'
}
);
$webapp->run();
You'll need to replace the "/path/to/photos" with the real path to your photos (see the photos_dir options below).
Put this somewhere where CGIs can run and name it something like
index.cgi.
This gets you the default behavior and look. To get something more to your specifications you can use the options described below.
perl Makefile.PL
make
make test
make install
the CGI::Application manpage modules accept options using the PARAMS arguement to
new(). To give options for this module you change the new()
call in the instance script shown above:
my $webapp = CGI::Application::PhotoGallery->new(
PARAMS => {
photos_dir => '/path/to/photos',
title => 'My Photos'
}
);
The title option tells PhotoGallery to use 'My Photos' as the title
rather than the default value. See below for more information
about title and other options.
This parameter is used to specify where all of your photos are located.
Previous limitations of this directory have been lifted.
Your photos directory can have any number of images and sub-directories of images. This is applied recursively so a gallery can have any number of sub-galleries.
This parameter uses $0 by default, you can change it (or set it to the
empty string) if you neeed to. It is needed for creating self referencial
links.
By default every page will start with the title "My Photo Gallery". You can specify your own using the title parameter.
By default PhotoGallery displays thumbnail images that are 100 x 100 on the index page. You can change this by specifying a number (in pixels) for this option.
Before viewing the entire contents of a gallery, you are shown a few
preview image. The default number of thumbnails is 4. You
can change it by specifying your own value in the instance script.
You can specifify which graphics library you wish to use to size your
thumbnails. Included in this package are Magick (Image::Magick) and
the default: GD. You can also create your own if you wish.
This application uses the HTML::Template manpage to generate its HTML pages. If
you would like to customize the HTML you can copy the default form
template and edit it to suite your needs. The default form template
is called 'photos_index.tmpl' and you can get it from the distribution
or from wherever this module ended up in your @INC. Pass in the
path to your custom template as the value of this parameter.
See the HTML::Template manpage for more information about the template syntax.
The default template for an individual photo is called
'photos_single.tmpl' and you can get it from the distribution or from
wherever this module ended up in your @INC. Pass in the path to
your custom template as the value of this parameter.
See the HTML::Template manpage for more information about the template syntax.
You can include captions for your photos by creating a tab-separated
database named captions.txt in your photos_dir. The filename
should be specified relative of your photos_dir.
1.jpg This is a caption.
Test Gallery/1.jpg This is another caption.
This method sets the default options and makes sure all required parameteres are set.
This method finds all of the image/* files in the specified
directory.
This method will create (if needed) and return a new the MIME::Types manpage object.
This method will create (if needed) and return the graphics adaptor specified by the user (default is GD).
This method will create (if needed) and return a the Cache::FileCache manpage object,
Reads in the contents of your photos_dir and generates an index of photos.
Generates a thumbnail for the requested image using the selected graphics library.
Sends the contents of the image to the browser.
Fills and sends the template for viewing an individual image.
Brian Cassidy <bricas@cpan.org>
Copyright 2005 by Brian Cassidy
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.