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

@rongyan/cover-generator

v0.1.0

Published

Generate title cover images from a bundled background template.

Downloads

104

Readme

@rongyan/cover-generator

基于内置 cover_bg.png 和「阿里妈妈东方大楷」字体生成标题封面图。实现使用 sharp 合成 PNG,不依赖浏览器、Playwright、Puppeteer 或截图流程。标题使用纯色填充,不添加阴影、描边等文字效果。

安装

npm install @rongyan/cover-generator

CLI

npx @rongyan/cover-generator "把复杂问题讲清楚" --output-dir ./covers

CLI 会在 stdout 输出 JSON:

{
  "ok": true,
  "title": "把复杂问题讲清楚",
  "outputPath": "/absolute/path/covers/cover-20260506150000-xxxx.png",
  "width": 1923,
  "height": 817,
  "format": "png",
  "size": 123456,
  "lines": ["把复杂问题讲清楚"],
  "fontFamily": "阿里妈妈东方大楷",
  "backgroundPath": "/absolute/path/assets/cover_bg.png"
}

常用参数:

cover-generator "标题" -o ./covers
cover-generator --title "标题" --output ./covers/custom.png
cover-generator "标题" --max-lines 1 --font-size 120

程序调用

const { generateCover } = require('@rongyan/cover-generator');

const result = await generateCover('把复杂问题讲清楚', {
  outputDir: './covers'
});

console.log(result);

也可以传对象:

const result = await generateCover({
  title: '把复杂问题讲清楚',
  outputDir: './covers',
  maxLines: 2
});

API

generateCover(title, options)

generateCover(options)

主要 options:

  • outputDir: 输出目录,默认当前目录
  • outputPath: 指定完整输出 PNG 路径,优先级高于 outputDir
  • fileName: 指定输出文件名
  • backgroundPath: 自定义背景 PNG
  • fontPath: 自定义 TTF/OTF 字体
  • color: 标题颜色
  • maxLines: 12,默认 2
  • fontSize: 最大字号
  • minFontSize: 最小字号
  • y: 标题垂直中心位置,单位 px

标题会自动居中,并根据宽度选择一行或两行排版。