2

I am trying to resize images (logos) to a max of 150px width and 150px height. Since these images differ greatly in original width and height I would like to center the generated image and then fill the gaps with a background color.

What I would like to end up with is a 150px x 150px image every time with logo centered... is this possible with CE Image?

Here is my current tag.

{exp:ce_img:pair src="{logo}" max_height="150" max_width="150" crop="no"}
    <img class="media-object" src="{made}" height="{height}" width="{width}" alt="{title}" />
{/exp:ce_img:pair}

1 Answer 1

2

Yes, there's an example on the CE Image docs (common solutions, option 2 - watermark) - essentially you need a blank image file that you can stretch as a watermark behind the resized graphic. Something like this (derived from the example on that page):

{exp:ce_img:pair src="{logo}" parse="inward" max="150" crop="yes"}
    {exp:ce_img:single src="/images/white_spec.png"
watermark="{made}|0,0|100|center,center" width="150" height="150" crop="yes" allow_scale_larger="yes"}
{/exp:ce_img:pair}

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.