FrameFit field notes

Contain vs cover: calculate padding and centered crop

See which parts of an image stay visible when the canvas has a different shape.

Calculate a centered crop →

When an image and its target canvas have different proportions, there is no way to both fill the canvas and show every part of the image without distortion. Contain and cover make that tradeoff explicit while preserving the source shape.

Contain keeps the whole image

The contain scale is the smaller of target-width/source-width and target-height/source-height. A 1920 × 1080 image inside a 1080 × 1080 square becomes 1080 × 607.5. The remaining vertical space is split above and below the image.

Scale = min(1080 / 1920, 1080 / 1080)
      = 0.5625
Top and bottom space = (1080 − 607.5) / 2
                     = 236.25 px each

Cover fills the canvas

The cover scale uses the larger ratio. In the same example, the source remains 1920 × 1080 and the square shows its central 1080 × 1080 region. The crop removes 420 original pixels from each horizontal side.

Scale = max(1080 / 1920, 1080 / 1080) = 1
Crop per side = (1920 − 1080) / 2 = 420 px
Visible source area = 56.25%

Keep coordinate systems separate

FrameFit reports the scaled image in target pixels and crop distances in original source pixels. That distinction matters when the scale is not one. Use the source crop values if you crop before resizing; use scaled dimensions to position a layer on the target canvas.

Centering is a starting point

A centered crop is predictable, but it may cut off a person near an edge. Inspect the actual image in your editor and move the crop window when composition requires it. The calculator does not detect faces or important objects.

Reference: MDN object-fit: contain and cover.