构建基于n8n和Gemini AI图像编辑的图像修复服务
高级
这是一个Design, AI领域的自动化工作流,包含 17 个节点。主要使用 Set, SplitOut, GoogleDrive, HttpRequest, ConvertToFile 等节点,结合人工智能技术实现智能自动化。 构建基于n8n和Gemini AI图像编辑的图像修复服务
前置要求
- •Google Drive API 凭证
- •可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "b6a5c37d-b845-4fd2-8ea3-db23aed99286",
"name": "当点击\"执行工作流\"时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-80,
320
],
"parameters": {},
"typeVersion": 1
},
{
"id": "1f363fc5-42cf-4e9c-ae74-496030362ed9",
"name": "示例图像",
"type": "n8n-nodes-base.set",
"position": [
120,
320
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "7196d08d-dff6-48e4-a06d-0ec863a4dff3",
"name": "url",
"type": "array",
"value": "={{\n[\n \"https://res.cloudinary.com/daglih2g8/image/upload/f_auto,q_auto/v1/n8n-workflows/l8b3j1sf6ejx73z0awsh\",\n \"https://res.cloudinary.com/daglih2g8/image/upload/f_auto,q_auto/v1/n8n-workflows/htrjbmiozdrvxwdsreyt\",\n \"https://res.cloudinary.com/daglih2g8/image/upload/f_auto,q_auto/v1/n8n-workflows/ykftgxpozp2pr4sxpuoy\"\n]\n}}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "e078aba0-2f2b-47b5-90b2-c457184e6237",
"name": "拆分输出",
"type": "n8n-nodes-base.splitOut",
"position": [
320,
320
],
"parameters": {
"options": {},
"fieldToSplitOut": "url"
},
"typeVersion": 1
},
{
"id": "a0fbf72b-d079-4777-be06-531e0e131857",
"name": "下载图片",
"type": "n8n-nodes-base.httpRequest",
"position": [
520,
320
],
"parameters": {
"url": "={{ $json.url }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "77f0d0c7-e6bd-4f15-beff-9cb53446fcb0",
"name": "Gemini 图像修复",
"type": "n8n-nodes-base.httpRequest",
"position": [
1100,
320
],
"parameters": {
"url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-preview-image-generation:generateContent",
"method": "POST",
"options": {},
"jsonBody": "={\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"You are an vintage image restoration agent. Restore the given image by removing cracks and tears and fill in missing sections of the image. Retain the dimensions, colors and camera film type of the original image.\"\n },\n {\n \"inline_data\": {\n \"mime_type\": \"{{ $('Download Image').item.binary.data.mimeType }}\",\n \"data\": \"{{ $json.data }}\"\n }\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"responseModalities\": [\n \"TEXT\",\n \"IMAGE\"\n ]\n }\n}",
"sendBody": true,
"specifyBody": "json",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "googlePalmApi"
},
"credentials": {
"googlePalmApi": {
"id": "dSxo6ns5wn658r8N",
"name": "Google Gemini(PaLM) Api account"
}
},
"typeVersion": 4.2
},
{
"id": "6aebcc29-a65d-4cb9-8d6a-56f24b58c7f5",
"name": "从文件提取",
"type": "n8n-nodes-base.extractFromFile",
"position": [
720,
320
],
"parameters": {
"options": {},
"operation": "binaryToPropery"
},
"typeVersion": 1
},
{
"id": "1c50d319-1771-408f-9015-f04bb6a3d305",
"name": "获取图像内容",
"type": "n8n-nodes-base.set",
"position": [
1340,
320
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "021aad70-de11-4387-844e-7e7dfd3b1044",
"name": "image",
"type": "string",
"value": "={{ $json.candidates[0].content.parts.find(part => part.inlineData).inlineData.data }}"
},
{
"id": "62877ef7-2057-4d35-a44b-1d58fa1f1769",
"name": "mimeType",
"type": "string",
"value": "={{ $json.candidates[0].content.parts.find(part => part.inlineData).inlineData.mimeType }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "c19074f0-45a1-42bd-b25f-966f26ef5ef5",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
2220,
-200
],
"parameters": {
"width": 700,
"height": 320,
"content": "|原始|修复后|"
},
"typeVersion": 1
},
{
"id": "82e82d53-e5ff-44a2-96ca-1867058fbb65",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-140,
80
],
"parameters": {
"color": 7,
"width": 1060,
"height": 460,
"content": "## 1. 下载示例图像"
},
"typeVersion": 1
},
{
"id": "eb1f70d5-2d3f-4f22-badb-d49569f565c2",
"name": "上传到Google Drive",
"type": "n8n-nodes-base.googleDrive",
"position": [
1960,
320
],
"parameters": {
"name": "=file_restored_{{ $itemIndex }}.{{ $binary.data.fileExtension }}",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "root",
"cachedResultName": "/ (Root folder)"
}
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "yOwz41gMQclOadgu",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "4f980d9d-a993-4ec6-80fd-1a323e40822d",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
960,
80
],
"parameters": {
"color": 7,
"width": 620,
"height": 460,
"content": "## 2. 使用 Gemini LLM 修复损坏的图像"
},
"typeVersion": 1
},
{
"id": "69f7f355-5443-4265-b2a1-901711fa93dd",
"name": "转换为文件",
"type": "n8n-nodes-base.convertToFile",
"onError": "continueRegularOutput",
"position": [
1720,
320
],
"parameters": {
"options": {
"mimeType": "={{ $json.mimeType }}"
},
"operation": "toBinary",
"sourceProperty": "image"
},
"typeVersion": 1.1
},
{
"id": "beae9111-8186-4afd-9fa6-c732f0229854",
"name": "便签 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1620,
80
],
"parameters": {
"color": 7,
"width": 560,
"height": 460,
"content": "## 3. 上传到 Google Drive"
},
"typeVersion": 1
},
{
"id": "00aaa458-1c49-4adf-87d6-ea70309107f9",
"name": "便签 4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-640,
-380
],
"parameters": {
"width": 460,
"height": 920,
"content": "## 试试看!"
},
"typeVersion": 1
},
{
"id": "4e4b822b-983b-48d2-a319-68242b7af171",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-640,
580
],
"parameters": {
"color": 5,
"width": 460,
"height": 140,
"content": "### 地理限制!"
},
"typeVersion": 1
},
{
"id": "24d74843-d9b5-4302-8136-159e0a7dd492",
"name": "便签 5",
"type": "n8n-nodes-base.stickyNote",
"position": [
2220,
140
],
"parameters": {
"width": 400,
"height": 440,
"content": "|原始|修复后|"
},
"typeVersion": 1
},
{
"id": "f77ed90e-70ca-4268-9c77-17e49f94a4bb",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
2640,
140
],
"parameters": {
"width": 580,
"height": 300,
"content": "|原始|修复后|"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Split Out": {
"main": [
[
{
"node": "Download Image",
"type": "main",
"index": 0
}
]
]
},
"Sample Images": {
"main": [
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
},
"Download Image": {
"main": [
[
{
"node": "Extract from File",
"type": "main",
"index": 0
}
]
]
},
"Convert to File": {
"main": [
[
{
"node": "Upload to Drive",
"type": "main",
"index": 0
}
]
]
},
"Extract from File": {
"main": [
[
{
"node": "Gemini Image Restoration",
"type": "main",
"index": 0
}
]
]
},
"Get Image Contents": {
"main": [
[
{
"node": "Convert to File",
"type": "main",
"index": 0
}
]
]
},
"Gemini Image Restoration": {
"main": [
[
{
"node": "Get Image Contents",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Sample Images",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 设计, 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用 n8n 和 Gemini AI 图像编辑拼接分离图像
使用 n8n 和 Gemini AI 图像编辑拼接分离图像
Set
Merge
Aggregate
+6
20 节点Jimleuk
设计
使用Imagen 3.0生成具有一致视觉风格的徽标和图像
使用Imagen 3.0生成具有一致视觉风格的徽标和图像
If
Set
Form
+8
21 节点Jimleuk
设计
使用Qdrant、Mistral.ai和OpenAI构建税法助手
使用Qdrant、Mistral.ai和OpenAI构建税法助手
Set
Wait
Filter
+18
38 节点Jimleuk
财务
使用CloudFlare Markdown转换从Excel中提取大学学期日期
使用CloudFlare Markdown转换从Excel中提取大学学期日期
Set
Code
Sort
+8
18 节点Jimleuk
人工智能
模板演示-chatgpt-图片-1-带-drive-和-sheet副本
使用GPT-image-1生成图像并存储到Google Drive,包含成本跟踪
Set
Split Out
Aggregate
+8
16 节点darrell_tw
设计
基于动态提示与Airtable的AI数据提取
通过动态提示与Airtable实现AI数据提取
Set
Code
Filter
+11
51 节点Jimleuk
人工智能
工作流信息
难度等级
高级
节点数量17
分类2
节点类型8
作者
Jimleuk
@jimleukFreelance consultant based in the UK specialising in AI-powered automations. I work with select clients tackling their most challenging projects. For business enquiries, send me an email at hello@jimle.uk LinkedIn: https://www.linkedin.com/in/jimleuk/ X/Twitter: https://x.com/jimle_uk
外部链接
在 n8n.io 查看 →
分享此工作流