使用 n8n 和 Gemini AI 图像编辑拼接分离图像
高级
这是一个Design, AI, Marketing领域的自动化工作流,包含 20 个节点。主要使用 Set, Merge, Aggregate, GoogleDrive, HttpRequest 等节点,结合人工智能技术实现智能自动化。 使用 n8n 和 Gemini AI 图像编辑拼接分离图像
前置要求
- •Google Drive API 凭证
- •可能需要目标 API 的认证凭证
使用的节点 (20)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9"
},
"nodes": [
{
"id": "bd94ff7b-0f66-45f7-bbab-bb2be0406532",
"name": "点击\"执行工作流\"时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-540,
320
],
"parameters": {},
"typeVersion": 1
},
{
"id": "fdd66c07-8168-4f94-8ff5-ba4ceed476a9",
"name": "获取图像内容",
"type": "n8n-nodes-base.set",
"position": [
1400,
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": "e23db650-d0fa-4d87-87ea-3ab2e78292d8",
"name": "上传到 Drive",
"type": "n8n-nodes-base.googleDrive",
"position": [
2020,
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": "0a8bd3f0-a6e9-4862-942c-20ce336ab24e",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1020,
60
],
"parameters": {
"color": 7,
"width": 640,
"height": 460,
"content": "## 2. 使用 Gemini LLM 组合图像"
},
"typeVersion": 1
},
{
"id": "8a87bcea-7b60-46d8-9070-380397d9d0d8",
"name": "转换为文件",
"type": "n8n-nodes-base.convertToFile",
"onError": "continueRegularOutput",
"position": [
1820,
320
],
"parameters": {
"options": {
"mimeType": "={{ $json.mimeType }}"
},
"operation": "toBinary",
"sourceProperty": "image"
},
"typeVersion": 1.1
},
{
"id": "0ea0a3bf-e4fb-4beb-8a02-405602e17558",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1700,
60
],
"parameters": {
"color": 7,
"width": 560,
"height": 460,
"content": "## 3. 上传到 Google Drive"
},
"typeVersion": 1
},
{
"id": "f6f9410f-f3ef-4b7b-88fe-774c30fe4e29",
"name": "从文件提取",
"type": "n8n-nodes-base.extractFromFile",
"position": [
600,
320
],
"parameters": {
"options": {},
"operation": "binaryToPropery"
},
"typeVersion": 1
},
{
"id": "c41e5653-bd37-4b17-9226-e9edf3d58899",
"name": "合并1",
"type": "n8n-nodes-base.merge",
"position": [
380,
320
],
"parameters": {
"numberInputs": 3
},
"typeVersion": 3.2
},
{
"id": "0fe5cc27-e378-4a62-8477-1b666c4dcbe6",
"name": "聚合1",
"type": "n8n-nodes-base.aggregate",
"position": [
820,
320
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData"
},
"typeVersion": 1
},
{
"id": "cd489b5f-0447-4d3e-84d1-a22142d02708",
"name": "角色",
"type": "n8n-nodes-base.httpRequest",
"position": [
-300,
120
],
"parameters": {
"url": "https://res.cloudinary.com/daglih2g8/image/upload/f_auto,q_auto/v1/n8n-workflows/qwitjyhejockuxfvkk5g",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "74e05106-26c0-4d59-adf9-274f2a1ddd7b",
"name": "斑点狗",
"type": "n8n-nodes-base.httpRequest",
"position": [
-180,
320
],
"parameters": {
"url": "https://res.cloudinary.com/daglih2g8/image/upload/f_auto,q_auto/v1/n8n-workflows/gxcc0xnghpbthwt8fpec",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "2bd84982-3984-4c22-a3de-0c871f5bc2ea",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
2300,
60
],
"parameters": {
"width": 480,
"height": 540,
"content": "## 最终输出"
},
"typeVersion": 1
},
{
"id": "4e3155bf-983b-46b4-b6cb-38278edc34fb",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-300,
-180
],
"parameters": {
"width": 220,
"height": 280,
"content": "## 角色"
},
"typeVersion": 1
},
{
"id": "01486147-0ddf-4055-9ebf-5bc6a884852c",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-40,
120
],
"parameters": {
"height": 300,
"content": "## 斑点狗"
},
"typeVersion": 1
},
{
"id": "e2153852-33b3-41dc-adcf-122027ada5a6",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-180,
520
],
"parameters": {
"height": 300,
"content": "## 沙发"
},
"typeVersion": 1
},
{
"id": "510619c4-1e9c-4466-95f1-5eaa72d6ecc5",
"name": "沙发",
"type": "n8n-nodes-base.httpRequest",
"position": [
100,
520
],
"parameters": {
"url": "https://res.cloudinary.com/daglih2g8/image/upload/f_auto,q_auto/v1/n8n-workflows/nyghscauxtcfl4dve6of",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "522cdb05-558c-4bd4-a4af-1a400bc641f9",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
300,
60
],
"parameters": {
"color": 7,
"width": 680,
"height": 460,
"content": "## 1. 将单独图像转换为 Base64 字符串"
},
"typeVersion": 1
},
{
"id": "ce28bdf0-a03e-486c-9dd4-2aeb0896519e",
"name": "便签7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1080,
-220
],
"parameters": {
"width": 460,
"height": 960,
"content": "## 试试看!"
},
"typeVersion": 1
},
{
"id": "086cae2e-3b21-4262-917d-9d9f261d20d6",
"name": "Gemini 图像组合",
"type": "n8n-nodes-base.httpRequest",
"position": [
1180,
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\": \"The character is sitting on the sofa, and the dalmation is lying on the blanket sleeping on the floor. Retain the image style of the character image.\"\n },\n {\n \"inline_data\": {\n \"mime_type\": \"image/png\",\n \"data\": \"{{ $json.data[0].data }}\"\n }\n },\n {\n \"inline_data\": {\n \"mime_type\": \"image/png\",\n \"data\": \"{{ $json.data[1].data }}\"\n }\n },\n {\n \"inline_data\": {\n \"mime_type\": \"image/png\",\n \"data\": \"{{ $json.data[2].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": "48127e5f-441a-4c46-9c96-3953e26ae092",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1080,
760
],
"parameters": {
"color": 5,
"width": 460,
"height": 140,
"content": "### 地理限制!"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Sofa": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 2
}
]
]
},
"Merge1": {
"main": [
[
{
"node": "Extract from File",
"type": "main",
"index": 0
}
]
]
},
"Character": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 0
}
]
]
},
"Dalmation": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 1
}
]
]
},
"Aggregate1": {
"main": [
[
{
"node": "Gemini Image Compose",
"type": "main",
"index": 0
}
]
]
},
"Convert to File": {
"main": [
[
{
"node": "Upload to Drive",
"type": "main",
"index": 0
}
]
]
},
"Extract from File": {
"main": [
[
{
"node": "Aggregate1",
"type": "main",
"index": 0
}
]
]
},
"Get Image Contents": {
"main": [
[
{
"node": "Convert to File",
"type": "main",
"index": 0
}
]
]
},
"Gemini Image Compose": {
"main": [
[
{
"node": "Get Image Contents",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Dalmation",
"type": "main",
"index": 0
},
{
"node": "Sofa",
"type": "main",
"index": 0
},
{
"node": "Character",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 设计, 人工智能, 营销
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
构建基于n8n和Gemini AI图像编辑的图像修复服务
构建基于n8n和Gemini AI图像编辑的图像修复服务
Set
Split Out
Google Drive
+5
17 节点Jimleuk
设计
使用Imagen 3.0生成具有一致视觉风格的徽标和图像
使用Imagen 3.0生成具有一致视觉风格的徽标和图像
If
Set
Form
+8
21 节点Jimleuk
设计
使用AI自动化品牌风格博客创建
使用AI自动化品牌风格博客创建
Set
Html
Limit
+11
27 节点Jimleuk
人工智能
使用 ComfyUI 生成 AI 媒体:图像、视频、3D 和音频桥接
使用 ComfyUI 生成 AI 媒体:图像、视频、3D 和音频桥接
If
Set
Code
+14
51 节点Nielo
设计
(Duc)深度研究市场模板
集成PerplexityAI研究和OpenAI内容的多层级WordPress博客生成器
If
Set
Xml
+28
132 节点Daniel Ng
人工智能
AI驱动的YouTube短视频自动化:使用OpenAI和ElevenLabs创建与发布
AI驱动的YouTube Shorts创建器(OpenAI脚本与ElevenLabs语音)
If
Set
Wait
+15
76 节点WIKIPILOT
设计
工作流信息
难度等级
高级
节点数量20
分类3
节点类型9
作者
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 查看 →
分享此工作流