What is image padding?

Image padding is extra space added around an image's content, filled with transparent or solid pixels, to reach a target size or aspect ratio without cropping or stretching.

By · Updated

Want the full walkthrough? Read: How to make a picture square without cropping →

Explained in more detail

Padding makes the canvas bigger than the picture. The original pixels stay exactly where they are, relative to each other, and new pixels are added around them. The new pixels can be transparent, white, black or any chosen color.

The most common use is making an image fit a required shape without distorting it. A 1200 by 800 photo that has to be square can be placed on a 1200 by 1200 canvas with 200 pixels of padding above and below. Nothing is cropped and nothing is stretched, so the subject keeps its proportions. Marketplaces and social platforms that want a 1:1 listing image are the typical case.

Padding is also used for breathing room. Icons and logos usually need a small margin so they do not touch the edge of their container, and sprite sheets often pad each frame so that scaling does not blend neighbouring images together.

Which color to pad with depends on the destination. Transparent padding keeps the image flexible but only works in formats with alpha, such as PNG and WebP. White padding is safe for white-background listings and for JPEG, which cannot store transparency.

Padding and trimming are complementary. Trim first to remove accidental margins, then pad to the exact size you need.

Related terms

Try it in Triim

Further reading

Part of the Triim image terms glossary, by Rocco Bombardieri.