jiligulu
Creative image tool

Text Portrait 文字肖像生成器

Text Portrait 是一个创意图像工具,上传照片后移除背景,并用文学文本填充人物轮廓,生成由文字构成的肖像。

What it is / 项目是什么

Upload a photo, AI removes the background, and fills your silhouette with literary text. Shakespeare, Dickens, Laozi — your portrait in words.

上传照片,AI 去除背景,用文学作品填充你的轮廓。莎士比亚、狄更斯、老子——用文字构成你的肖像。

How it works / 实现原理

前端使用 MediaPipe 的人像分割模型把照片里的人和背景分开,得到 alpha 通道掩膜。然后选一段文本(默认提供莎士比亚、狄更斯、老子等公共版权作品,也可粘贴自己的文字),在掩膜区域内用 canvas 排版渲染。字号、密度、颜色、行距都可以调,文字会沿着轮廓填满整个剪影。最终导出 PNG 或 SVG。

Who it is for / 适合谁

想把头像、照片和文学文本结合成视觉作品的创作者。

Typical use cases / 常见使用场景

  • 生成有文字感的社交头像和封面图
  • 为活动海报、书籍宣传图做视觉素材
  • 把自己写的诗或散文做成文字肖像送朋友

Key features / 主要功能

  • 上传照片后自动处理人物轮廓
  • 使用文学文本填充剪影,形成文字肖像
  • 适合生成头像、海报和社交媒体视觉素材

Design notes / 设计取舍

这类工具如果做成简单 demo,效果会很"AI 风"。Text Portrait 花了不少精力调字号自适应和边缘处理:当人脸细节比较多时,自动加大字号以避免文字糊成一团;轮廓边缘做轻微羽化,让文字像水墨晕开而不是硬切。这些细节决定了它能不能被当成可用作品而不是玩具。

Technology stack / 技术栈

Each layer below was chosen for what it lets the project avoid as much as what it enables. Together they shape the latency, the build pipeline, and how quickly new ideas can be tried in production.

下面这些选择,更多是为了排除某些复杂度,而不只是为了“用上”。它们共同决定了项目的延迟特性、构建流水线,以及把一个想法跑通的最短路径。

  • Vite

    A fast frontend build tool with native ESM dev server. Hot-reload is near-instant even on large component trees.

  • TypeScript

    A typed superset of JavaScript that catches mismatches at compile time. Helps keep the codebase maintainable as projects grow.

  • MediaPipe

    Google's on-device perception toolkit. Used here for real-time face landmark detection in the browser.

FAQ / 常见问题

上传的照片会被保存吗?

不会。分割和渲染都在浏览器中完成,照片不上传服务器。

可以用自己的文本吗?

可以。文本输入框接受任意长度的字符,包括中文、英文及标点。建议长度足够覆盖整个轮廓。

为什么我的输出文字看起来很挤?

通常是文本太短或字号太大。可以增加文本长度,或调小字号;也可以打开"自动重复填充"选项。

商用可以吗?

工具本身免费,输出可商用。请确保你用的文本和照片拥有相应授权。

Continue reading

The blog goes deeper into the ideas behind Text Portrait. These pieces unpack the psychology, the engineering trade-offs, and the design questions this project raises.