Cut Image Field 1.5
Up to Product page
For additional information about this project, please visit the
project page.
Available downloads
Release Notes
| Tested with | Plone 2.5, Plone 2.1.3, Plone 2.1.2, Plone 2.1.1, Plone 2.1 |
|---|---|
| State | Final release |
| License | GPL |
| Release Manager | Thierry Benita |
| Released | 2006/07/25 |
CutImageField Readme
An Archetype field that cut images.
Description
Archetypes native ImageField allows to scale images. For instance, when setting 451x277 in original_size and 99x143 in sizes['mini'], if you upload an image file sized 800x750 you'll end up with 2 images respectively sized 296x277 nad 93x87.
Sometimes, it may be more important to completely fill the space reserved to the image than to keep the ratio when rescaling.
CutImageField tries to achieve this :
When you ask it to cut images, it will first rescale it and then cut off the pixels in excess. For instance, with the above configuration and uploaded file, you'll end up with 2 images sized 451x277 and 99x193 exactly.
Requirements
- Archetypes 1.3+ - PIL (the Python Image Library)
Usage
- Install as usual in your Products directory.
- Add this line to your custom Archetype to import the field:
from Products.CutImageField import CutImageField - In your schema, add CutImageField like this:
BaseSchema + Schema(( ... CutImageField('myField', original_size=(400,600), sizes={'mini':(40,60)}, cut={'original_size':1, 'mini':1 }, allow_top_cropping={'original_size':0, 'mini':0}, widget=ImageWidget() ), ... ))
Explainations
original_size
Optional : if it is not set, the master image is stored as uploaded. If it is set, the master image is resized/cut before being stored.
sizes
Optional : All sizes we want to get for the image
cut
Optional : Wether we want to cut images or only rescale them. Default value is 0, which means that images will be rescaled in order to fit into the size. If set to 1, the image will be rescaled and cut in order to fill the whole size.
allow_top_cropping
Optional : Wether we allow to cut the top of the image or not. This is usefull in order not to cut heads for example. Default value is 1, which means that we allow to cut both head and botom of the image. If set to 0, only bottom will be cut in order to fill the size.
Credits
CutImageField has been writen based on ImageField, programmed by Danielle Drillon (atReal) and Thierry Benita (atReal)
Thanks to contributors :
Dean Jackson (Lime Factor Pty Ltd) allow_top_cropping added to schema definition
Pierre-Yves Landuré (Dorigo consultants ) support for plone 2.5
Copyright (C) 2005-2006 atReal