Sponge has contrib controllers, which you can just use inside your own controllers.
Sponge has the ImageHandler class, which is a CherryPy controller that handles dinamically resized and cropped images. It is made through the view’ ``picture`.
Example:
>>> import cherrypy
>>> from sponge.contrib.controllers import ImageHandler
>>>
>>> class MyController:
... exposed = True
... images = ImageHandler()
... def index(self):
... return 'try out going to /images/crop/200x200/logo.jpg'
ImageHandler support caching of generated images, all you need is to set the cache path on its instantiation, and the path must exist.
Example:
>>> import cherrypy
>>> from sponge.contrib.controllers import ImageHandler
>>>
>>> class MyController:
... exposed = True
... images = ImageHandler(cache_at='/srv/images/content')
... def index(self):
... return 'try out going to /images/crop/200x200/logo.jpg'
Sponge’s ImageHandler will lookup in the given directory if the image exists, then it serves statically directly from disk. If the file is not cached, ImageHandler will generate the image, save on disk and serve.