To crop images, you can use Drupal’s core Image module features. However, let’s consider a case where the output image must strictly be 150x150 pixels, proportions must be preserved, and the image should not be cropped.
We need the ImageCache Actions module. This module adds new actions for images.
To achieve our goal, enable the following modules:
- Imagecache Actions
- Imagecache Canvas Actions
Next, go to the edit page of an existing style or add a new one.
The first action you need to add is Scale, where you specify your desired dimensions.
Then, you need to add the Define canvas action. In this action’s settings, you’ll be asked to choose a color. This color will be used to fill the canvas. Essentially, it will become the background color of your image if the image is not proportional to the desired dimensions.
Specify the final dimensions for your resulting image.
After completing these steps, you’ll receive an image of 150x150 pixels, regardless of the input image size, always preserving proportions, and without cropping the image.