| MICA |
This CGI program takes a directory of images, creates thumbnails, (if they don't already exist,) displays captions, and provides the user with the option of selecting various sizes of the image to display.
It does so, to a large extent, by looking at the directory structure of the image directory.
The available sizes are controlled by the presence of the directory where the script will store the image (ie., a directory called 1024x768 means the script will provide an option to scale the image to 1024x768)
If you have supplied captions then this script will provide you with a quick word filter.
The script uses imagemagick to do the transformations. This script will prefer to use the pure-perl Image::Magick over imagemagick (through the convert binary)
Assume that $IMAGEDIR is /var/www/images if you need a concrete example. This would mean that the URI used to access this directory would be /images.
/usr/lib/cgi-bin, or wherever your cgi-bin lives.
Create a directory that's readable by the web server at $IMAGEDIR .
Populate this directory with images.
Create a directory that's writeable by the web server at
$IMAGEDIR/thumbnails. MICA won't run unless it finds this thumbnail
directory.
(OPTIONAL) Create a directory that's writeable by the web server at
$IMAGEDIR/WWWxHHH , where WWWxHHH are your favorite dimensions
(i.e. 400x300, 640x480, 800x600, 1024x768)
(OPTIONAL) Create a directory that's readable by the web server at
$IMAGEDIR/captions . For each file.jpg in $IMAGEDIR, you can
create a caption file file.jpg.txt in $IMAGEDIR/captions.
Load http://server-name/cgi-bin/mica.pl?path=/images/ in your
favorite web browser
This script supports captions for the images. The captions are stored in the captions subdirectory, next to the thumbnails directory. Caption files are named as the image file name, but with a txt extension appended to make it easier for the Point-and-Drool types (myself included) to edit them. --(Mike Alborn)
I'd like to point out that this naming convention is almost identical (if not identical) to what feh does for automatic use of caption. Great minds think alike, apparently. ;) --(Mike Carr)
When running MICA you must always make sure that a path argument is passed
to the script. For example,
http://server-name/cgi-bin/mica.pl?path=/images/, assuming that your
image directory is /images/.
When using the script through an SSI, you must make sure that the options passed to the page are forwarded to the script. Mike Alborn uses the following on his website:
<!--#if expr="$QUERY_STRING" -->
<!--#include virtual="/cgi-bin/mica.pl?$QUERY_STRING" -->
<!--#else -->
<!--#include virtual="/cgi-bin/mica.pl?path=/images/" -->
<!--#endif -->
This presupposes, of course, that the image directory is /images/
Mike Carr uses the following code on his HTML::Mason site:
# in /comp/mica
<%perl>
my($path) = $ENV{SCRIPT_NAME};
$path =~ s!/[^/]*$!!;
$ENV{QUERY_STRING} ||= "path=$path";
$ENV{DOCUMENT_NAME} ||= 'index.html';
{
my(@output) = qx[/usr/lib/cgi-bin/mica.pl];
shift @output; # Discard "Content-Type: text/html" output
print join('', @output);
}
</%perl>
Then in each image directory I have a index.html that calls
<& /comp/mica &>. Basically all the component is
doing is artificially adding a path= argument if it doesn't find one already
there. Then, it's disregarding the header portion of MICA's output as we're
already within a web page.
With this layout you would call MICA with argument path=/images, i.e. http://server-name/cgi-bin/mica.pl?path=/images
If you're in doubt as to what user the web server is running under, you can
always make the directory ``sticky'' temporarily and check the ownership of
the files as they are created. You can make a directory sticky by running
chmod +t directory. You can remove a directory's stickyness by
running chmod -t directory.
MICA will automatically overwrite thumbnails if the source file is modified.
A caption file would be named foo.jpeg.txt if the original filename
was foo.jpeg
| MICA |