登录 注册
其他
10,696
Stars
1,196
Forks
255
Watchers
425
Open Issues
待补全
许可证
JavaScript
语言
2010-09-29
创建时间
2026-11-11
最近更新

项目能做什么

基于 Cairo 图形库构建的 Node.js 版 Canvas 实现。
来源:基于仓库元数据 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# node-canvas

![Test](https://github.com/Automattic/node-canvas/actions/workflows/ci.yaml/badge.svg)
[![NPM version](https://badge.fury.io/js/canvas.svg)](http://badge.fury.io/js/canvas)

node-canvas is a [Cairo](http://cairographics.org/)-backed Canvas implementation for [Node.js](http://nodejs.org).

## Installation

The latest version of node-canvas is v4. It fixes a plethora of font related issues, adds support for worker threads, reduces binary size, removes the post install script, expands the platforms that binaries support, and more. It is still in the pre-release phase. We appreciate any feedback.

```bash
$ npm install canvas@next
```

To get v3:

```bash
$ npm install canvas
```

The minimum version of Node.js required is **22**.

Binaries will be installed for the following platforms:
- macOS x64/arm64
- Linux x64/x86/arm64 (glibc or musl)
- Linux arm/riscv64 (glibc)
- Windows x64/x86/arm64

If you want to install for a more exotic system, CD into the package and run
`zig build`. You may need to tweak build.zig. PRs are welcome.

## Quick Example

```javascript
const { createCanvas, loadImage } = require('canvas')
const canvas = createCanvas(200, 200)
const ctx = canvas.getContext('2d')

// Write "Awesome!"
ctx.font = '30px Impact'
ctx.rotate(0.1)
ctx.fillText('Awesome!', 50, 100)

// Draw line under text
var text = ctx.measureText('Awesome!')
ctx.strokeStyle = 'rgba(0,0,0,0.5)'
ctx.beginPath()
ctx.lineTo(50, 102)
ctx.lineTo(50 + text.width, 102)
ctx.stroke()

// Draw cat with lime helmet
loadImage('examples/images/lime-cat.jpg').then((image) => {
  ctx.drawImage(image, 50, 0, 70, 70)

  console.log('<img src="' + canvas.toDataURL() + '" />')
})
```

## Documentation

This project is an implementation of the Web Canvas API and implements that API as closely as possible. For API documentation, please visit [Mozilla Web Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API). (See [Compatibility Status](https://github.com/Automattic/node-canvas/wiki/Compatibility-Status) for the current API compliance.) All utility methods and non-standard APIs are documented below.

### Utility methods

* [createCanvas()](#createcanvas)
* [createImageData()](#createimagedata)
* [loadImage()](#loadimage)

### Font API

* [FontFace](#fontface)
* [fonts](#fonts)

### Non-standard APIs

* [Image#src](#imagesrc)
* [Image#dataMode](#imagedatamode)
* [Canvas#toBuffer()](#canvastobuffer)
* [Canvas#createPNGStream()](#canvascreatepngstream)
* [Canvas#createJPEGStream()](#canvascreatejpegstream)
* [Canvas#createPDFStream()](#canvascreatepdfstream)
* [Canvas#toDataURL()](#canvastodataurl)
* [CanvasRenderingContext2D#patternQuality](#canvasrenderingcontext2dpatternquality)
* [CanvasRenderingContext2D#quality](#canvasrenderingcontext2dquality)
* [CanvasRenderingContext2D#textDrawingMode](#canvasrenderingcontext2dtextdrawingmode)
* [CanvasRenderingContext2D#globalCompositeOperation = 'saturate'](#canvasrenderingcontext2dglobalcompositeoperation--sa
阅读完整原文

项目深度分析 规则生成(AI 未配置)

综合评分 57.4 分。该项目在“个人可实施性”维度得 60 分,“付费可能性”维度得 20.0 分,差异化空间 70.0 分(评分依据见评分卡)。

面向细分需求的二次开发产品

产品构想基于 node-canvas 的核心能力,聚焦一个更窄的场景(如某平台、某行业)做差异化。
目标用户该细分场景用户
难度/周期中 · 2~6 周
收费模式买断制 / 订阅制 / 广告
竞争风险细分需求规模需验证
依据 AI 推测:基于项目主题标签的判断

封装为在线小工具或 API 服务

产品构想把项目最常用的一个功能做成网页小工具,靠流量变现或按量计费。
目标用户搜索引擎带来的长尾用户
难度/周期低 · 1~3 周
收费模式免费引流 + 增值功能 / API 按量计费
竞争风险同质化竞争,需做好 SEO
依据 AI 推测:基于技术栈与部署特征的判断
以上为规则引擎基于仓库公开数据生成的参考结论,包含推测成分,不构成投资或创业承诺;配置 AI 后可获得更深入的分析。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

相似项目数据正在完善中,暂不展示(避免误导)

项目优势与风险

技术成熟度创建于 2010-09-29,近 30 天仍在推送,发布过 23 个 Release
社区活跃Star 10,696 / Fork 1,196 / Issue 425(数据支持,可自行核实)
许可证未检测到(需人工确认)
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。