Questions tagged [node-canvas]

Node canvas is a Cairo backed Canvas implementation for NodeJS.

Installation

$ npm install canvas

node-canvas extends the canvas API to provide interfacing with node, for example streaming PNG data, converting to a Buffer instance, etc. Among the interfacing API, in some cases the drawing API has been extended for SSJS image manipulation / creation usage, however keep in mind these additions may fail to render properly within browsers.

Github

Node Wiki

152 questions
2
votes
1 answer

Right to Left paragraph writing with node-canvas, Cairo based implementation

I'm trying to generate an image that contains right-to-left text on my node.js server. I'm currently using node-canvas(based on "Cairo"), but open for suggestions in case other libraries will do the trick. To be clear: I need support to be able…
TBE
  • 1,002
  • 1
  • 11
  • 32
2
votes
1 answer

Is there a successful method to destroy Buffer instances and deallocate the memory used in NodeJS Canvas?

Tried numerous ways to force the GC to cleanup the memory without success. On top of that: buf.remove(); // does not exist delete buf; // does not deallocate the memory buf = null; // removing references - no result The problem occurs in this…
swogger
  • 1,079
  • 14
  • 30
2
votes
1 answer

Node Canvas/Resemble.js Error: Image given has not completed loading at load

I'm trying to use Resemble.js in node. I had a bit of trouble getting canvas/cairo installed (something to do with a mix of OS X Mavericks/XQuarts and Homebrew) but got there eventually. Got pretty far, but I've hit a wall with this. function…
Paul Coghill
  • 667
  • 6
  • 27
1
vote
1 answer

Build fails after swapping to pnpm: RollupError: Unexpected character '\x7F' (caused by parse error in node-canvas / pdf.js)

Thanks in advance for any help. TL;DR: I have a parse error at build time bubbling from node-canvas and pdf.js. This is caused by Rollup reading the canvas.node binary, which shouldn't even be in the build output... Is there any way to mark an…
Oscar Hermoso
  • 302
  • 2
  • 12
1
vote
0 answers

How to Measure text width in both node-canvas and canvas, currently gives wildly different results

I'm trying to get the width of text to reduce the font size to fit an element. When using measureText, the browser text width is 570-600 whilst the node-canvas implementation is 350. The max width is 360. Because of this difference, the browser…
wanna_coder101
  • 508
  • 5
  • 19
1
vote
0 answers

fabricjs scale cuts off image when using aws lambda

Steps To Reproduce I am not sure if this is an issue with fabricjs, aws lambda, node-canvas, or I am not setting this up correctly on lambda. Install lambda-layer-canvas-nodejs layer on lambda function Utilize scaling to adjust image inside of…
user2053040
  • 73
  • 1
  • 7
1
vote
1 answer

node-canvas font not applied to the text

const { createCanvas, loadImage, registerFont } = require('canvas'); const fs = require('fs'); const myfact = "when a person dies, they have 7 minutes of brain activity left." const settings = { txtarea: { x: 540, y: 0, width: 864, …
Lol
  • 27
  • 5
1
vote
0 answers

Node-canvas was built without jpeg support (M1 Max, Apple silicon)

having issues with node-canvas on the M1 Max apple silicon machine. This problem doesn't acquire un intel based machines. Throwing error: node-canvas was built without JPEG support. Also, necessary packages are installed: arch -arm64 brew install…
Janis Rozenfelds
  • 29
  • 1
  • 1
  • 8
1
vote
0 answers

How to convert an array of bytes into an image that can be drawn onto a canvas?

I'm using node-canvas to do some image manipulation (in this example to convert the image to a grayscale version, just to keep the example simple). I have no issues getting the raw data, but I'm having trouble working out how to convert the derived…
Dave Sag
  • 13,266
  • 14
  • 86
  • 134
1
vote
1 answer

Using node-canvas in jenkins CI - overriding host to Jenkins-approved host

How can I override binary-host in node-canvas package.json so it fetches pre-built binariy tarballs from my Jenkins-allowlisted corp server instead of GitHub? "binary": { "module_name": "canvas", "module_path": "build/Release", "host":…
Mïchael Makaröv
  • 1,085
  • 12
  • 21
1
vote
0 answers

Converting from canvas to PDF with default at 72 dpi causes incorrect page size

I am creating a canvas with predefined dimensions (2505px width, 3542px height) which are the dimensions for an A4 paper in 300 DPI resolution. I am converting the canvas to pdf using createPDFStream…
Alien13
  • 558
  • 3
  • 8
  • 30
1
vote
0 answers

node_module_version error on node-v17.6.0

I can't run node-canvas on electron. says the following issues. NODE_MODULE_VERSION 102. This version of Node.js requires NODE_MODULE_VERSION 101. Please try re-compiling or re-installing npm version: $ npm -v 8.5.1 node version: $ node…
1
vote
0 answers

how to upgrade from NODE_MODULE_VERSION 101 to NODE_MODULE_VERSION 102

canvas.node was compiled against a different Node.js version using NODE_MODULE_VERSION 102. This version of Node.js requires NODE_MODULE_VERSION 101. Please try re-compiling or re-installing the module (for instance, using "npm rebuild" or "npm…
1
vote
0 answers

Node Canvas context filters don't do anything in NodeJS

When trying to use canvas to blur an image of text in NodeJS, it simply does nothing. This is an example of a Discord bot that's supposed to return a blurred image of the text "Hello World" in SansSerif, but what it actually returns is this …
Aci
  • 546
  • 5
  • 22
1
vote
0 answers

THREE.WebGLRenderer: Error creating WebGLContext on Node.js server

I am trying to open my Three.js script on Node.js headless server with CentOS 9. But I get this problem: THREE.WebGLRenderer: Error creating WebGLContext /home/oleg/servrend/node_modules/three/build/three.cjs:19211 throw error; …