Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/content/docs/zh-cn/reference/modules/astro-assets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,34 @@ fetchpriority="high"

如需进一步定制,这些独立属性仍可手动设置。

#### `background`

<p>

**类型:** `string | undefined`<br />
<Since v="5.17.0" />
</p>

在将图像扁平化以转换为所需输出 `format` 时使用的背景颜色。

默认情况下,Sharp 在将图像扁平化时使用黑色背景。指定不同的背景颜色在将具有透明背景的图像转换为不支持透明度的格式(例如 `.jpeg`)时尤其有用:

```astro title="src/components/MyComponent.astro" "background"
---
import { Image } from 'astro:assets';
import myImage from '../assets/my_image.png';
---
<Image
src={myImage}
alt="A description of my image"
format="jpeg"
background="#ffffff"
/>
```

这些值会直接传递给图像服务。Sharp 接受 [`color-string `包能解析的任何值](https://github.com/Qix-/color-string/blob/master/README.md#parsing)。


### `<Picture />`

<p><Since v="3.3.0" /></p>
Expand Down