In Plone 4, there is a completely new way to generate scales that can help solve this problem. Using this approach, you can say that it scales the image βdownβ instead of βupβ, which means that it scales the short side of the image to the specified size, not the long side (so that the image ends with cropping, but always fills the specified area) .
With this approach, you do not need to determine the scale in your circuit, but you can simply include something like the following in the template. Scale will be generated on demand.
<img tal:define="scale context/@@images" tal:replace="structure python: scale.scale('image', width=160, height=160, direction='down').tag()" />
See the plone.app.imaging page for more on this scaling approach.
source share