Drupal core provides and image effect called "Scale and Crop". This effect asks for a target width and height. The source image is scaled up or down to fit within those dimensions (respecting the aspect ratio), and the crops out the remaining portion.

In most cases, it doesn't make sense to upscale the image to fit, because upscaling will result in pixelation and loss of quality.

Drupal core has a longstanding issue to have this fixed, but until then, this module exists to provide the functionality.

This image effect provided by this module while check if the source image width and/or height are smaller than the target dimensions. If so, instead of scaling the image up, the target dimensions are scaled down. This means the output image resolution will be smaller than desired, but the aspect ratio of the target resolution is still maintained, and no upscaling of the image occurs.

Source Resolution Target Resolution Result from Scale and Crop (from core) Result from Scale and Crop (this module)
200x200 (1:1) 300x200 (3:2) 300x200 (3:2, scaled up) 200x133 (3:2)
300x300 (1:1) 300x200 (3:2) 300x200 (3:2) 300x200 (3:2)
300x400 (3:4) 400x225 (16:9) 400x225 (16:9, scaled up) 300x169 (16:9)

Project information

Releases