npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fmode/image

v2.1.0

Published

AI 图片生成器 — 架构图、产品界面、场景插图、整页 PPT,一行命令出图

Readme

@fmode/image

AI 配图生成器 —— 一行命令出架构图、产品界面、场景插图、整页 PPT。

纯 ESM、零依赖、Node 18+。

npx @fmode/image --app "运营管理后台,左侧导航,主区客户列表" demo

安装

npm install -g @fmode/image     # 全局安装,命令名 fmode-image
npm install @fmode/image        # 作为依赖在代码里调用

配置

export FMODE_API_KEY="sk-..."   # 必需

也支持从 ~/.fmode/config.json 读取:

{ "api_key": "sk-..." }

快速开始

# 架构图
fmode-image --arch "四层技术架构:数据采集、模型服务、业务应用、终端" arch1

# 产品界面(表现力最强)
fmode-image --app "运营管理后台,左侧导航,主区客户列表与趋势曲线" dashboard

# 整页 PPT
fmode-image --slide "商业计划书封面,深蓝渐变底,标题《让每一次交付都可度量》" cover

# 场景插图
fmode-image --scene "深夜办公室,一个人对着三块屏幕,城市夜景窗外" night-work

输出文件为 <name>.png,默认写在当前目录;用 -o <dir> 或 SKILL_IMAGE_OUTPUT 指定目录。

七种模式

| 模式 | 适用场景 | 默认尺寸 | 单价 | |---|---|---|---| | --arch | 架构 / 分层 / 闭环 / 流程图 | 1792×1024 | ¥0.5 | | --app | 产品界面概念图(表现力最强) | 1792×1024 | ¥0.5 | | --slide | 文字少的整页 PPT(封面 / 金句 / 章节页) | 1920×1088 | ¥0.5 | | --explode | 内部结构拆解、数据流向标注 | 1792×1024 | ¥0.5 | | --product | 硬件 / 工业品多角度效果图 | 1792×1024 | ¥0.5 | | --scene | 场景插图、痛点可视化 | 1024×1024 | ¥0.3 | | --detail | 零件 / 材质 / 实物特写 | 1024×1024 | ¥0.3 |

尺寸可用 -s WxH 覆盖,宽高都必须能被 16 整除,否则 API 直接拒绝(常见翻车尺寸 1500x857 → 改用 1536x864)。

代码调用

import { gen, genApp, batch } from '@fmode/image';

// 单张:返回输出文件路径
const path = await genApp('营销数据看板,左侧导航,主区折线图', 'board');

// 指定模型和输出目录
await gen('slide', '产品发布会封面', 'cover', {
  model: 'gpt-image-2.5-sunburst',
  outDir: './out',
});

// 批量:任务间隔默认 3 秒,避免限流
const r = await batch([
  ['arch', 'arch1', '四层架构图'],
  ['app', 'ui1', '管理后台'],
  ['slide', 'cover', '项目封面'],
]);
console.log(r.ok, r.fail, r.cost); // 成功数 / 失败数 / 估算成本

模式既可以写 arch 也可以写 --arch,两种写法等价。

模型

| 模型 | 特点 | 速度 | 成本 | |---|---|---|---| | gpt-image-2.6-sunburst | 默认。图标风格统一、版式更规整;但文字和说明会比 2.5 更精简 | 30–50s | 1× | | gpt-image-2.5-sunburst | 上一版。信息密度更高,会把 prompt 里的功能说明、备注文字写进图里 | 25–45s | 1× |

同一提示词(数据平台三层架构图)的输出对比:

2.5 vs 2.6

  • 2.5 会把「多源数据接入,统一汇聚」这类补充说明写进图;2.6 只保留模块名,版面更干净
  • 本次对比里 2.6 出现过图标语义偏差(「离线计算」配了日历图标)和文字重复(图标里「API」+ 标签「API」)
  • 同批次另测了两张整页 PPT(文字少的封面页 / 文字密集的汇报页),两张中文都没有乱码;但密集页表格里出现了「各行相加 ≠ 合计」的数字错误:2.5 和 2.6 都不保证文字内容与数字自洽

选择建议

  • 需要功能说明文字、信息量大的架构图 → gpt-image-2.5-sunburst
  • 追求版面干净、图标统一的汇报配图 → gpt-image-2.6-sunburst(默认)
  • 正式材料无论用哪个:生成后逐张检查文字与图标语义
# 指定单次使用的模型
fmode-image --app "界面" demo --model gpt-image-2.5-sunburst

# 设置默认模型
export FMODE_IMAGE_MODEL=gpt-image-2.5-sunburst

# 模型回退链:只在模型不可用(400 / 404 / 503 model_not_found)时才切换;
# 429 限流、5xx 故障走重试,不会白白浪费一次出图
fmode-image --arch "架构" arch1 --models gpt-image-2.6-sunburst,gpt-image-2.5-sunburst
# 或
export FMODE_IMAGE_FALLBACK=gpt-image-2.6-sunburst,gpt-image-2.5-sunburst

模型选择优先级:--model / options.model > FMODE_IMAGE_FALLBACK > FMODE_IMAGE_MODEL > 默认模型。

使用建议

适合 AI 出图

  • ✅ 架构图、流程图、闭环图 —— 比手画快得多,版式也更好看
  • ✅ 产品界面概念图 —— 表现力最强,适合方案演示
  • ✅ 文字少的整页 PPT —— 封面、金句页、章节过渡页
  • ✅ 场景插图 —— 氛围感强的插画 / 照片风格图

不适合 AI 出图

  • ❌ 文字密集的页面 —— 长正文、多列表格、密集数据表:长段落基本必乱,数字前后对不上
  • ❌ 需要精确还原的实物 —— 产品特写、证件、服装细节
  • ❌ 数据图表 —— AI 不保证数值真实、合计对得上

文字密集型页面的推荐做法:AI 出画面 + 代码贴文字。 让 AI 生成背景、插画、示意图、界面骨架,标题、正文、数字、表格用 HTML / PPT 精确排版后叠上去。--slide 更适合文字少的页面;内容多的页面拆成「AI 背景 + 代码排版」两层。

出图后必须验证

  1. 中文是否准确 —— 错字、生造词、缺笔画
  2. 图标语义 —— 图标和标签是否对应(2.6 在这方面偶有偏差)
  3. 数字是否自洽 —— 表格合计、正文百分比、图例之间是否一致

CLI 选项

| 选项 | 说明 | |---|---| | -m, --model <id> | 指定模型 | | --models <a,b> | 模型回退链 | | -o, --out <dir> | 输出目录 | | -s, --size <WxH> | 覆盖尺寸 | | --retries <n> | 限流 / 5xx 时单模型重试次数 | | --interval <ms> | 批量间隔,默认 3000 | | --batch <file> | 从 JSON 文件批量生成(- 表示 stdin) | | --list | 列出模式与价格 | | --json | 输出 JSON 结果 |

批量任务文件格式:

[
  ["arch", "arch1", "四层技术架构图"],
  { "mode": "app", "name": "ui1", "prompt": "管理后台界面" }
]

API

gen(mode, prompt, name, options)

生成一张图,返回输出文件的绝对路径。

| 参数 | 说明 | |---|---| | mode | 模式,arch / app / scene / slide / explode / product / detail | | prompt | 提示词(模式自带前后缀,会包在外面) | | name | 输出文件名,不含扩展名,默认 output | | options.size | 覆盖尺寸 | | options.model | 指定模型 | | options.models | 模型回退链 | | options.retries | 单模型重试次数 | | options.outDir | 输出目录 | | options.silent | 不打印进度 |

batch(tasks, options)

批量生成,返回 { ok, fail, cost, results }。

其他导出

genArch / genApp / genScene / genSlide / genExplode / genProduct / genDetail 便捷函数、MODES、MODEL_INFO、DEFAULT_MODEL、getApiKey、validateSize、estimateCost、normalizeMode。

环境变量

| 变量 | 说明 | |---|---| | FMODE_API_KEY | API 密钥(必需) | | FMODE_IMAGE_MODEL | 默认模型 | | FMODE_IMAGE_FALLBACK | 模型回退链(逗号分隔) | | SKILL_IMAGE_OUTPUT | 默认输出目录 | | FMODE_API_BASE_URL | API 根地址(默认 https://api.fmode.cn,带不带 /v1 均可) | | FMODE_IMAGE_RETRIES | 默认重试次数 | | FMODE_IMAGE_INTERVAL_MS | 批量默认间隔 |

作为智能体 Skill 使用

本仓库的 SKILL.md 可直接作为 Skill 或工具说明加载,让智能体在生成配图时遵循模式选择、尺寸约束与出图后的验证流程。

License

MIT