How Does SMIL Region Fit Attribute Scale Images?
The fit attribute in Synchronized Multimedia Integration
Language (SMIL) controls how visual media elements, such as images or
video streams, adapt to the physical dimensions of their target
<region>. By specifying values like
hidden, fill, meet,
slice, or scroll, authors can dictate whether
media scales uniformly, stretches non-uniformly, crops overflow, or
preserves native aspect ratios. Understanding how these values interact
with intrinsic image dimensions is essential for predictable multimedia
layout and rendering across SMIL-compliant players.
Core Role of the Fit Attribute
In SMIL layout models, visual components render inside dedicated
spatial containers defined by <region> tags within
the <layout> header. When an image's native width and
height differ from the region's declared bounds, the fit
attribute determines the rendering behavior:
- Aspect Ratio Preservation: It dictates whether the player enforces the original width-to-height ratio or distorts the image to occupy all available space.
- Overflow Handling: It specifies whether media extending past region boundaries should be clipped, displayed with scroll mechanisms, or scaled down.
- Blank Space Management: It governs whether empty space (letterboxing or pillarboxing) appears when an aspect ratio does not match the bounding box.
Breakdown of Fit Values
SMIL defines several standard values for the fit
attribute, each directly influencing aspect ratio and scale.
hidden
The hidden value acts as the default behavior in many
SMIL profiles. The visual asset renders at its exact intrinsic
resolution, anchored at the top-left corner of the region. No scaling
occurs. If the image is smaller than the region, the remaining area
displays the background color. If the image exceeds the region
dimensions, any content extending beyond the boundaries is clipped and
hidden from view.
fill
Setting fit="fill" forces the media object to scale both
horizontally and vertically until its width and height match the target
region exactly. This mode ignores intrinsic aspect ratios. If the
region's aspect ratio differs from the image's source ratio, the visual
content stretches or compresses, leading to visible distortion.
meet
The meet value scales the visual element uniformly while
strictly preserving its original aspect ratio. The media scales until
one dimension reaches the boundary of the region, ensuring the entire
image remains visible without cropping. If the region aspect ratio does
not match the image, empty space appears along the unconstrained axis,
creating letterbox (horizontal bars) or pillarbox (vertical bars)
effects.
slice
Like meet, fit="slice" scales the media
uniformly to preserve the original aspect ratio. However, instead of
stopping when the first edge touches the boundary, it continues scaling
until the entire region area is fully covered. As a result, the
dimension that exceeds the region's bounds is cropped, eliminating blank
margins at the cost of losing peripheral visual content.
scroll
The scroll setting renders the image at its native
dimensions without scaling, similar to hidden. However, if
the asset exceeds the bounding box, the user agent provides interactive
scrolling controls (such as horizontal or vertical scrollbars) allowing
the user to pan across the full graphic.
Comparison of Scaling Behaviors
| Fit Value | Preserves Aspect Ratio | Scales Media | Crops Content | May Introduce Letterboxing |
|---|---|---|---|---|
hidden |
Yes (Native Size) | No | Yes (If oversized) | No (Shows background) |
fill |
No | Yes (Non-uniform) | No | No |
meet |
Yes | Yes (Uniform) | No | Yes |
slice |
Yes | Yes (Uniform) | Yes | No |
scroll |
Yes (Native Size) | No | No (Scrollable) | No (Shows background) |
Implementation Example
The following SMIL layout configuration illustrates how different scaling rules apply to regional definitions:
<smil xmlns="http://www.w3.org/ns/SMIL" version="3.0" baseProfile="Language">
<head>
<layout>
<root-layout width="800px" height="600px" backgroundColor="black"/>
<!-- Uniform scaling with letterboxing -->
<region id="main_viewport" top="0px" left="0px" width="800px" height="450px" fit="meet"/>
<!-- Cropped full-bleed background -->
<region id="bg_layer" top="0px" left="0px" width="800px" height="600px" fit="slice"/>
</layout>
</head>
<body>
<par>
<img src="background.jpg" region="bg_layer"/>
<img src="graphic.png" region="main_viewport"/>
</par>
</body>
</smil>When authoring responsive or multi-display SMIL presentations,
selecting between meet and slice provides the
most reliable way to handle disparate screen resolutions without
introducing visual distortion.