I'm looking for a solution to resize uploaded images while maintaining a desired aspect ratio instead of cropping them.

We can configure some preset Image styles, but it seems we can only :
Resize : Will force an exact set of width/height dimensions which can cause images to be stretched or shrunk disproportionately and loose.
Scale and crop : will maintain the original aspect-ratio of the uploaded image, which can be different from the desired aspect ratio.

So is there a way to force a certain aspect ratio to uploaded images, by adding a white background for instance ?

  • " Resize : which cause images to be stretched or shrunk disproportionately." <- What do you mean? And what are the settings you are using that are causing this undesired effect?
    – Jaypan
    Commented Jun 25, 2022 at 18:01
  • Thanks for the remark, I edited my question to clarify that part. Right now i'm using the "scale and crop" image style which resizes uploaded images to a specific width/height size but in order to keep the aspect ration I want, some uploaded images are cropped so we don't see the entire image. It looses part of its top/bottom or right/left sides. I'm thinking maybe there's a way to set a specific resize dimensions and adding white background to the top/bottom or right/left sides instead of cropping. Commented Jun 25, 2022 at 18:13
  • This is usually done with CSS, not with image manipulation tools.
    – Hudri
    Commented Jun 25, 2022 at 19:16

1 Answer 1


If you want to resize the image while maintaining the desired aspect ratio, this is actually two steps.

  1. Get the image in the appropriate aspect ratio.
  2. Resize the image.

One way to do this is with the Image Widget Crop module. This module allows you to decide which aspect ratios to crop to.

You can use one or multiple aspect ratios, and you can set which aspect ratios are usable for which image fields.

This adds a "cropping" step when you upload an image to set each required crop. There is an Automated Crop module available that may be able to help do this automatically but I haven't used it.

Potential dealbreaker

I do not think it is possible to use Image Widget Crop to set a crop that is larger than the image (to add a white background, for example). Instead, you have to crop the image within the "frame" of the image itself.

Other modules

Another module of note in this area is Image Effects, which will give you more scaling and resizing options, as well as many other useful things like adding watermarks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.