image-rendering
===============

The **`image-rendering`** CSS property sets an image scaling algorithm. The property applies to an element itself, to any images set in its other properties, and to its descendants.

Try it
------

The user agent will scale an image when the page author specifies dimensions other than its natural size. Scaling may also occur due to user interaction (zooming). For example, if the natural size of an image is `100×100px`*,* but its actual dimensions are `200×200px` (or `50×50px`), then the image will be upscaled (or downscaled) using the algorithm specified by `image-rendering`. This property has no effect on non-scaled images.

Syntax
------


```css
/\* Keyword values \*/
image-rendering: auto;
image-rendering: crisp-edges;
image-rendering: pixelated;

/\* Global values \*/
image-rendering: inherit;
image-rendering: initial;
image-rendering: revert;
image-rendering: revert-layer;
image-rendering: unset;
```

### Values

`auto`

The scaling algorithm is UA dependent. Since version 1.9 (Firefox 3.0), Gecko uses *bilinear* resampling (high quality).

`smooth` 
Experimental

The image should be scaled with an algorithm that maximizes the appearance of the image. In particular, scaling algorithms that "smooth" colors are acceptable, such as bilinear interpolation. This is intended for images such as photos.

`high-quality` 
Experimental

Identical to `smooth`, but with a preference for higher-quality scaling. If system resources are constrained, images with `high-quality` should be prioritized over those with any other value, when considering which images to degrade the quality of and to what degree.

`crisp-edges`

The image is scaled with an algorithm that preserves contrast and edges in the image. Generally intended for images such as pixel art or line drawings, no blurring or color smoothing occurs.

`pixelated`

The image is scaled with the "nearest neighbor" or similar algorithm, preserving a "pixelated" look as the image changes in size.


**Note:** The values `optimizeQuality` and `optimizeSpeed` present in an early draft (and coming from its SVG counterpart `image-rendering`) are defined as synonyms for the `smooth` and `pixelated` values respectively.

Formal definition
-----------------

|  |  |
| --- | --- |
| Initial value | `auto` |
| Applies to | all elements |
| Inherited | yes |
| Computed value | as specified |
| Animation type | discrete |

Formal syntax
-------------
```

image-rendering =   
  auto          |  
  smooth        |  
  high-quality  |  
  pixelated     |  
  crisp-edges     
  
```

Examples
--------

### Setting image scaling algorithms

In practical use, the `pixelated` and `crisp-edges` rules can be combined to provide some fallback for each other. (Just prepend the actual rules with the fallback.) The Canvas API can provide a fallback solution for `pixelated` through manual image data manipulation or with `imageSmoothingEnabled`.
```

<div>
  <img
 class="auto"
 alt="A small photo of some white and yellow flower against a leafy green background. The image is about 33% smaller than the size it is being displayed at. This upscaling causes the image to appear blurry, with notable soft edges between objects."
 src="blumen.jpg" />
  <img
 class="pixelated"
 alt="The same photo as the previous image, which is also being upscaled the same amount. Browsers that support the pixelated value for the image-rendering property display the image as very pixelated. Individual pixels are clearly visible and edges appear much sharper."
 src="blumen.jpg" />
  <img
 class="crisp-edges"
 alt="The same photo as the previous images, which is also being upscaled the same amount. Browsers that support the crisp-edges value for the image-rendering property display the image as very pixelated. In these examples, there is virtually no perceivable difference between the pixelated and crisp-edges versions."
 src="blumen.jpg" />
</div>
```


```
img {
  height: 200px;
}
```


#### CSS


```css
.auto {
  image-rendering: auto;
}

.pixelated {
  image-rendering: pixelated;
}

.crisp-edges {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}
```


#### Result

Specifications
--------------

| Specification |
| --- |
| CSS Images Module Level 3 # the-image-rendering |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

**Note:** Although `crisp-edges` is supposed to use a pixel-art scaler like in the specification example, in practice no browsers (as of January 2020) do so. In Firefox, `crisp-edges` or `pixelated` is interpreted as nearest-neighbor, and `auto` is interpolated as trilinear or linear.

For behavior on Chromium and Safari (WebKit), see the `GetInterpolationQuality` function and `CSSPrimitiveValue::operator ImageRendering()` respectively.

See also
--------

* Other image-related CSS properties: `object-fit`, `object-position`, `image-orientation`, `image-rendering`, `image-resolution`.