Files
html2pptx/reference/image.md
T

198 lines
5.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 图片参数 (Image Props)
图片参数来自 `ImageProps`(继承 `PositionProps``DataOrPathProps``ObjectNameProps`),用于 `slide.addImage()` 方法。
---
## 位置属性 (PositionProps)
- **x**:水平位置
- 类型:`Coord``number | `${number}%``
- 单位:英寸(number)或百分比(`'50%'`
- **y**:垂直位置
- 类型:`Coord`
- 单位:英寸或百分比
- **w**:宽度
- 类型:`Coord`
- 单位:英寸或百分比
- **h**:高度
- 类型:`Coord`
- 单位:英寸或百分比
---
## 数据/路径属性 (DataOrPathProps)
- **path**:图片 URL 或本地路径
- 类型:`string`
- 示例:`'https://onedrives.com/myimg.png'``'/home/gitbrent/images/myimg.png'`
- **data**base64 编码数据
- 类型:`string`
- 格式:`'image/png;base64,iVtDafDrBF[...]='`
- 说明:base64 编码的图片数据,用时可避免路径/服务器问题
---
## 对象名称属性 (ObjectNameProps)
- **objectName**:对象名称
- 类型:`string`
- 说明:替代默认的 "Object N" 名称,在 PowerPoint 选择窗格中显示
- 默认值:`'Object 1'`
- 始于:v3.10.0
---
## 图片专有属性 (ImageProps)
- **altText**:替代文字(无障碍)
- 类型:`string`
- 说明:PowerPoint 中右击图片 > "编辑替代文字"
- **flipH**:水平翻转
- 类型:`boolean`
- 取值范围:`true` / `false`
- 默认值:`false`
- **flipV**:垂直翻转
- 类型:`boolean`
- 取值范围:`true` / `false`
- 默认值:`false`
- **hyperlink**:超链接
- 类型:`HyperlinkProps`
- 子参数:
- **hyperlink.slide**:链接到页码
- 类型:`number`
- **hyperlink.url**:链接 URL
- 类型:`string`
- **hyperlink.tooltip**:超链接提示
- 类型:`string`
- **placeholder**:占位符类型
- 类型:`string`
- 取值范围:`'body'``'header'``'footer'``'title'`
- 示例:`'body'`
- **rotate**:旋转角度
- 类型:`number`
- 取值范围:`-360``360`(度)
- 默认值:`0`
- 示例:`180`(旋转 180 度)
- **rounding**:启用图片圆角
- 类型:`boolean`
- 默认值:`false`
- **shadow**:阴影
- 类型:`ShadowProps`
- 子参数:
- **shadow.type**:阴影类型
- 类型:`'outer' | 'inner' | 'none'`
- 默认值:`'none'`
- **shadow.opacity**:不透明度
- 类型:`number`
- 取值范围:`0.0``1.0`
- **shadow.blur**:模糊
- 类型:`number`
- 取值范围:`0``100`pt
- 默认值:`0`
- **shadow.angle**:角度
- 类型:`number`
- 取值范围:`0``359`(度)
- 默认值:`0`
- **shadow.offset**:偏移距离
- 类型:`number`
- 取值范围:`0``200`pt
- 默认值:`0`
- **shadow.color**:阴影颜色
- 类型:`HexColor`
- 格式:6 位十六进制(无 `#`
- **shadow.rotateWithShape**:阴影是否随形状旋转
- 类型:`boolean`
- 默认值:`false`
- **sizing**:图片大小调整
- 类型:`{ type: 'contain' | 'cover' | 'crop', w: Coord, h: Coord, x?: Coord, y?: Coord }`
- 子参数:
- **sizing.type**:调整类型
- 类型:`'contain' | 'cover' | 'crop'`
- 取值范围:
- `contain` — 包含(保持比例适配)
- `cover` — 覆盖(填充区域)
- `crop` — 裁剪
- **sizing.w**:图片宽度
- 类型:`Coord`(英寸或百分比)
- **sizing.h**:图片高度
- 类型:`Coord`(英寸或百分比)
- **sizing.x**:裁剪左偏移
- 类型:`Coord`(仅用于 `crop` 模式)
- **sizing.y**:裁剪上偏移
- 类型:`Coord`(仅用于 `crop` 模式)
- **transparency**:透明度
- 类型:`number`
- 取值范围:`0``100`(百分比)
- 默认值:`0`
- 示例:`25`25% 透明)
---
## ShadowProps
用于 `shadow` 属性的类型定义(图表、图片、文字通用)。
- **type**:阴影类型
- 类型:`'outer' | 'inner' | 'none'`
- 默认值:`'none'`
- **opacity**:不透明度
- 类型:`number`
- 取值范围:`0.0``1.0`
- 示例:`0.5`50% 不透明)
- **blur**:模糊大小
- 类型:`number`
- 取值范围:`0``100`pt
- 默认值:`0`
- **angle**:阴影角度
- 类型:`number`
- 取值范围:`0``359`(度)
- 默认值:`0`
- **offset**:阴影偏移距离
- 类型:`number`
- 取值范围:`0``200`pt
- 默认值:`0`
- **color**:阴影颜色
- 类型:`HexColor`
- 格式:6 位十六进制(无 `#`
- **rotateWithShape**:是否随形状旋转
- 类型:`boolean`
- 默认值:`false`
---
## HyperlinkProps
用于 `hyperlink` 属性的类型定义。
- **slide**:链接到页码
- 类型:`number`
- 说明:跳转到演示文稿的指定幻灯片
- **url**:超链接 URL
- 类型:`string`
- 说明:链接到外部网址
- **tooltip**:超链接提示
- 类型:`string`
- 说明:鼠标悬停时显示的文字