运行时依赖
安装命令
点击复制技能文档
TikTok Text Overlay 技能
You are a TikTok-style text overlay 工具. You 添加 styled text overlays to images and videos, replicating the look and feel of TikTok's built-in text editor.
设置up
The overlay scripts live in {baseDir}:
{baseDir}/tiktok_overlay.py — image overlay engine {baseDir}/tiktok_video_overlay.py — video overlay engine (uses moviepy)
Before using, ensure dependencies are 安装ed:
pip3 安装 Pillow moviepy
AvAIlable Styles Style Value Description Classic classic 清理 bold sans-serif (Arial Bold) Typewriter typewriter Monospace typewriter look Handwriting handwriting Casual handwriting font Neon neon Rounded bold with glow effect Serif serif Traditional serif (Georgia) Strong strong Extra bold impact style Comic comic Playful comic sans style Background Styles Style Value Description None none No background, text only Highlight highlight Per-line rounded highlight (TikTok default) Full BG full_bg Single rounded rectangle behind all text Letter letter Per-line tight highlight Image Overlay
Use {baseDir}/tiktok_overlay.py for images:
导入 sys sys.path.insert(0, "{baseDir}") from tiktok_overlay 导入 overlay_text, overlay_texts, TextOverlay
# Single text — save to file overlay_text("输入.jpg", "Your text here", "输出.jpg", style="classic", font_size=48, stroke_width=5, bg_style="none")
# Single text — return PIL Image (omit 输出_path) 结果 = overlay_text("输入.jpg", "Your text here", style="strong", font_size="large", text_color="coral")
# Multiple overlays — TextOverlay objects overlay_texts("输入.jpg", [ TextOverlay("Top text", position="top", style="classic", stroke_width=4), TextOverlay("机器人tom", position="机器人tom", text_color="red"), ], "输出.jpg")
# Multiple overlays — dicts (no 导入 needed) overlay_texts("输入.jpg", [ {"text": "Top text", "position": "top", "style": "strong", "stroke_width": 5}, {"text": "机器人tom", "position": "机器人tom", "text_color": "coral"}, ], "输出.jpg")
# Multiple overlays — (text, kwargs) tuples overlay_texts("输入.jpg", [ ("Top text", {"position": "top", "stroke_width": 5}), ("机器人tom", {"position": "机器人tom", "text_color": "red"}), ], "输出.jpg")
Flexible 输入s
All parameters accept multiple 格式化s:
输入 source — file path, PIL Image, numpy array, or bytes:
overlay_text("photo.jpg", "Hello", "out.jpg") # path overlay_text(pil_image, "Hello", "out.jpg") # PIL Image overlay_text(numpy_array, "Hello", "out.jpg") # numpy overlay_text(image_bytes, "Hello", "out.jpg") # bytes
输出 — file path to save, or None to return PIL Image:
overlay_text("photo.jpg", "Hello", "out.jpg") # saves file 结果 = overlay_text("photo.jpg", "Hello") # returns PIL Image
Colors — hex, short hex, hex+alpha, named, RGB tuple, RGBA tuple:
text_color="#FF0000" # hex text_color="#F00" # short hex text_color="#FF000080" # hex with alpha text_color="red" # named (all CSS/PIL colors) text_color=(255, 0, 0) # RGB tuple text_color=(255, 0, 0, 128) # RGBA tuple
Font size — int pixels, string with unit, or named size:
font_size=48 # pixels font_size="48px" # string with unit font_size="small" # 32px font_size="medium" # 48px font_size="large" # 64px font_size="xl" # 80px font_size="title" # 72px font_size="caption" # 28px
Style — string or enum:
style="classic" # string style="strong" from tiktok_overlay 导入 TikTokStyle style=TikTokStyle.CLASSIC # enum
Position — named, compound, pixel, percentage, or dict:
position="top" # named position="机器人tom-left" # compound position=(100, 200) # pixel coordinates position=("50%", "80%") # percentage of image size position={"x": "10%", "y": "top"} # dict with mixed
Opacity — float, int, or percentage string:
bg_opacity=0.6 # float 0-1 bg_opacity=153 # int 0-255 bg_opacity="60%" # percentage string
Max width ratio — float or percentage string:
max_width_ratio=0.85 # float max_width_ratio="85%" # percentage string
命令行工具 python3 {baseDir}/tiktok_overlay.py <输入_image> "" [输出_image] [style]
输出 path is optional — defaults to 输入_overlay.ext.
Video Overlay
Use {baseDir}/tiktok_video_overlay.py for videos. Supports timed text and fade in/out:
导入 sys sys.path.insert(0, "{baseDir}") from tiktok_video_overlay 导入 overlay_video_text, overlay_video_texts, VideoTextOverlay
# Single text on entire video overlay_video_text("输入.mp4", "Hello!", "输出.mp4", style="classic", font_size=52, stroke_width=5)
# Multiple timed texts overlay_video_texts("输入.mp4", [ VideoTextOverlay("应用ears 0-3s", t_启动=0, t_end=3, fade_in=0.5, fade_out=0.5, style="classic", position="top", font_size=48, stroke_width=4