8
n8n 中文网amn8n.com

使用AI将产品照片转换为营销图片

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 12 个节点。主要使用 Set, Code, Form, FormTrigger, HttpRequest 等节点。 使用 Google Gemini AI 将产品图片转换为营销广告

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "LXRZnDfPCKjD6FT8",
  "meta": {
    "instanceId": "8e5c0196cd9c25c3b614ccc37109266dd4ae7fef2aa858eab9011bdc62218bf1",
    "templateCredsSetupCompleted": true
  },
  "name": "使用AI将产品照片转换为营销图片",
  "tags": [
    {
      "id": "sBLDO4c3ubWvhiSj",
      "name": "n8n creator",
      "createdAt": "2025-09-30T20:55:34.201Z",
      "updatedAt": "2025-09-30T20:55:34.201Z"
    }
  ],
  "nodes": [
    {
      "id": "becdfdad-82d2-4294-a282-adcb434c7c45",
      "name": "提取图像数据",
      "type": "n8n-nodes-base.set",
      "position": [
        2720,
        784
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d83a18ad-f0dd-4088-b4d4-4109882c17c6",
              "name": "data",
              "type": "string",
              "value": "={{ $json.choices[0].message.images[0].image_url.url }}"
            },
            {
              "id": "16aac0e1-9be2-4f1a-85f7-751bf370fb5c",
              "name": "base",
              "type": "string",
              "value": "={{ $json.choices[0].message.images[0].image_url.url.split(\",\")[1] }}"
            },
            {
              "id": "eed882fe-7e1a-4914-82c2-5acb0139f71a",
              "name": "content",
              "type": "string",
              "value": "={{ $json.choices[0].message.content }}"
            },
            {
              "id": "1c01e6fb-4bc5-429d-bca1-71fa08a3dd08",
              "name": "mime",
              "type": "string",
              "value": "={{ $json.choices[0].message.images[0].image_url.url.split(\",\")[0].split(':')[1]}}"
            },
            {
              "id": "0c206e48-63ca-4018-8515-230dda633beb",
              "name": "fileNme",
              "type": "string",
              "value": ".png"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "acd06b17-48d1-4813-b7c5-492b2018ae48",
      "name": "转换为可下载文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        2928,
        784
      ],
      "parameters": {
        "options": {},
        "operation": "toBinary",
        "sourceProperty": "base"
      },
      "typeVersion": 1.1
    },
    {
      "id": "3059e6a8-4370-4383-a3ac-59c2bb942fee",
      "name": "下载营销图片",
      "type": "n8n-nodes-base.form",
      "position": [
        3136,
        784
      ],
      "webhookId": "5bf16605-997b-4b9e-a812-9853fd88edb1",
      "parameters": {
        "options": {},
        "operation": "completion",
        "respondWith": "returnBinary",
        "completionTitle": "Your Marketing Image is Ready!",
        "completionMessage": "Your AI-generated marketing image will automatically download to your device. Use it in your ads, social media, or product listings!"
      },
      "typeVersion": 1
    },
    {
      "id": "028dd4ee-c286-4c9b-8976-5462609e1bbd",
      "name": "上传说明",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        496
      ],
      "parameters": {
        "color": 4,
        "width": 280,
        "height": 265,
        "content": "## 📤 步骤1:上传您的产品照片"
      },
      "typeVersion": 1
    },
    {
      "id": "1f8fa60f-9bbf-45b2-a871-0fa4891b1e5b",
      "name": "AI营销图片生成器",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2528,
        784
      ],
      "parameters": {
        "url": "https://openrouter.ai/api/v1/chat/completions",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"google/gemini-2.5-flash-image-preview\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"type\": \"text\",\n          \"text\": \"Transform this product image into a professional marketing photograph. Create a scene that includes: 1) A professional model naturally showcasing or using the product, 2) An aesthetically pleasing background that complements the product's style and target market, 3) Professional lighting and composition, 4) Strategic placement highlighting the product's key features, 5) A lifestyle context that helps potential customers envision using the product. The final image should look like a high-end advertisement suitable for e-commerce, social media, or print campaigns.\"\n        },\n        {\n          \"type\": \"image_url\",\n          \"image_url\": {\n            \"url\": \"{{ $json.url }}\"\n          }\n        }\n      ]\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openRouterApi"
      },
      "credentials": {
        "openRouterApi": {
          "id": "zFZq5RDpNbZ0ghSe",
          "name": "new_key"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4fef9c13-dd77-45d9-bbe7-c520c7bd0645",
      "name": "工作流文档",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        496,
        496
      ],
      "parameters": {
        "color": 5,
        "width": 636,
        "height": 1106,
        "content": "## 使用AI将产品照片转换为营销图片"
      },
      "typeVersion": 1
    },
    {
      "id": "b02395b9-960a-404e-b680-d44366f39e05",
      "name": "上传产品图片",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        1872,
        784
      ],
      "webhookId": "79ece969-c2c6-41a7-b1a9-90fb5d96a4be",
      "parameters": {
        "options": {},
        "formTitle": "Product Photo to Marketing Image",
        "formFields": {
          "values": [
            {
              "fieldType": "file",
              "fieldLabel": "Product Image",
              "multipleFiles": false,
              "requiredField": true,
              "acceptFileTypes": "jpg,png"
            }
          ]
        },
        "formDescription": "Upload your product photo and get a professional marketing image in seconds!"
      },
      "typeVersion": 2.2
    },
    {
      "id": "d3aa7fa1-4a98-47c2-8b4e-32b57e858590",
      "name": "将图像转换为 Base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2096,
        784
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery",
        "binaryPropertyName": "Image"
      },
      "typeVersion": 1
    },
    {
      "id": "5a8b957c-768a-4a35-a9b1-58fc62ac80d0",
      "name": "为AI格式化图片URL",
      "type": "n8n-nodes-base.code",
      "position": [
        2304,
        784
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst updatedItems = items.map((item) => {\n  const base64Url = item?.json?.data;\n  const url = `data:image/png;base64,${base64Url}`;\n  return { url };\n});\nreturn updatedItems;"
      },
      "typeVersion": 2
    },
    {
      "id": "493b0000-6d23-42c9-b3c2-df6ca73f21e1",
      "name": "AI生成信息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2416,
        480
      ],
      "parameters": {
        "color": 4,
        "width": 280,
        "height": 269,
        "content": "## 🤖 步骤2:AI生成"
      },
      "typeVersion": 1
    },
    {
      "id": "6bd383f9-3f47-461b-b49e-3320c8e5cdb1",
      "name": "下载信息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2832,
        560
      ],
      "parameters": {
        "color": 4,
        "width": 280,
        "height": 197,
        "content": "## 💾 步骤3:处理与下载"
      },
      "typeVersion": 1
    },
    {
      "id": "c0b3b857-bd0e-49e0-a5c5-eee13a4e4dce",
      "name": "设置指南",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1184,
        496
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 615,
        "content": "## 🔧 快速设置指南"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0ad0ebec-1df3-4337-bfde-a92b49278b62",
  "connections": {
    "Extract Image Data": {
      "main": [
        [
          {
            "node": "Convert to Downloadable File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Product Image": {
      "main": [
        [
          {
            "node": "Convert Image to Base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Image to Base64": {
      "main": [
        [
          {
            "node": "Format Image URL for AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Image URL for AI": {
      "main": [
        [
          {
            "node": "AI Marketing Image Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Marketing Image Generator": {
      "main": [
        [
          {
            "node": "Extract Image Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to Downloadable File": {
      "main": [
        [
          {
            "node": "Download Marketing Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 内容创作, 多模态 AI

需要付费吗?

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

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

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

作者
Biznova

Biznova

@biznova

Automating your biz, one workflow at a time. I build and share powerful n8n workflows to save you hours and boost productivity. All workflows are completely free. Streamline your operations with no-code.

外部链接
在 n8n.io 查看

分享此工作流