Using PIL
Using the Python Imaging Library to scale images on-the-fly
The Python Imaging Library, PIL, is capable of (among other things) re-scaling images on-the-fly. The Archetypes ImageField can take a sizes attribute to define the possible sizes an image can be scaled to. ATContentTypes defines the following sizes in 'ATContentTypes/content/image.py':
sizes= {'large' : (768, 768),
'preview' : (400, 400),
'mini' : (200, 200),
'thumb' : (128, 128),
'tile' : (64, 64),
'icon' : (32, 32),
'listing' : (16, 16),
}
These can then be referred to by name. For example, to render the thumbnails in the richdocument_view_preview template, we do:
<img tal:replace="structure python:image.tag(scale='thumb')"/>
where image is an ImageAttachment object.