1. Home
  2. Design tools
  3. Object-Fit & Aspect-Ratio Previewer

Object-Fit & Aspect-Ratio Previewer

Put an image in a box of any size and compare all five object-fit values side by side, with the crop worked out in numbers.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use Object-Fit & Aspect-Ratio Previewer

  1. Set the box size and choose a fit.
  2. Move object-position to decide what stays visible.
  3. Copy the CSS.

Features

  • Five fit values compared side by side
  • Object-position sliders
  • Drawn size, offset and visible share calculated
  • Your own image or a labelled sample
  • Optional aspect-ratio in the output
  • Copy-ready CSS

Supported formats

Input

  • An image (optional)
  • Box size and position

You get

  • CSS

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the Object-Fit & Aspect-Ratio Previewer is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • It applies to img, video and similar elements, not to CSS background images.
  • The visible share is calculated geometrically and ignores transparent areas.

Guide

object-fit and object-position: how an image fills its box

Thumbnails, avatars and hero pictures rarely arrive in the shape of the box that holds them. A photo taken in landscape is dropped into a square card, an avatar is taller than it is wide, a banner has to cover a strip of variable height. The object-fit property tells the browser what to do with the mismatch, and object-position decides which part stays in view. Seeing all five values at once makes the difference clear faster than any description.

The five values

fill stretches the image to the box and ignores proportions, so circles become ovals. contain scales the image down until all of it fits, leaving empty bars on two sides. cover scales it up until it fills the box and crops what overflows, which is what most thumbnails want. none ignores the box and draws the image at its natural size, cropped or surrounded by space. scale-down behaves like none or contain, whichever gives the smaller picture, so a small icon is never enlarged.

A worked example

Press Sample: a 1600 by 900 pixel scene in a 300 by 200 pixel box, cover, centred. The readout shows the drawn size as 356 by 200 pixels with an offset of about -28 pixels across, and 84.4% of the image visible. Cover scaled the picture to a height of 200, which makes the width 355.6, and the extra 55.6 pixels are cropped equally from both sides. Switch to contain and the drawn size becomes 300 by 169 with an offset of 16 pixels down, and all of the image is visible. fill draws 300 by 200 and distorts the scene, and none draws 1600 by 900 so only 4.2% is in view.

Choosing the crop

object-position is the anchor of the crop. The default 50% 50% keeps the centre. A portrait on a wide banner usually needs the top, so use 50% 20% rather than the middle, where the chin and shoulders would stay and the eyes be cut off. The sliders go from 0% to 100% for both axes, and the generated line reads for example object-position: 30% 70%;. With contain, position decides where the bars go. When the image has the exact proportions of the box there is nothing to move.

Writing the CSS

The output starts with width: 100%; and the object-fit line, and adds object-position only when you moved it from the centre. If you fill the aspect-ratio field with something like 16 / 9, the rule gains aspect-ratio: 16 / 9; at the top, which keeps the box in proportion while its width changes with the layout and prevents the page from jumping as pictures load. With an aspect ratio on the box you can drop the fixed height.

Edge cases

An img with only width set keeps its natural proportions; object-fit matters only when both dimensions are fixed or driven by the layout. Very large sources waste bandwidth when displayed small, so pair this with correctly sized files or srcset. Non-image content such as video obeys the same rules. Vector pictures without an intrinsic size behave differently under none, so test them.

Limits

The tester shows geometry, not file quality: it does not resize, crop or compress images, and the picture you load stays in your browser. The five previews use the box proportions you set. Focal-point cropping that follows faces needs server software.

Checked against the current version of the Object-Fit & Aspect-Ratio Previewer on .

Troubleshooting

The download did not start

Look for your browser’s download bar or icon. Some browsers ask once before a site may download files; allow it and click the button again.

Frequently asked questions

Why does my image look squashed in a card?

The image has both a width and a height set by the layout and the default object-fit is fill, which stretches to fit. Set object-fit to cover or contain to keep the proportions.

Does object-fit work for background-image?

No, it applies to replaced elements such as img, video and canvas. For backgrounds the equivalent properties are background-size: cover or contain and background-position.

What is the difference between cover and contain?

cover fills the box and crops what overflows. contain shows the whole image and leaves empty bars if the shapes differ.

Does object-fit work on background images?

No. It applies to img, video and similar elements. For backgrounds use background-size and background-position, which take the same keywords.

Keep working with the result

After you download, choose “Save to Workstand” to keep the result in a folder on your computer, attach it to a project and create a follow-up task. It is saved by your browser, not uploaded.