Dynamic generation of images using pmz?
David Mertz
quilty at spire.com
Thu Aug 10 17:11:55 EDT 2000
Grant Edwards wrote:
> One would think that there would be a way to catch the requests
> for the image files and generate them on the fly the same way
> one catches requests for html files and generates HTML on the
> fly.
I have a silly little program that chooses an author image for some
articles I have written. Articles include the link:
<img src="http://gnosis.cx/cgi/img_dqm.cgi">
The script this points to is:
#!/usr/bin/python
import sys, time, glob, string
pix = glob.glob('../general_images/dqm?.jpg')
which = int(time.time()) % len(pix)
fh = open(pix[which], 'r')
img = fh.read()
header = "Content-type: image/jpeg\n\n"
sys.stdout.write(header)
sys.stdout.write(img)
The underlying images are not dynamically generated.. but they could be,
I'd just need a bytestream in the right format. In a sense what is
actually displayed is dynamically generated... but the dynamism is only
in which diskfile acts as byte source.
More information about the Python-list
mailing list