CroppingImageField
An Archetypes based field to allow you to specify exact dimensions for resized images.
Current release
No stable release available yet.
Project Description
We needed a field that ensured all images on a site were of the same dimensions.
Just add this field to your archetype and you can specify dimensions, similar to that of the ImageField, but this field will scale images and crop the overhang, hence the name!
Requirements
PIL
Usage
Install as usual in your Products folder, or use the egg available on cheeseshop
Add to your archetype:
from croppingimage.field import CropppingImageField
Then add it to your schema:
CroppingImageField('image',
long_edge_size = 600,
short_edge_size = 450,
sizes= {'large' : (600, 450),
'medium' : (300, 225),
'thumb' : (125, 94),
},
widget=ImageWidget())
When you upload a landscape image, it will be resized to 600x450. A portrait image will be resized to 450x600. The other image sizes are resized accordingly.
If you want portrait images to be cropped to landscape format or landscape images to be cropped to portrait ones use the force_format='landscape' property.
See the documentation section for some croppingimagefield usage-examples.
A CroppingImageField example is provided in the croppingimage.py
