I'm trying to scale image and to crop it to certain size from center.
Basically if I want image to be 240x160 (scale 1.5:1) and I have Image that is 900x800 (scale 1.125:1) and use these settings:
filters:
- { name: geometry/scaledownonly, params: [240, 160] }
- { name: geometry/crop, params: [240, 160, 0, 0] }
But I cant get desired results.
In your site image_variations
block of your site settings yaml, try adding the following:
image_variation_name:
reference: ~
filters:
- { name: geometry/scaledownonly, params: [240, 160] }
- { name: thumbnail, params: { size: [240, 160], mode: outbound } }
The above block will do two things. First, your image will scaled down to the appropriate size (you already had that bit). Next, the thumbnail filter will crop the image from the middle out (center crop) to the desired dimentions.