Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: reading all images in a directory

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


in reply to reading all images in a directory

Greetings,
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/thumbnail.pl?img=<TMPL_VAR name="img1src">"> </TMPL_IF> </td> <td valign="top"> <TMPL_IF name="img2src"> <img src="/cgi-bin/thumbnail.pl?img=<TMPL_VAR name="img2src">"> </TMPL_IF> </td> <td valign="top"> <TMPL_IF name="img3src"> <img src="/cgi-bin/thumbnail.pl?img=<TMPL_VAR name="img3src">"> </TMPL_IF> </td> <td valign="top"> <TMPL_IF name="img4src"> <img src="/cgi-bin/thumbnail.pl?img=<TMPL_VAR name="img4src">"> </TMPL_IF> </td> <td valign="top"> <TMPL_IF name="img5src"> <img src="/cgi-bin/thumbnail.pl?img=<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/thumbnail.pl?img=foobar.jpg" /> That way you don't have to slurp the entire directory of images in, just their names.

Update Fixed Template formatting for readability

-InjunJoel

"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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-26 02:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found