Simple Zope Photo Album

Karsten W. Rohrbach karsten at
Sat Jan 4 10:48:28 CET 2003

mlorfeld <tutal at> wrote:
> image, python script, wiki).  So basically I'm looking for a Q&D
> pytyhon/dtml/html code snippit that will dynamically create a photo
> album.  Any suggestions?

- Install ImageMagick locally
- Create a work directory hierarchy
    $ mkdir work
    $ mkdir work/img
    $ mkdir work/thumb
- Put all images into ./work
- run ImageMagick over them to create jpg and thumbnails
  (presented script is from my work dir wich contains only PNG images,
  I publish JPEG pictures)
    for i in *.png
	FNAME=`echo -n ${i} | sed s/.png$//`
	echo ${FNAME}
	convert ${i} ./img/${FNAME}.jpeg
	convert ${i} -geometry 96x96 ./thumb/${FNAME}.jpeg
- Now FTP to your Zope server and upload the two directories relative to
  you gallery container object (Folder) - I use NcFTP for that
  (recursive put)
- on the Zope side you can install a simple DTML method which creates a 5
  by somewhat table of thumbnails. [1]
    <dtml-let numpics="_.len(img.objectIds(['Image']))">
    <table class="gallery" align="center">
    <dtml-in expr="img.objectValues(['Image'])" sort="id">
	<dtml-let seq=sequence-number>
	<dtml-if "(seq - 1) % 5 == 0">
	<td class="gallery"><a href="pics/<dtml-var "getId()">" 
	    target="_blank"><img src="thumbs/<dtml-var "getId()">" 
            border="0" alt="[]"></a></td>
	<dtml-if "seq % 5 == 0">
    <p align="right">
    (<dtml-var numpics > Photos)

The beneift is, that you won't need any additional Zope products. The
drawback is the hackish generation of URLs (which produces relative URLs
that might lead to acqusition problems, depending on where you put the
DTML method).



More information about the Python-list mailing list