8
n8n 中文网amn8n.com

照片背景去除自动化

中级

这是一个Design, AI领域的自动化工作流,包含 12 个节点。主要使用 GoogleDrive, HttpRequest, SplitInBatches, ScheduleTrigger 等节点,结合人工智能技术实现智能自动化。 通过Photoroom API和Google Drive自动化照片背景去除

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "b2441a46-bd10-4c0c-a804-3be138d2fd8e",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -460,
        220
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "c98d1021-81f1-43e9-8001-8708a16c5fdc",
      "name": "遍历项目1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -440,
        860
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "d6b4b139-1751-4e53-8bd3-e86d0b427301",
      "name": "移动到原始",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        260,
        880
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": "Original"
        },
        "operation": "move"
      },
      "typeVersion": 3
    },
    {
      "id": "0be7ea89-f48b-4844-ad2a-29b7e23e0fd2",
      "name": "保存到移除背景",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        220,
        300
      ],
      "parameters": {
        "name": "={{ $json.name }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": "Remove Background"
        },
        "inputDataFieldName": "result-sandbox-mode.png"
      },
      "notesInFlow": true,
      "typeVersion": 3
    },
    {
      "id": "73369386-e3c9-452d-a89f-6bf66072d002",
      "name": "下载图像",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -220,
        300
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "notesInFlow": true,
      "typeVersion": 3
    },
    {
      "id": "b127c813-9ae3-48d2-85da-36d2db1c6e63",
      "name": "获取所有文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -800,
        220
      ],
      "parameters": {
        "filter": {
          "folderId": {
            "__rl": true,
            "mode": "list",
            "value": "1j1wl00y4RAsRRecU74XxR6SpncYxMqdA",
            "cachedResultUrl": "",
            "cachedResultName": ""
          },
          "whatToSearch": "files"
        },
        "options": {},
        "resource": "fileFolder"
      },
      "typeVersion": 3
    },
    {
      "id": "c3546db3-2a28-4f98-87bd-1556c8ee3e8c",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1260,
        -120
      ],
      "parameters": {
        "color": 7,
        "width": 600,
        "height": 560,
        "content": "### 1. 收集所有原始图像文件名"
      },
      "typeVersion": 1
    },
    {
      "id": "18181d47-99e1-4ec6-9f0c-4e46c5f42315",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -520,
        -120
      ],
      "parameters": {
        "color": 7,
        "width": 1000,
        "height": 620,
        "content": "### 2. 使用 Photoroom API 移除背景并将结果保存在子文件夹 **Remove Background** 中"
      },
      "typeVersion": 1
    },
    {
      "id": "91ffb1ae-3a55-460b-8d29-6f28ae33c83d",
      "name": "Photoroom API 移除背景",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        0,
        300
      ],
      "parameters": {
        "url": "https://image-api.photoroom.com/v2/edit",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file",
              "outputPropertyName": "result-sandbox-mode.png"
            }
          }
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "shadow.mode",
              "value": "ai.soft"
            },
            {
              "name": "background.color",
              "value": "FFFFFF"
            },
            {
              "name": "padding",
              "value": "0.1"
            },
            {
              "name": "imageFile",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "image/png, application/json"
            },
            {
              "name": "x-api-key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "5c99a353-1a07-400e-996a-fbd83c735dce",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -520,
        540
      ],
      "parameters": {
        "color": 7,
        "width": 1000,
        "height": 560,
        "content": "### 3. 移动已处理的图像"
      },
      "typeVersion": 1
    },
    {
      "id": "3a7e0bcd-eb5a-4609-9359-8e632cace6d3",
      "name": "每天上午 08:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1020,
        220
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8281445b-9cf1-4e43-8a19-9e3b26b8d67e",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        -120
      ],
      "parameters": {
        "width": 660,
        "height": 460,
        "content": "### [📺完整教程](https://www.youtube.com/watch?v=gBn9wd0fJ54)"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Get all files": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          },
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Image": {
      "main": [
        [
          {
            "node": "Photoroom API Remove Background",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [],
        [
          {
            "node": "Move to Original",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Move to Original": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily at 08:00 am": {
      "main": [
        [
          {
            "node": "Get all files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Remove Background": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Photoroom API Remove Background": {
      "main": [
        [
          {
            "node": "Save to Remove Background",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 设计, 人工智能

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量12
分类2
节点类型5
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Samir Saci

Samir Saci

@samirsaci

Automation, AI and Analytics for Supply Chain & Business Optimization Helping businesses streamline operations using n8n, AI agents, and data science to enhance efficiency and sustainability. Linkedin: www.linkedin.com/in/samir-saci

外部链接
在 n8n.io 查看

分享此工作流