Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ollie Philpott 5 posts 25 karma points
    Jul 07, 2014 @ 11:57
    Ollie Philpott
    0

    Padding an image without upsizing it?

    I can't get this to work, so wondering if it is possible.

    I have some thumbnails of variable size that I need to fit into a 220 x 220 square. My intention is to display the image at its original size (e.g. 100 x 140), with padding surrounding it and a background colour applied.

    If I use the settings below, the image is padded to the left and right but stretched beyond its original size

    <Width>220</Width>
    <Height>220</Height>
    <Pad>true</Pad>
    <BgColor>FBFBFA</BgColor>

    If I add <AllowUpsizing>false</AllowUpsizing>, then the image is displayed at its original size but with no padding.

    Is there anyway to apply padding all the way round an image, and prevent it being upsized?

     

  • Douglas Robar 3563 posts 4597 karma points MVP 6x admin c-trib
    Jul 07, 2014 @ 13:46
    Douglas Robar
    100

    HI, Ollie,

    There's no way to do what you want with ImageGen unfortunately. Padding means you resize to a maximum dimension (220px in your example) while maintaining a proportional resizing of the original image; then any space left over is padded with the background color to make up the full size you requested. By not allowing upsizing you won't get an image bigger than the original even if you request a bigger dimension. So ImageGen is behaving properly, though not in the way you were hoping it might.

    Personally, in this case I would use CSS to align and pad the background rather than creating a larger image to download to the website visitor by including the padding in the resized image itself. If the original image needs to be resized (or cropped) I'd use ImageGen for that part, but leave the background padding to CSS.

    cheers,
    doug.

Please Sign in or register to post replies

Write your reply to:

Draft