Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: reading all images in a directory

by injunjoel (Priest)
on Jun 24, 2005 at 17:05 UTC ( #469769=note: print w/replies, xml ) Need Help??

in reply to reading all images in a directory

I would use HTML::Template to set up a table for image display, 5 per row, as many rows as needed. Something like
<table border="0" cellpadding="4" cellspacing="1" bgcolor="#000000"> <TMPL_LOOP name="rowloop"> <tr bgcolor="#ffffff"> <td valign="top"> <TMPL_IF name="img1src"> <img src="/cgi-bin/<TMPL_VAR name="img1src">"> </TMPL_IF> </td> <td valign="top"> <TMPL_IF name="img2src"> <img src="/cgi-bin/<TMPL_VAR name="img2src">"> </TMPL_IF> </td> <td valign="top"> <TMPL_IF name="img3src"> <img src="/cgi-bin/<TMPL_VAR name="img3src">"> </TMPL_IF> </td> <td valign="top"> <TMPL_IF name="img4src"> <img src="/cgi-bin/<TMPL_VAR name="img4src">"> </TMPL_IF> </td> <td valign="top"> <TMPL_IF name="img5src"> <img src="/cgi-bin/<TMPL_VAR name="img5src">"> </TMPL_IF> </td> </tr> </TMPL_LOOP> </table>
As for resizing you could create a script that reads in a single image and outputs the resized version, like a thumbnail, You will need GD or Image::Magic for this. Then with your gallery script fill the HTML::Template with image tags that call the thumbnail script i.e. <image src="/cgi-bin/" /> That way you don't have to slurp the entire directory of images in, just their names.

Update Fixed Template formatting for readability


"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://469769]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2019-07-21 19:37 GMT
Find Nodes?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?

    Results (9 votes). Check out past polls.