
從架構設計側剖析: MCP vs A2A 是朋友還是對手?
功能模塊 | 工具/平臺 | 鏈接 |
---|---|---|
AI 圖像生成 | Midjourney | https://www.midjourney.com/ |
自動下載與分類 | Python / Requests / asyncio | https://www.python.org/、https://pypi.org/project/requests/ |
Etsy 批量上架 | Etsy Open API | https://developers.etsy.com/ |
自動化工作流 | Zapier / Make | https://zapier.com/、https://www.make.com/ |
圖像處理與優化 | ImageMagick / Pillow | https://imagemagick.org/、https://pypi.org/project/Pillow/ |
版本管理與部署 | Git / GitHub Actions | https://github.com/ |
/wallpaper stunning cosmic galaxy, high resolution, 4K, vibrant colors, symmetrical composition --ar 16:9 --v 5
/avatar futuristic cyberpunk character portrait, clean lines, high detail, transparent background --ar 1:1 --v 5
--ar
:長寬比;--v
:渲染版本;import os
import asyncio
import aiohttp
TOKEN = os.getenv("DISCORD_BOT_TOKEN")
CHANNEL_ID = "你的_midjourney_頻道ID"
PROMPTS = [...] # 從外部文件讀取 Prompt 列表
async def send_prompt(session, prompt):
url = f"https://discord.com/api/v9/channels/{CHANNEL_ID}/messages"
headers = {
"Authorization": f"Bot {TOKEN}",
"Content-Type": "application/json"
}
data = {"content": f"/imagine {prompt}"}
async with session.post(url, json=data, headers=headers) as resp:
return await resp.json()
async def main():
async with aiohttp.ClientSession() as session:
tasks = [send_prompt(session, p) for p in PROMPTS]
results = await asyncio.gather(*tasks)
print("已發送全部請求", results)
if __name__ == "__main__":
asyncio.run(main())
aiohttp
實現高并發;生成完畢后,監聽 Bot 的消息并提取圖片 URL,自動下載到本地,并按主題分類存儲:
import os
import requests
def download_image(url, save_path):
resp = requests.get(url)
with open(save_path, "wb") as f:
f.write(resp.content)
# 遍歷已保存的消息記錄,提取 URL 并調用 download_image
使用 ImageMagick 或 Pillow:
# ImageMagick: 將所有圖片統一裁剪為 1080x1080
magick mogrify -path output/ -resize 1080x1080^ -gravity center -extent 1080x1080 input/*.png
from PIL import Image, ImageDraw, ImageFont
def add_watermark(image_path, text, out_path):
img = Image.open(image_path).convert("RGBA")
watermark = Image.new("RGBA", img.size)
draw = ImageDraw.Draw(watermark)
font = ImageFont.truetype("arial.ttf", 24)
draw.text((10, img.height-30), text, font=font, fill=(255,255,255,128))
combined = Image.alpha_composite(img, watermark)
combined.save(out_path)
api_key
;import requests
import os
API_KEY = os.getenv("ETSY_API_KEY")
SHOP_ID = os.getenv("ETSY_SHOP_ID")
IMAGE_FOLDER = "output/"
def create_listing(title, description, price, image_path):
url = f"https://openapi.etsy.com/v3/application/shops/{SHOP_ID}/listings"
headers = {"x-api-key": API_KEY}
listing_data = {
"title": title,
"description": description,
"price": price,
"quantity": 999,
"shop_section_id": None,
"who_made": "i_did",
"is_supply": False,
"when_made": "made_to_order",
"state": "draft"
}
resp = requests.post(url, json=listing_data, headers=headers)
listing = resp.json()
# 上傳圖片
upload_url = f"{url}/{listing['listing_id']}/images"
files = {"file": open(image_path, "rb")}
requests.post(upload_url, files=files, headers=headers)
for filename in os.listdir(IMAGE_FOLDER):
title = os.path.splitext(filename)[0]
create_listing(title, f"AI 生成壁紙:{title}", "5.00", os.path.join(IMAGE_FOLDER, filename))
利用 Flask + Chart.js 自建一個后臺儀表盤,實時監控:
“AI 設計小店”模式,最大的魅力在于**“低成本、高回報、自動化運營”**。只要掌握了 Midjourney 的批量生產技巧、Etsy 的上架與優化策略,并輔以合理的自動化流程,你也能在 2025 年實現“躺著賺錢”的理想。
現在就行動起來:注冊 Midjourney,準備你的第一批 Prompt;開啟 Etsy 店鋪,制定上架計劃;自動化腳本幫你解放雙手——AI 設計小店的成功之路,從此刻啟程!