使用 Google Drive 和 Nano Banana API 的批量证件照转换器和增强器
高级
这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 16 个节点。主要使用 If, Set, Code, Wait, FormTrigger 等节点。 使用 Google Drive 和 Nano Banana API 的批量证件照转换器和增强器
前置要求
- •Google Drive API 凭证
- •可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "1f6e5HSDWrQSzgEt",
"meta": {
"instanceId": "8dc97f110c3d1c4c1312bf2ee1e5a9845338284bdb271e93c73c8939c0887ef7",
"templateCredsSetupCompleted": true
},
"name": "使用 Google Drive 和 Nano Banana API 的批量证件照转换器和增强器",
"tags": [],
"nodes": [
{
"id": "1b27c0b9-2433-45a5-b303-96809323537d",
"name": "获取生成状态",
"type": "n8n-nodes-base.httpRequest",
"position": [
464,
-32
],
"parameters": {
"url": "https://api.defapi.org/api/task/query",
"options": {},
"sendQuery": true,
"sendHeaders": true,
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"queryParameters": {
"parameters": [
{
"name": "task_id",
"value": "={{$json.data.task_id}}"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"credentials": {
"httpBearerAuth": {
"id": "uZqL4UNyrG73Kntx",
"name": "Defapi account"
}
},
"typeVersion": 4.2
},
{
"id": "7b26f227-aaf0-4942-992d-ba03d124ebd7",
"name": "向 Defapi.org API 发送图片生成请求",
"type": "n8n-nodes-base.httpRequest",
"position": [
32,
-32
],
"parameters": {
"url": "https://api.defapi.org/api/image/gen",
"method": "POST",
"options": {},
"jsonBody": "={\n \"prompt\": \"{{$json.prompt}}\",\n \"model\": \"google/nano-banana\",\n \"images\": [\"{{ $json.image }}\"]\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"credentials": {
"httpBearerAuth": {
"id": "uZqL4UNyrG73Kntx",
"name": "Defapi account"
}
},
"typeVersion": 4.2
},
{
"id": "00981a5b-1a3e-49d3-93c5-dd2e204f20e2",
"name": "等待图片处理完成",
"type": "n8n-nodes-base.wait",
"position": [
240,
-32
],
"webhookId": "bb6c2821-9586-44b7-8606-2ee69a77ed75",
"parameters": {
"amount": 10
},
"typeVersion": 1.1
},
{
"id": "9d2169f3-20a1-42a5-bb02-c75a061e8c06",
"name": "检查图片生成是否完成",
"type": "n8n-nodes-base.if",
"position": [
688,
-32
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "db9a5dec-997b-4c3f-9582-37c9bbeb19ff",
"operator": {
"type": "string",
"operation": "notEquals"
},
"leftValue": "={{ $json.data.status }}",
"rightValue": "=pending"
},
{
"id": "9352ce97-6628-4135-a8e3-35af03688d5d",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "",
"rightValue": ""
}
]
},
"looseTypeValidation": true
},
"typeVersion": 2.2
},
{
"id": "1862d1cf-b65e-4839-9947-b70f666bba19",
"name": "格式化并显示图片结果",
"type": "n8n-nodes-base.set",
"position": [
32,
288
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "fa5f375f-cddc-4f7b-a018-67c28015d18b",
"name": "markdown_content",
"type": "string",
"value": "=\n- Generation result: {{$json.data?.status}}\n \n{{$json.data?.result?.[0]?.text}} \n{{$json.data?.status_reason?.message}} \n\n"
},
{
"id": "1d219e61-a59b-4156-b284-42cc42ce6f6d",
"name": "image",
"type": "string",
"value": "={{$json.data?.result?.[0]?.image}}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "6dba5850-1ab2-4ffb-9160-6c780a779dbe",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-192,
464
],
"parameters": {
"color": 4,
"width": 528,
"height": 336,
"content": "## Google Drive 输入目录"
},
"typeVersion": 1
},
{
"id": "59a4c0ca-baad-4378-8ab6-9817f10ddd20",
"name": "搜索文件和文件夹",
"type": "n8n-nodes-base.googleDrive",
"position": [
256,
-384
],
"parameters": {
"filter": {
"folderId": {
"__rl": true,
"mode": "url",
"value": "={{ $json['Google Drive - Input Folder URL'] }}"
}
},
"options": {
"fields": "={{ [\"mimeType\",\"name\",\"id\",\"webViewLink\", \"imageMediaMetadata\", \"webContentLink\", \"thumbnailLink\"] }}"
},
"resource": "fileFolder",
"returnAll": true
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "ECFfMtuxT2HgQvFH",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "682a50fc-7d1d-44b2-993f-02c5bd792541",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-400,
-544
],
"parameters": {
"width": 352,
"height": 320,
"content": "## 如何使用 drive"
},
"typeVersion": 1
},
{
"id": "cf6a8583-dc11-447c-bcd0-6fe365b973af",
"name": "表单提交时",
"type": "n8n-nodes-base.formTrigger",
"position": [
32,
-384
],
"webhookId": "d047f428-e1d7-4b23-bef4-50db362f1d67",
"parameters": {
"options": {},
"formTitle": "Set Google Drive",
"formFields": {
"values": [
{
"fieldLabel": "Google Drive - Input Folder URL",
"requiredField": true
},
{
"fieldLabel": "Google Drive - Output Folder URL",
"requiredField": true
},
{
"fieldType": "textarea",
"fieldLabel": "Prompt",
"placeholder": "Create a professional portrait suitable for ID documentation with proper spacing and composition. Framing: Include the full head, complete shoulder area, and upper torso. Maintain generous margins around the subject without excessive cropping. Outfit: Transform the existing attire into light business-casual clothing appropriate for the individual's demographics and modern style standards. Ensure the replacement garment appears natural, properly tailored, and complements the subject's overall presentation (such as professional shirt, refined blouse, contemporary blazer, or sophisticated layered separates). Pose & Gaze: Position shoulders square to the camera, maintaining perfect frontal alignment. Direct the gaze straight ahead into the lens at identical eye height, avoiding any angular deviation in vertical or horizontal planes. Expression: Display a professional neutral demeanor or subtle closed-lip smile that conveys confidence and authenticity. Background: Utilize a solid, consistent light gray photographic background (color code: #d9d9d9) without any pattern, texture, or tonal variation. Lighting & Quality: Apply balanced studio-quality illumination eliminating harsh contrast or reflective artifacts. Deliver maximum resolution imagery with precise focus and accurate natural skin color reproduction."
}
]
}
},
"typeVersion": 2.3
},
{
"id": "0af17c30-f6fa-49f4-a9f1-44ebb337fe9f",
"name": "JavaScript代码",
"type": "n8n-nodes-base.code",
"position": [
480,
-384
],
"parameters": {
"jsCode": "/**\n * Encodes multiple binary files from an n8n input item into Base64 strings.\n *\n * This code assumes it is running in an n8n \"Code\" or \"Function\" node\n * where 'this' refers to the node's context and 'helpers' are available.\n *\n * @returns {object} An object containing an array of file objects,\n * each with a 'path' and 'data' (Base64 string).\n */\nconst results = [];\n\nconsole.log('---- x', $input.all())\n\nfor (const item of $input.all()) {\n const result = {}\n result.prompt = $('On form submission').first().json.Prompt || $(\"On form submission\").params.formFields.values[2].placeholder\n result.image = item.json.webContentLink\n result.name = item.json.name\n results.push(result)\n}\n\n\n\n// Return the final object in the expected format for the next node.\nreturn results;\n"
},
"typeVersion": 2
},
{
"id": "84851efc-02db-4557-8aeb-4a5eb01f2fa4",
"name": "上传文件",
"type": "n8n-nodes-base.googleDrive",
"position": [
480,
288
],
"parameters": {
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "url",
"value": "={{ $('On form submission').item.json['Google Drive - Output Folder URL'] }}"
}
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "ECFfMtuxT2HgQvFH",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "7d7326d2-f6e9-4b53-b2e9-896fc2fa88a0",
"name": "HTTP请求",
"type": "n8n-nodes-base.httpRequest",
"position": [
256,
288
],
"parameters": {
"url": "={{ $json.image }}",
"options": {
"response": {
"response": {
"responseFormat": "file"
}
}
}
},
"typeVersion": 4.2
},
{
"id": "c758902f-a550-4ba7-a94c-72e7cc798233",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
336,
464
],
"parameters": {
"color": 4,
"width": 528,
"height": 336,
"content": "## Google Drive 输出目录"
},
"typeVersion": 1
},
{
"id": "e66266e6-b49c-43b5-abfa-04fef281d549",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-32,
-544
],
"parameters": {
"width": 672,
"height": 320,
"content": "## 从 Google Drive 输入目录加载图片"
},
"typeVersion": 1
},
{
"id": "a012c005-137a-4108-86c1-321a12af4a5e",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
-176
],
"parameters": {
"width": 880,
"height": 288,
"content": "## 发送图片到 Nano Banana API(Defapi.org)"
},
"typeVersion": 1
},
{
"id": "1bf5927f-d8d6-4b61-adac-b3868bccdd84",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
160
],
"parameters": {
"width": 880,
"height": 288,
"content": "## 下载图片并上传到 Google Drive"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "92598834-25e9-447c-9eac-6134da030888",
"connections": {
"HTTP Request": {
"main": [
[
{
"node": "Upload file",
"type": "main",
"index": 0
}
]
]
},
"Code in JavaScript": {
"main": [
[
{
"node": "Send Image Generation Request to Defapi.org API",
"type": "main",
"index": 0
}
]
]
},
"On form submission": {
"main": [
[
{
"node": "Search files and folders",
"type": "main",
"index": 0
}
]
]
},
"Search files and folders": {
"main": [
[
{
"node": "Code in JavaScript",
"type": "main",
"index": 0
}
]
]
},
"Obtain the generated status": {
"main": [
[
{
"node": "Check if Image Generation is Complete",
"type": "main",
"index": 0
}
]
]
},
"Format and Display Image Results": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"Wait for Image Processing Completion": {
"main": [
[
{
"node": "Obtain the generated status",
"type": "main",
"index": 0
}
]
]
},
"Check if Image Generation is Complete": {
"main": [
[
{
"node": "Format and Display Image Results",
"type": "main",
"index": 0
}
],
[
{
"node": "Wait for Image Processing Completion",
"type": "main",
"index": 0
}
]
]
},
"Send Image Generation Request to Defapi.org API": {
"main": [
[
{
"node": "Wait for Image Processing Completion",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 内容创作, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用Sora 2 API生成病毒视频
使用Sora 2 AI为营销和内容创作创建社交媒体视频
If
Set
Code
+4
11 节点panyanyany
内容创作
## 设置指南
使用 Gemini AI 生成复古宝丽来风格照片
If
Set
Code
+4
13 节点panyanyany
内容创作
WordPress博客自动化专业版(深度研究)v2.1市场
使用GPT-4o、Perplexity AI和多语言支持自动化SEO优化的博客创建
If
Set
Xml
+27
125 节点Daniel Ng
内容创作
从您的多个参考图像生成视频片段
使用 Fal.ai VIDU 从参考图像创建病毒式视频并上传到 YouTube/TikTok
If
Set
Code
+6
20 节点Davide
内容创作
使用Nano Banana AI将自拍转换为3D手办
使用Nano Banana AI将自拍转换为3D手办
If
Set
Code
+4
11 节点panyanyany
杂项
Recap AI - Veo 3.1 电商产品动画生成器
基于Veo 3.1的电商产品目录AI视频生成器
If
Set
Wait
+10
18 节点Lucas Walter
内容创作