I am not sure if this really is this difficult, or if I can't come up with the right search terms, but an ImageCache use case has me stumped right now.

I have a theme where I need to proportionally scale images to a max height and width (ie, a bounding box), and if possible center the image on a colored background.

For example, lets say I have a 1024x768 image and max size is 500x400. I need ImageCache to make a 500x375 image. The action would need to work for arbitrary image sizes, as the input varies widely.

Non-proportional scaling and/or cropping is not an option due to usage rights.

What is the best option here? I have gone through module that add additional ImageCache actions, but did not see any that did this. I suspect I could use ImageMagick Raw Effect but I would rather not rely on a particular toolkit, as I may need a portable solution.


Add two scale actions to a preset. On the first one, set the width to 500, and in the second, set the height to 400. Since they don't by default up-scale, that should bound you in your box.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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