|
Image::Random - select random image from a directory |
Image::Random - select random image from a directory
In HTML::Mason, I use this like so:
<p class=pullquote> <img src=<% Image::Random->from_dir('/home/terry/public_html/livingcosmos.org/img/frontpage', '/img/frontpage') %> > </p>
This module has one function, from_dir, which selects an image at
random from a specified directory. It filters the file list using the regexp
/[.](gif|jpeg|jpg|png)$/
which is stored in the scalar $Image::Random::image_filter
The random number seed is the function Image::Random::srander.
At present, it does not recursively search directories --- it simply looks in the present directory.
The function requires one argument, which directory to look for image files in. The selected filename is returned sans directory. A second optional argument, if supplied, is prepended to the selected filename. This is very useful in web situations where the Unix path may differ from the webserver path.
None by default.
Terrence Brannon, <terry@hcoop.net>
Copyright (C) 2004 by Terrence Brannon
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.
|
Image::Random - select random image from a directory |