8
n8n 中文网amn8n.com

将普通图片转换为惊艳照片和视频

高级

这是一个Design, AI, Marketing领域的自动化工作流,包含 20 个节点。主要使用 Wait, Telegram, HttpRequest, ConvertToFile, TelegramTrigger 等节点,结合人工智能技术实现智能自动化。 将普通图片转换为惊艳照片和视频

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "e5aa7986ab694604988fd614f16d3dd8cb275c306d75d6a818e14c909713473c"
  },
  "nodes": [
    {
      "id": "0db7b2f0-dfb2-4c92-98c8-d5eb27ca54f3",
      "name": "Telegram Bot Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -280,
        380
      ],
      "webhookId": "ab3c5adb-2300-4fcc-9d5c-7402e7456415",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {
          "download": true
        }
      },
      "description": "Listens for incoming messages with images from a Telegram bot",
      "typeVersion": 1.2
    },
    {
      "id": "434d739e-54d7-4f75-955f-e1181ff23db8",
      "name": "工作流开始文档",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -380,
        -20
      ],
      "parameters": {
        "width": 400,
        "height": 560,
        "content": "## 📱 Telegram 消息触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "dc5ddb08-76b8-4a1f-a2fb-315c64199157",
      "name": "工作流概览",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1000,
        -220
      ],
      "parameters": {
        "color": 3,
        "width": 400,
        "height": 560,
        "content": "## 🖼️ 图像处理流水线"
      },
      "typeVersion": 1
    },
    {
      "id": "b4682f5b-4c6e-4ba0-a40b-c2851c64bfef",
      "name": "OpenAI API 文档",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        60,
        -240
      ],
      "parameters": {
        "color": 3,
        "width": 340,
        "height": 680,
        "content": "## 🎨 OpenAI 图像编辑 API"
      },
      "typeVersion": 1
    },
    {
      "id": "a7266711-bee5-40a2-afc2-86affd226abc",
      "name": "转换文档",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        460,
        -120
      ],
      "parameters": {
        "color": 4,
        "width": 380,
        "height": 580,
        "content": "## 📤 文件格式转换"
      },
      "typeVersion": 1
    },
    {
      "id": "f651bd6f-dc2f-4d60-b896-2c860ef0673f",
      "name": "编辑图像 (OpenAI)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        160,
        280
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/images/edits",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "image",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            },
            {
              "name": "prompt",
              "value": "={{ $json.message.caption }}"
            },
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "n",
              "value": "1"
            },
            {
              "name": "size",
              "value": "1024x1024"
            },
            {
              "name": "quality",
              "value": "low"
            }
          ]
        },
        "nodeCredentialType": "openAiApi"
      },
      "credentials": {
        "openAiApi": {
          "id": "10eOcgAxufRENylm",
          "name": "OpenAi account"
        }
      },
      "description": "Sends image to OpenAI for AI-powered editing based on the caption",
      "typeVersion": 4.2
    },
    {
      "id": "8e50ff8a-6c4b-486e-9307-9624fc7ff274",
      "name": "转换为二进制图像",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        580,
        280
      ],
      "parameters": {
        "options": {
          "fileName": "edited_image.png",
          "mimeType": "image/png"
        },
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json"
      },
      "description": "Converts base64 encoded image to binary format for sending",
      "typeVersion": 1.1
    },
    {
      "id": "e8096804-b5a7-4f2f-943b-e4a5db0929fb",
      "name": "发送编辑后的图像",
      "type": "n8n-nodes-base.telegram",
      "position": [
        880,
        740
      ],
      "webhookId": "6d8b80b6-8450-49c9-98dc-0f34e14da588",
      "parameters": {
        "chatId": "={{ $json.message.chat.id }}",
        "operation": "sendPhoto",
        "binaryData": true,
        "additionalFields": {
          "caption": "Here's your edited image! ✨"
        }
      },
      "description": "Sends the edited image back to the user via Telegram",
      "typeVersion": 1.2
    },
    {
      "id": "d33a7637-4046-40a9-90e6-6d8b8fc2f4b6",
      "name": "Replicate 文档",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1460,
        120
      ],
      "parameters": {
        "color": 2,
        "width": 400,
        "height": 700,
        "content": "## 🧠 Replicate AI 图像生成"
      },
      "typeVersion": 1
    },
    {
      "id": "d0894342-ab6a-473c-9ad0-667987801a9f",
      "name": "等待节点文档",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2000,
        180
      ],
      "parameters": {
        "color": 6,
        "width": 280,
        "height": 600,
        "content": "## ⏱️ 轮询机制"
      },
      "typeVersion": 1
    },
    {
      "id": "5f0417a3-7682-481c-b642-c2b45142839e",
      "name": "文件检索文档",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        -40
      ],
      "parameters": {
        "color": 5,
        "width": 340,
        "height": 560,
        "content": "## 📡 文件检索系统"
      },
      "typeVersion": 1
    },
    {
      "id": "906ba4d2-445c-477f-8732-be7e9d828ba0",
      "name": "生成变体 (Replicate)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1620,
        640
      ],
      "parameters": {
        "url": "https://api.replicate.com/v1/models/pixverse/pixverse-v4/predictions",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"input\": {\n    \"prompt\": \"{{ $json.message.caption || 'a creative enhancement of this image' }}\",\n    \"quality\": \"720p\",\n    \"image\": \"https://api.telegram.org/file/bot{{$credentials.telegramBot.botToken}}/{{ $json.result.file_path }}\"\n}}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$credentials.replicateApi.apiKey}}"
            }
          ]
        }
      },
      "description": "Sends the original image to Replicate for AI-powered variation",
      "typeVersion": 4.2
    },
    {
      "id": "ab244f36-31e3-4dea-9c8e-e4935335810a",
      "name": "检索生成的图像",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2540,
        840
      ],
      "parameters": {
        "url": "={{ $json.urls.get }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$credentials.replicateApi.apiKey}}"
            }
          ]
        }
      },
      "description": "Gets the final generated image from Replicate after processing",
      "typeVersion": 4.2
    },
    {
      "id": "fee42f2b-09d2-47f9-842a-52139e8c8de6",
      "name": "发送变体图像",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2740,
        280
      ],
      "webhookId": "c2af49c2-2c87-4020-928a-ce18f14e557f",
      "parameters": {
        "file": "={{ $json.output }}",
        "chatId": "={{ $json.message.chat.id }}",
        "operation": "sendDocument",
        "additionalFields": {
          "caption": "Here's an AI-generated variation of your image! 🚀"
        }
      },
      "description": "Sends the AI-generated variation back to the user",
      "typeVersion": 1.2
    },
    {
      "id": "93c43617-3c40-451f-b3b5-eb1d276db1ba",
      "name": "获取文件路径",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1220,
        340
      ],
      "parameters": {
        "url": "https://api.telegram.org/bot{{$credentials.telegramBot.botToken}}/getFile",
        "options": {},
        "jsonBody": "={\n  \"file_id\": \"{{ $json.result.photo[0].file_id }}\"\n}\n",
        "sendBody": true,
        "specifyBody": "json"
      },
      "description": "Retrieves the file path from Telegram's servers",
      "typeVersion": 4.2
    },
    {
      "id": "71391d58-693a-4c6e-9180-a7b5819bdd3f",
      "name": "等待处理",
      "type": "n8n-nodes-base.wait",
      "position": [
        2080,
        600
      ],
      "webhookId": "eb746bd1-bead-4d9c-b5d5-6c1a1b605c20",
      "parameters": {
        "amount": 45
      },
      "description": "Waits for Replicate to complete the image generation (45 seconds)",
      "typeVersion": 1.1
    },
    {
      "id": "736f5bc9-3785-486d-a93a-d6e9cbd5e45b",
      "name": "设置文档",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1000,
        380
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 400,
        "content": "## 📝 设置说明"
      },
      "typeVersion": 1
    },
    {
      "id": "2873e80c-d160-4bbc-88e7-89097adaa0bd",
      "name": "注意:发送 Replicate 输出",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2640,
        20
      ],
      "parameters": {
        "color": 4,
        "width": 300,
        "height": 440,
        "content": "### Telegram:发送 Replicate 输出"
      },
      "typeVersion": 1
    },
    {
      "id": "65e13c0b-cf11-4c15-8de4-a6633e621a43",
      "name": "注意:获取 Replicate 结果",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2420,
        580
      ],
      "parameters": {
        "color": 7,
        "width": 360,
        "height": 400,
        "content": "### Replicate API:获取结果"
      },
      "typeVersion": 1
    },
    {
      "id": "d6f4bd9c-6016-45a1-9318-c37aa5786e34",
      "name": "注意:发送编辑后的图像",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        500
      ],
      "parameters": {
        "color": 6,
        "width": 280,
        "height": 380,
        "content": "### Telegram:发送编辑后的图像"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Get File Path": {
      "main": [
        [
          {
            "node": "Generate Variation (Replicate)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Edited Image": {
      "main": [
        [
          {
            "node": "Get File Path",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Image (OpenAI)": {
      "main": [
        [
          {
            "node": "Convert to Binary Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Processing": {
      "main": [
        [
          {
            "node": "Retrieve Generated Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Bot Trigger": {
      "main": [
        [
          {
            "node": "Edit Image (OpenAI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to Binary Image": {
      "main": [
        [
          {
            "node": "Send Edited Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Generated Image": {
      "main": [
        [
          {
            "node": "Send Variation Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Variation (Replicate)": {
      "main": [
        [
          {
            "node": "Wait for Processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 设计, 人工智能, 营销

需要付费吗?

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

工作流信息
难度等级
高级
节点数量20
分类3
节点类型6
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者

AI & Automation Consultant. Sharing cool stuff on my YouTube Channel

外部链接
在 n8n.io 查看

分享此工作流