I want to define an image style in Drupal 7 which changes the width of images to 200px and the max of the height to 150px. That means if a picture is 400x300 the image style should change it to 200x150 but if an image is 250x120 the image style should change only the width of it to 200px and the height shouldn't be changed.

How can I do it ? It seems it is not possible by 'admin/config/media/image-styles'.

2 Answers 2


Your approach will differ depending on whether you want your images to be cropped or scaled to fit the appropriate size, but generally speaking, in most of the image style effects where you can specify a width and height, if you just enter one value, the value for the other will be automatically calculated ("Resize" is an exception, but since that can result in distorted images, you almost always want to use "Scale" or "Scale and crop" instead.) For example, if you add a "Scale" effect, leave the width field blank and set the height to 150px, when processing a 400x600px image, the system will notice that it needs to divide the height by 4 in order to reduce its height to 150px, and apply the same division to the width, resulting in a 100x150px image.

Again, depending on how you want images to be scaled or cropped, applying more than one action in sequence may also get you where you want to be. For example, scale to a certain width, then crop to a certain height. The "Scale and crop" action can do both of these together in one action, but might not do it in exactly the manner you want.


You might want to check the "Image max size crop" module, which sole mission is to add an image style that provides the functionality that you're looking for.

  • Could you add a quote from module project page that will show exactly why and how it is the answer?
    – Mołot
    Sep 21, 2015 at 22:26

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.