> [Site index](https://perfectvector.com/llms.txt) — available pages and descriptions.

# SVG feImage: Fit, Crop, or Stretch a Filter Image

> Place an SVG filter image with feImage preserveAspectRatio. Compare meet, slice, and none in the same filter primitive region.

Source: https://perfectvector.com/blog/svg-feimage-aspect-ratio

Language: en
Author: Irene Kim
Published: 2026-11-27T08:00:00+09:00

Set `preserveAspectRatio` on `feImage` to choose how an image fits inside the filter primitive's rectangle. Use `xMidYMid meet` to center the entire image, `xMidYMid slice` to fill the rectangle and crop any excess, or `none` to stretch the image to both dimensions. [W3C Filter Effects Level 1](https://www.w3.org/TR/filter-effects-1/#feImageElement)

## Find the rectangle your image fits

The **filter primitive subregion** is the rectangle for one primitive. When you set `x`, `y`, `width`, and `height` on `feImage`, those values define the rectangle used here. `primitiveUnits="userSpaceOnUse"` makes the numbers use the current user coordinate system. The outer `filter` has its own region and can also clip the result. [Filter primitive subregions](https://www.w3.org/TR/filter-effects-1/#FilterPrimitiveSubRegion)

| Setting          | What stays visible when a wide image goes into a square                       |
| ---------------- | ----------------------------------------------------------------------------- |
| `xMidYMid meet`  | Both ends remain visible. There is space above and below.                     |
| `xMidYMid slice` | The square fills without stretching. The left and right ends are cropped.     |
| `none`           | Both ends remain visible and the square fills. The image changes proportions. |

With `meet` or `slice`, `xMidYMid` centers the fit on both axes. Choose a different alignment when one edge contains something you need to keep. [W3C SVG 2 aspect-ratio rules](https://www.w3.org/TR/SVG2/coords.html#PreserveAspectRatioAttribute)

## Hold the filter rectangle steady and change the fit

Save this example as an SVG. The embedded 12 × 6 PNG has orange columns at both ends and a green center mark. The peach rectangle behind the filtered object makes uncovered space visible. The filter and primitive bounds are both 120 × 120, so switching one attribute isolates the effect of the fit.

```svg
<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120"
     viewBox="0 0 120 120">
  <defs>
    <filter id="fit" x="0" y="0" width="120" height="120"
            filterUnits="userSpaceOnUse" primitiveUnits="userSpaceOnUse">
      <feImage x="0" y="0" width="120" height="120"
               href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAGCAIAAAB4jOjWAAAAHUlEQVR4nGN40uQiZxsCR9pNJUCELAJUwDBUFQEAvuJCVaRaCrYAAAAASUVORK5CYII="
               preserveAspectRatio="xMidYMid meet"/>
    </filter>
  </defs>
  <rect width="120" height="120" fill="#f6d9b9"/>
  <rect width="120" height="120" filter="url(#fit)"/>
</svg>
```

Open the file, then make two copies that replace `xMidYMid meet` with `xMidYMid slice` and `none`. Compare the left edge near the vertical center and the top edge near the horizontal center.

In our resvg 0.47.0 renders, `meet` kept orange at (3, 60) and exposed the peach background at (60, 3). With `slice`, the left sample changed to navy and the top sample was covered by the image. With `none`, the left sample stayed orange and the image covered the top. These samples distinguish crop, padding, and stretch for this fixture.

![Three square feImage renders showing full motif with top and bottom space, cropped sides, and a stretched motif](https://perfectvector.com/blog/svg-feimage-aspect-ratio/workflow-proof.webp)

*The rectangle and source image stay fixed. Watch the orange edges and the peach background above the motif.*

## Check the fit before combining the image with another input

When `feImage` is one input in a larger filter, use it as the last primitive in a disposable copy. Inspect the resulting image and its bounds before restoring the composite operation. This checks the fit independently of [which image a composite keeps or removes](https://perfectvector.com/blog/svg-composite-artwork).

Changing `preserveAspectRatio` on the root SVG changes how the whole view fits its viewport. For a mismatch isolated to the filter image, change the attribute on `feImage`. Use the [SVG preserveAspectRatio guide](https://perfectvector.com/blog/svg-preserveaspectratio) if the framing problem affects the entire SVG. For an ordinary image placed outside a filter, this fit can be set on the SVG `image` element. [W3C SVG 2 image element](https://www.w3.org/TR/SVG2/embedded.html#ImageElement)

## FAQ

### What is the default fit for feImage?

The default is xMidYMid meet. It centers the image and scales it uniformly to keep the whole image inside the primitive rectangle.

### What is the difference between meet and slice?

Both preserve the source aspect ratio. Meet keeps the entire image visible. Slice fills the rectangle by cropping any portion outside it.

### Does preserveAspectRatio="none" crop the image?

It stretches the source to the target width and height. A wide motif can become taller relative to its width when you stretch it into a square.

## Start with paths when the motif needs editing

PerfectVector can trace a flat raster motif into editable SVG paths. If you need to change its individual shapes in an SVG editor, [vectorize the source image](https://perfectvector.com/image-to-vector) and check that its paths can be selected separately before reusing it. Use the fit settings above when you only need to place the source image inside a filter.

## Sources

1. [W3C Filter Effects Level 1, feImage](https://www.w3.org/TR/filter-effects-1/#feImageElement) — Defines the image primitive and its default fit.
2. [W3C SVG 2, preserveAspectRatio](https://www.w3.org/TR/SVG2/coords.html#PreserveAspectRatioAttribute) — Defines the aspect fit and alignment values.
3. [W3C SVG 2, the image element](https://www.w3.org/TR/SVG2/embedded.html#ImageElement) — Documents aspect fit for an image placed outside a filter.

## Explore

- [Read the HTML article](https://perfectvector.com/blog/svg-feimage-aspect-ratio)
- [Place an SVG Filter Offset With Signed dx and dy](https://perfectvector.com/blog/svg-feoffset-dx-dy.md)
- [Stop SVG Logo Layout Shifts by Reserving Space](https://perfectvector.com/blog/svg-logo-layout-reservation.md)
- [Product facts](https://perfectvector.com/product-facts.md)
- [FAQ](https://perfectvector.com/faq.md)
- [Pricing and credits](https://perfectvector.com/pricing.md)
