8
n8n 中文网amn8n.com

使用 APImage 自动替换和重照明任何图像的背景

中级

这是一个Miscellaneous, Multimodal AI领域的自动化工作流,包含 10 个节点。主要使用 FormTrigger, GoogleDrive, HttpRequest 等节点。 使用 APImage 自动替换和重照明任何图像的背景

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "47d295a7329d3547e0e6b56de9e439dc1a0a49c6d827b2320629f54300c47e41"
  },
  "nodes": [
    {
      "id": "15ab6203-2c77-45ac-b5dd-79f404e090fa",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -140
      ],
      "parameters": {
        "width": 1220,
        "height": 300,
        "content": "##  🡫 如何开始"
      },
      "typeVersion": 1
    },
    {
      "id": "8cb25cf6-2de1-4a8a-b39f-dd3d277ef96e",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        920,
        180
      ],
      "parameters": {
        "color": 4,
        "width": 300,
        "height": 1160,
        "content": "### 输出图像"
      },
      "typeVersion": 1
    },
    {
      "id": "1024a4b1-eecb-4fbd-8740-5ce45f238df0",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        180
      ],
      "parameters": {
        "color": 4,
        "width": 280,
        "height": 1160,
        "content": "### 输入图像"
      },
      "typeVersion": 1
    },
    {
      "id": "daaec5d9-342d-4f2f-85d2-0ca1a072dd4c",
      "name": "下载图像",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        700,
        380
      ],
      "parameters": {
        "url": "={{ $json.data.url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "3f76cef0-807e-42e7-9a6f-4d078e86aada",
      "name": "APImage API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        400,
        380
      ],
      "parameters": {
        "url": "https://apimage.org/api/ai-replace-background",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "image_url",
              "value": "={{ $json[\"Image URL\"] }}"
            },
            {
              "name": "background_prompt",
              "value": "={{ $json[\"Background Description\"] }}"
            },
            {
              "name": "preserve_subject",
              "value": "0.8"
            },
            {
              "name": "light_direction",
              "value": "above"
            },
            {
              "name": "light_strength",
              "value": "0.6"
            },
            {
              "name": "output_format",
              "value": "png"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_API_KEY_HERE"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "ad8c0911-3d2b-4acb-ad4c-8b96e556e0d0",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        180
      ],
      "parameters": {
        "color": 4,
        "width": 280,
        "height": 460,
        "content": "### 替换 + 重新打光背景"
      },
      "typeVersion": 1
    },
    {
      "id": "ad068051-dcbe-49f9-8345-f42f1edc754c",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        600,
        180
      ],
      "parameters": {
        "color": 4,
        "width": 300,
        "height": 460,
        "content": "### 下载图像"
      },
      "typeVersion": 1
    },
    {
      "id": "07ef7110-3d9e-4773-96f2-6f6c2143a012",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        660
      ],
      "parameters": {
        "width": 600,
        "height": 680,
        "content": "### 常见问题"
      },
      "typeVersion": 1
    },
    {
      "id": "3d8afd28-2752-4145-bfdf-29c64e59af3b",
      "name": "替换背景(节点可替换)",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        80,
        380
      ],
      "webhookId": "b7487db2-4581-4fd6-b4e0-afac3d8466fb",
      "parameters": {
        "options": {},
        "formTitle": "APImage Replace Background",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Image URL",
              "placeholder": "https://example.com/product-image.png",
              "requiredField": true
            },
            {
              "fieldLabel": "Background Description",
              "placeholder": "a modern office with natural lighting",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Replaces the background of images"
      },
      "typeVersion": 2.2
    },
    {
      "id": "2f066144-49d7-4f26-8278-fc778e4f37d4",
      "name": "存储输出图像(节点可替换)",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1020,
        380
      ],
      "parameters": {
        "name": "data",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        }
      },
      "typeVersion": 3
    }
  ],
  "pinData": {},
  "connections": {
    "APImage API": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Image": {
      "main": [
        [
          {
            "node": "Store the output image (node can be exchanged)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replace Background (node can be exchanged)": {
      "main": [
        [
          {
            "node": "APImage API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 杂项, 多模态 AI

需要付费吗?

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

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

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

作者
Gegenfeld

Gegenfeld

@gegenfeld

We at Gegenfeld are an EdTech platform dedicated to delivering high-quality on-demand courses and interactive training sessions for professional development at all skill levels. With our commitment to "Accelerate your future," we empower professionals to enhance their expertise through engaging, industry-focused learning experiences. On n8n, we share some of the workflows used in our interactive training to provide deeper insights and practical applications.

外部链接
在 n8n.io 查看

分享此工作流