1
votes

Specifically, the default scaling profile uses the 'keep' scale property; see https://github.com/plone/plone.scale/blob/master/plone/scale/scale.py#L62

This scales without cropping.

It's useful to set the plone.allow_sizes registry key to allow custom tags, eg.

http://192.168.15.156:8080/Plone/media/4qrcrmn.jpg/@@images/image/tile

However, this doesn't respect the requested size; it simple proportionally scales the image.

I've been digging through the source of https://github.com/plone/plone.app.imaging/blob/master/src/plone/app/imaging/scaling.py#L179 trying to understand what's happening, but there doesn't appear to be a way to override the direction property here?

Is there some other way of doing this, or is the only option to create custom views for the Image type?

1

1 Answers

3
votes

I guess this is not possible simply through the url.

You could either generate a tag inside a view (like you said) and crop it to the exact size you need: https://github.com/plone/plone.app.imaging/blob/master/README.rst#new-style-image-scales

Or you could use plone.app.imagecropping. With this package you can edit each uploaded image and crop it to the exact size you defined in the available scales. You can even specify which area of the image should be used for the crop. After this is done the url

http://192.168.15.156:8080/Plone/media/4qrcrmn.jpg/@@images/image/tile

Will give you the exact cropped image you have specified for that scale.