跳到主要内容

调整图像大小 n8n

调整图像大小 是一个 PDF4me 节点操作 n8n 它可以按原始尺寸的百分比或精确到像素宽度和高度缩放图像,并可通过开关启用/禁用保持宽高比。可用于生成缩略图、将用户上传的图片标准化为房屋大小,或在存储前缩小过大的照片。

此节点的功能

PDF4me调整图像大小 从二进制数据中获取图像, Base64 String或者 URL 并返回一个缩放后的副本。 调整大小类型 字段决定方法: 百分比 按原图比例缩放,适用于混合尺寸的输入; 具体的 为固定布局槽位设定精确的像素宽度和高度。由于该节点对每个传入项只运行一次,因此一个配置好的节点即可使用相同的设置调整整批数据的大小。

相关博客文章
目前尚无关于此功能的博客文章——敬请期待。
在此期间,您可以浏览 PDF4me 博客,查看适用于各平台的教程和工作流程。
访问博客

验证您的身份 API 要求

每一个 PDF4me 节点 n8n 需要有效 用于连接的凭证创建或选择一个可以容纳您的 PDF4me API 关键在于确保工作流程能够安全地验证调整大小请求。

您不容错过的重要事实

调整大小类型决定显示哪些字段
选择“百分比”会显示“调整大小百分比”。选择“具体数值”会显示“宽度”和“高度”。您无需同时填写这两组数值。
保持宽高比可防止图像失真。
除非您特意需要非比例尺寸,否则请保持此开关开启。关闭此开关后,如果宽度和高度不匹配,图片将被拉伸。
放大并不能创造细节
超过 100% 的百分比会增加像素尺寸,但不会提高清晰度。务必从可用的最高分辨率源开始。
n8n 中的 PDF4me 节点设置为“操作:调整图像大小”,输入数据类型:二进制数据,输入二进制字段:数据,输出文件名:resize_image_output.jpg,调整类型:百分比,调整百分比:50%,并启用了“保持纵横比”和“异步”切换开关。

PDF4me 在“调整图像大小”参数面板中 n8n以百分比模式显示

百分比调整还是特定值调整:应该使用哪种调整大小方式?

这两种模式解决的是不同的问题,选错模式是导致输出大小意外的最常见原因。

调整大小类型您填写的字段最佳匹配
PercentageResize Percentage, for example 50 to halve or 200 to doubleMixed-size inputs that should all shrink or grow by the same proportion, keeping their relative differences
SpecificWidth and Height in pixelsA fixed layout slot, thumbnail grid, or platform that demands exact dimensions regardless of the source size

调整图像大小需要哪些参数?

必需的: 操作、输入数据类型、与该输入类型匹配的字段、输出文件名、调整大小类型以及调整大小类型所显示的维度字段。 Async 二进制数据输出名称带有默认的工作值。

范围必需的它的作用例子
ActionRequiredSelects the PDF4me node action to run. Choose Resize Image.Resize Image
Input Data TypeRequiredFormat of the source image input. Choose Binary Data (from a previous node), Base64 String, or URL.Binary Data
Input Binary FieldConditionalName of the binary property on the incoming n8n item that holds the image. Required when Input Data Type is Binary Data. Defaults to data.data
Base64 Image ContentConditionalBase64-encoded content of the source image. Required when Input Data Type is Base64 String./9j/4AAQSkZJRgAB...
Image URLConditionalPublicly reachable HTTPS URL to the source image. Required when Input Data Type is URL.https://example.com/photo.jpg
Output File NameRequiredFilename for the resized image. Include the extension matching the output format.resize_image_output.jpg
Resize TypeRequiredScaling method. Percentage scales relative to the original size, Specific targets exact pixel dimensions. Your choice decides which fields appear next.Percentage
Resize PercentageConditionalScaling percentage relative to the original. Below 100 reduces, above 100 enlarges. Required when Resize Type is Percentage.50
WidthConditionalTarget width in pixels. Required when Resize Type is Specific.800
HeightConditionalTarget height in pixels. Required when Resize Type is Specific.600
Maintain Aspect RatioOptionalToggle that preserves the original proportions so the image is not stretched. Leave enabled unless you need forced dimensions.true
AsyncOptionalToggle that runs the resize in the background instead of holding the workflow execution open. Useful for large images or long batches.true
Binary Data Output NameOptionalName of the binary property the output item exposes. Defaults to data.data

输出字段

一次成功的运行返回一个 n8n 包含调整大小后的图像及其尺寸报告的项目。

场地类型它包含什么
Binary (data)BinaryThe resized image, under Binary Data Output Name (default data).
fileNameStringGenerated filename, matching Output File Name.
mimeTypeStringMIME type of the output image, for example image/jpeg or image/png.
fileSizeNumberSize of the resized image in bytes.
originalDimensionsStringWidth and height of the source image in pixels, for example 1920x1080.
newDimensionsStringWidth and height after resizing, for example 960x540. Compare it against your target to confirm aspect ratio behaviour.
successBooleanTrue when the resize completed, false on failure. Use it to branch error handling.
messageStringHuman-readable status message, carrying success confirmation or error detail.

如何在设置中调整图像大小 n8n

  1. 添加 PDF4me 致你 n8n 工作流程并选择 调整图像大小 行动。
  2. 用于连接的凭证请选择您的 PDF4me 凭证或点击 创建新凭证 并粘贴你的 API 钥匙。
  3. 输入数据类型二进制数据 (默认), Base64 String, 或者 URL 并提供匹配的源图像字段。
  4. 调整大小类型百分比 并填写 调整大小百分比或者 具体的 并填写 宽度高度
  5. 离开 保持宽高比 启用以避免拉伸,并启用 Async 适用于大型图像或大批量处理。
  6. 输出文件名执行该节点并检查 newDimensions 在输出结果上进行确认。

典型配置

工作流程示例Common n8n workflow patterns using Resize Image.
产品上传的缩略图
  1. 新的产品图片已上传至云端存储。
  2. 调整图像大小以特定模式运行,尺寸为缩略图网格尺寸。
  3. 缩略图会与原图一起显示。
缩小用户上传的超大文件
  1. webhook 会接收通过表单提交的照片。
  2. 调整图像大小以百分比模式运行,按比例缩小图像。
  3. 存储较小的文件,从而控制存储空间和带宽。
批量归一化图像库
  1. “循环遍历项目”节点会遍历一个包含大小不一图像的现有文件夹。
  2. “调整图像大小”功能对每个项目应用一致的设置, Async 已启用。
  3. 最终,无需任何人打开编辑器,库文件就会变得统一。
调整大小并压缩以适应网络。
  1. 编辑图片是从内容管理系统中提取的。
  2. 调整图像大小首先会将其缩小到显示宽度。
  3. 压缩图像后,会在发布前进一步减小文件大小。

实用技巧

Resize before you compress, not after
Reducing dimensions first means the compressor has less data to work on, which usually gives a better result than compressing a full-size image.
Leave Maintain Aspect Ratio on by default
Turning it off only makes sense when a target slot genuinely demands non-proportional dimensions. Otherwise it silently stretches faces and logos.
Use Percentage for mixed-size inputs
When sources vary, a fixed pixel target crops or pads inconsistently. A percentage keeps every image in proportion to where it started.
Read newDimensions rather than assuming
The output reports both original and new dimensions, which is the fastest way to confirm aspect ratio handling did what you expected.
Match the Output File Name extension to the format
Naming a PNG output with a .jpg extension confuses downstream nodes and any application that opens the file by extension.
Enable Async for large batches
Long-running batches are exactly where a synchronous call risks timing out, and Async keeps the execution from being held open.

速查表

场地价值
ActionResize Image
Input Data TypeBinary Data
Input Binary Fielddata
Output File Nameresize_image_output.jpg
Resize TypePercentage
Resize Percentage50
Width / Height (Specific mode)800 / 600
Maintain Aspect Ratiotrue
Asynctrue
Binary Data Output Namedata

常见问题

Should I resize by percentage or by exact pixel dimensions?+
Use Percentage when the source images vary in size and you want them all reduced or enlarged by the same proportion, for example halving every upload. Use Specific when a target slot demands fixed dimensions, such as a thumbnail grid or a platform that requires an exact width and height.
What happens if I turn off Maintain Aspect Ratio?+
With Maintain Aspect Ratio on, the original proportions are preserved so the image is never stretched. Turning it off lets the width and height you supply be applied independently, which will distort the picture if the target aspect ratio differs from the source. Leave it on unless you specifically need to force non-proportional dimensions.
Does enlarging an image with a percentage above 100 improve its quality?+
No. Scaling above 100 percent increases the pixel dimensions but cannot add detail that was never captured, so an enlarged image will look softer than a natively larger original. Enlarge only when a layout demands the dimensions, and prefer starting from the highest-resolution source you have.
When should I enable Async on the Resize Image node?+
Async Processing runs the resize in the background rather than holding the workflow execution open, which helps with large source images or long batch runs where a synchronous call might otherwise time out.
How do I resize many images in one n8n workflow?+
Feed the images in as multiple items, for example from a folder listing or a Loop Over Items node, and place Resize Image after it. The node runs once per item, so a single configured node handles the whole batch with identical settings rather than needing one node per file.

相关操作

在其他平台上执行相同任务

获取帮助