[mod_python] Image handling handler

Terry MacDonald terry.macdonald at dsl.pipex.com
Wed Sep 22 00:22:08 EDT 2004

I'm probably missing something obvious here, but in the 'handle_thumb'
and 'handle_size' class methods if the image is not cached (or is older)
where is the method sending the image file back to the client? 
It appears only to resize and cache the image not return it.

On Tue, 2004-09-21 at 15:53, Damjan wrote:
> I've hacked this last evening (stayed a bit longer that should've).
> Its an handler that allows modifications of images on the fly, but also
> cache's the results... its a bit hackish but anyway I'll sahre it here
> as a demo of mod_python.
> I enable it with this .htaccess file
> 	AcceptPathInfo On
> 	AddHandler mod_python .png .py .jpg .jpeg
> 	PythonHandler image | .png .jpg .jpeg
> 	PythonHandler mptest | .py
> 	PythonDebug On
> 	PythonOption Cache on
> 	PythonOption CacheDir /tmp/cache
> Ok what exactly the modules does?
> Say you have e picture at the /images/me.jpg URL
> Retrieving /images/me.jpg will let Apache handle the request
> (apache.DECLINED), that way proper caching is allowed etc.
> But getting /images/me.jpg/size?width=100;height=200 will resize the
> image with PIL, store the resized image as
> /tmp/cache/images/me.jpg/size?width=100;height=200 (but only if 
> "Cache on") and send back the resized image to the user.
> Other methods are also possible, there's also /thumb?... similar to /size?
> but retains the aspect-ratio of the original. /datemodified returns
> text/plain content with the data of the last modification of the image
> file.
> Other methods could extract other meta info from images, implement other
> transformations, filters etc...
> - more error checking is needed

More information about the Mod_python mailing list