Actions4
调整大小
AI-generatedOverview
This node performs image processing with a focus on resizing images. It supports resizing images by specifying exact dimensions or scaling based on the longest edge, maintaining or adjusting aspect ratios according to user preferences. The node can take input images from file paths, base64 strings, or binary data, and outputs the processed image either saved to a file or as binary data. It is useful for scenarios where images need to be resized for web optimization, thumbnails, or specific display requirements.
Use Case Examples
- Resize an image to 1920x1080 resolution for HD display.
- Scale an image proportionally based on the longest edge to fit within 800 pixels.
- Resize images in bulk from file paths and save the resized versions to a target directory.
Properties
| Name | Meaning |
|---|---|
| 附加描述信息 | 为图像添加附加描述信息(类似于PNG的comments或EXIF的description)用于转换、调整大小和裁剪操作,输出为文件或二进制数据时使用。 |
| Input Type | 指定输入图像的类型,可以是文件路径、Base64编码字符串或二进制数据。 |
| Source Path | 当输入类型为文件路径时,指定源图像文件的路径。 |
| Base64 Image | 当输入类型为Base64时,提供Base64编码的图像数据。 |
| Binary Property | 当输入类型为二进制数据时,指定包含图像数据的二进制属性名称。 |
| Target Path | 调整大小操作时,指定处理后图像保存的文件路径。 |
| 调整大小模式 | 选择调整大小的模式,指定宽高或按最长边等比例缩放。 |
| 分辨率 | 当调整大小模式为指定宽高时,选择输出图像的分辨率。 |
| 自定义分辨率 | 当分辨率选择自定义时,手动输入分辨率,格式为宽x高。 |
| 最长边尺寸 | 当调整大小模式为按最长边缩放时,指定最长边的尺寸,图像将按比例缩放。 |
| 调整大小选项 | 调整大小时的附加选项,包括缩放模式、背景颜色、位置、不放大和不缩小设置。 |
Output
JSON
error- 当操作失败时,返回的错误信息。success- 操作是否成功的标志。operation- 执行的图像处理操作名称。
Dependencies
- sharp library for image processing
Troubleshooting
- 输入路径错误或文件不存在会导致处理失败,确保源路径正确且文件可访问。
- Base64或二进制数据格式错误会导致解码失败,确认输入数据格式正确。
- 调整大小参数设置不合理(如分辨率格式错误)可能导致异常,检查输入参数格式。
- 输出路径无写权限会导致保存失败,确保目标路径可写。
- 操作失败时节点会抛出错误,启用继续执行选项可捕获错误信息并继续处理。