> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# image-rendering

APISummary
## Introduce

`image-rendering`

Used to set the image scaling algorithm. Currently only works with `<image>` and `background-image`
Currently it only applies to the element itself and will not take effect on child elements.

The image will be scaled when the dimensions specified by the front end are not the original dimensions of the image. For example, if there is an image with a physical pixel size of 100×100, but the actual width and height dimensions are set to 200×200px (or 50×50px), then the image will be reduced or reduced according to the algorithm specified by image-rendering. Enlarge to new size. This property has no effect on unscaled images.

## Examples

**This is an example below: css-api**

**Entry:** `src/image-rendering`
**Bundle:** `dist/image-rendering.lynx.bundle`

```tsx
import { root } from "@lynx-js/react";
import "./index.scss";

const ImageRendering = () => {
  const url =
    "data:image/bmp;base64,Qk12BQAAAAAAADYAAAAoAAAAFQAAAOv///8BABgAAAAAAEAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AAAAAAAA////////AAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////////wAAAP///////wAAAP///////////////wAAAP///////////////////wAAAAAAAAD///8AAAAAAAAAAAD///8AAAD///8AAAAAAAAAAAD///////////8AAAD///8AAAAAAAAAAAD///8AAAAAAAAA////AAAAAAAAAAAA////AAAA////AAAAAAAA////////AAAA////AAAA////AAAAAAAAAAAA////AAAAAAAAAP///wAAAAAAAAAAAP///wAAAP///////wAAAAAAAP///////////wAAAP///wAAAAAAAAAAAP///wAAAAAAAAD///////////////////8AAAD///8AAAD///8AAAD///////////8AAAD///////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AAAA////AAAA////AAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////////////////////wAAAP///wAAAP///////////////////////////////////////wAAAAAAAAD///8AAAD///////8AAAAAAAD///////8AAAAAAAAAAAAAAAAAAAAAAAD///8AAAAAAAD///8AAAAAAAAAAAAA////AAAAAAAA////////////////////AAAA////////AAAAAAAA////AAAAAAAA////AAAAAAAAAP///wAAAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////////wAAAP///////////wAAAAAAAAD///////8AAAAAAAD///////////////////////////////8AAAD///////8AAAAAAAD///8AAAAAAAAAAAAA////AAAAAAAAAAAA////////AAAA////////AAAAAAAAAAAA////////////AAAA////////////AAAAAAAAAP///////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAP///wAAAAAAAP///////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8AAAD///8AAAD///////////8AAAAAAAAAAAD///////8AAAD///8AAAAA////////////////////AAAA////////AAAAAAAA////////AAAA////////////////////////AAAAAAAAAP///wAAAAAAAAAAAP///wAAAP///////////wAAAP///wAAAP///wAAAP///////wAAAAAAAAAAAP///wAAAAD///8AAAAAAAAAAAD///8AAAD///8AAAAAAAD///8AAAAAAAAAAAAAAAAAAAD///8AAAD///8AAAD///8AAAAA////AAAAAAAAAAAA////AAAA////////AAAA////////////////AAAAAAAAAAAA////AAAA////////AAAAAP///////////////////wAAAP///wAAAP///wAAAAAAAAAAAAAAAP///////wAAAAAAAP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8AAAAAAAAAAAD///////////////////8AAAD///////8AAAD///8A";

  const verticalStyle = {
    linearOrientation: "vertical" as const,
  };

  const pixelatedStyle = {
    imageRendering: "pixelated" as const,
  };

  const autoStyle = {
    imageRendering: "auto" as const,
  };

  const crispEdgesStyle = {
    imageRendering: "crisp-edges" as const,
  };

  return (
    <scroll-view>
      <view style={verticalStyle}>
        <view className="image size" style={pixelatedStyle}></view>
        <view className="image size" style={autoStyle}></view>
        <view className="image size" style={crispEdgesStyle}></view>
      </view>

      <view style={verticalStyle}>
        <image src={url} className="size" style={pixelatedStyle}></image>
        <image src={url} className="size" style={autoStyle}></image>
        <image src={url} className="size" style={crispEdgesStyle}></image>
      </view>
    </scroll-view>
  );
};

root.render(<ImageRendering />);

```

v0.11.0



## Syntax

```css
image-rendering: auto;
image-rendering: crisp-edges;
image-rendering: pixelated;
```

### Values

#### `auto`

Default value, platform layer default setting. Generally implemented as bilinear interpolation

#### `crisp-edges`

The image must be scaled using an algorithm that effectively preserves contrast and edges in the image, and that does not smooth the colors or introduce blur into the image during processing. This attribute value is suitable for pixel art works, such as images in some web games.
This is designed for pixel games (refer to Pixel-art scaling algorithms), and is not implemented by mainstream browsers.
Currently, lynx does not support it, and the effect is the same as auto.

#### `pixelated`

When zooming in and out of an image, the nearest neighbor algorithm is used, so the image appears to be made up of large blocks of pixels.

## Formal definition

| Initial value | auto |
| Applies to | `image`, view's `background-image` |
| Inherited | no |
| Animatable | no |


## Formal syntax

```
image-rendering = auto | crisp-edges | pixelated
```

## Differences from the Web

1. Only takes effect on the element itself, not on child elements.
2. Global attribute values ​​such as inherit, unset, etc. are not supported.

## Compatibility

**Compatibility Table**

**Query:** `css.properties.image-rendering`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/208-image-rendering.json) · [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| image-rendering | Partial (2.14) | Partial (3.4) | Partial (2.14) | Partial (2.14) | Partial (2.14) | Partial |

**`image-rendering`**

The image-rendering CSS property sets an image scaling algorithm. The property applies to an element itself.

- **Android — From 2.14:** Partial support; only <image> and  background-image supports, it only applies to an element itself.
- **HarmonyOS — From 3.4:** Partial support; only <image> and  background-image supports, it only applies to an element itself.
- **iOS — From 2.14:** Partial support; only <image> and  background-image supports, it only applies to an element itself.
- **macOS — From 2.14:** Partial support; only <image> and  background-image supports, it only applies to an element itself.
- **Windows — From 2.14:** Partial support; only <image> and  background-image supports, it only applies to an element itself.
- **Web — Supported (version unknown):** Partial support; it applies to an element itself, to any images set in its other properties, and to its descendants.

