npm / canvas
canvas
What changed in canvas 3, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-24.
7 breaking2 security1 new APIs and options1 behavior and defaults1 tooling13 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initcanvas 325 changes
Breaking changes 7
loadImage now rejects when src is null or invalid.
Cairo errors are now thrown by canvas.toBuffer().
Exif orientation in JPEG files is no longer ignored.
Improved font matching was reverted because it does not work when fonts are installed; the notes advise using v3.0.0-rc3 if font selection degrades.
The native addon migrated to N-API and removed libuv and V8 dependencies.
Support for Node.js 16.x and below was dropped, so applications must use a newer Node.js version.
PNG constants are now static properties of the Canvas class.
Security 2
Security fixes address untrusted inputs to getImageData.
Security fixes address untrusted inputs to putImageData.
New APIs and options 1
String tags were added to support class detection.
Behavior and default changes 1
RGB functions now support real numbers instead of only integers.
Tooling 1
The package changed its native-binary installation tool from node-pre-gyp to prebuild-install.
Fixes and other changes 13
Fixes building with gcc.
ctx.direction is now affected by ctx.save and ctx.restore.
PDF pages are preserved when changing width and height.
Fixes compilation on GCC 15.
Corrects the shape drawn by roundRect() when radii are large relative to the rectangle size.
The image src setter now reports the correct HTTP response status code in its error message.
Class properties now have defaults, consistent with standard JavaScript classes.
Parsing of rgb functions and leading or trailing whitespace in CSS colors was fixed.
Missing methods were added to align DOMMatrix with the spec.
Missing methods were added to align DOMPoint with the spec.
Font-family names may contain alternate or properly escaped quotes.
The type of setTransform was corrected.
The TextMetrics type now includes alphabeticBaseline, emHeightAscent, and emHeightDescent properties.