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+。

安装

npm install -g @fmode/image

或直接运行:

npx @fmode/image --app "后台管理界面" demo

配置

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

七种模式

| 模式 | 用途 | 尺寸 | 单价 | |---|---|---|---| | --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 |

代码调用

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

// 单张
await genApp('营销数据看板,左侧导航,主区折线图', 'board');

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

// 批量
await batch([
  ['--arch', 'arch1', '四层架构图'],
  ['--app', 'ui1', '管理后台'],
  ['--slide', 'cover', '项目封面'],
]);

模型

| 模型 | 特点 | 速度 | |---|---|---| | gpt-image-2.6-sunburst | 默认。中文渲染质量最高,长文本与数据逻辑一致性最好 | 40-90s | | gpt-image-2.5-sunburst | 稳定可用,中文渲染良好 | 40-60s |

自动回退:主模型不可用时,会自动尝试回退链中的下一个模型。凭据错误(401/403)不会触发回退。

# 查看可用模型
fmode-image --models

# 指定模型
fmode-image --app "界面" demo --model gpt-image-2.5-sunburst

# 通过环境变量
FMODE_IMAGE_MODEL=gpt-image-2.5-sunburst fmode-image --app "界面" demo

使用建议

什么场景用 AI 生图

  • ✅ 架构图、流程图、闭环图 —— AI 出图比手画快得多,版式也更好看
  • ✅ 产品界面概念图 —— 表现力最强,适合方案演示
  • ✅ 整页 PPT 版式 —— 文字量适中的页面,一次成型
  • ✅ 场景插图 —— 氛围感强的照片风格图

什么场景不要用

  • ❌ 文字密集的页面 —— 表格、多列表、小字注释,AI 极易出现乱码、错字、数字错位
  • ❌ 需要精确还原的实物 —— 产品特写、服装细节、证件照片
  • ❌ 数据图表 —— AI 画不准真实数值,会编造数据

推荐做法:文字密集页用 HTML/CSS 精确排版,AI 只负责出背景和插图,两者合成。

出图后必须验证

AI 生成的图一定要逐张检查,重点看:

  1. 中文是否准确 —— 有没有错字、乱码、生造词
  2. 数字是否合理 —— 图表里的数据有没有被编造
  3. 逻辑是否一致 —— 比如看板写着 12,846 人,分页是否对得上

API

gen(mode, prompt, name, opts)

生成一张图。

  • mode — 模式,如 --app
  • prompt — 提示词
  • name — 输出文件名(不含扩展名)
  • opts.model — 指定模型
  • opts.outdir — 输出目录
  • opts.silent — 静默模式

返回输出文件的绝对路径。

batch(tasks, opts)

批量生成。tasks 是 [mode, name, prompt] 数组。

返回 { ok, fail, cost }。

MODES / MODEL_INFO / DEFAULT_MODEL

模式注册表、模型信息、默认模型。

环境变量

| 变量 | 说明 | |---|---| | FMODE_API_KEY | API 密钥(必需) | | FMODE_IMAGE_MODEL | 默认模型 | | SKILL_IMAGE_OUTPUT | 默认输出目录 | | FMODE_API_BASE | API 地址(默认 https://api.fmode.cn) | | FMODE_IMAGE_VERBOSE | 设置后输出模型回退的详细日志 |

License

MIT