Images
How to resize an image without stretching it
Choose between proportional resizing, cropping, and padding.
To make an image smaller without distorting it, change its width and height by the same proportion. A 1600 × 900 image becomes 800 × 450 when both dimensions are halved.
Keep the proportions
In an image editor, enable the aspect-ratio lock before entering a new width. For a 1200-pixel-wide copy of that same image, calculate the height as 900 × (1200 ÷ 1600) = 675.
When the destination has a different shape
A wide image cannot fill a square and keep every edge visible without extra space. Choose what matters:
- Crop: fill the square and remove part of the image. Check that the subject still fits.
- Pad: keep the complete image and add space around it.
- Stretch: change the proportions. Circles become ovals, so avoid this for photographs and logos.
Displaying an image on a website
Use width: 100%; height: auto; for a proportionally scaled image. Inside a fixed-size box, object-fit: contain keeps the whole image visible; object-fit: cover fills the box and can crop it.
CSS controls display size. It does not create a smaller downloadable image file. Export a resized copy when reducing the file's pixel dimensions is the goal, and keep the original for future edits.