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
0
votes
1 answer

node-canvas & TypeScript: Assertion failed: (tmp.table_size - hash_table_sizes < ARRAY_LENGTH (hash_table_sizes))

I am using node-canvas for drawing an image, this error occurs when the code is ran: Assertion failed: (tmp.table_size - hash_table_sizes < ARRAY_LENGTH (hash_table_sizes)), function _cairo_hash_table_manage, file cairo-hash.c, line…
bruhbruh
  • 33
  • 6
0
votes
1 answer

Not able to load font node-canvas

I am trying to use Fira font but for some reason I am not able to do it. registerFont('./fira.ttf', { family: 'Fira', weight: 700 }); ctx.font = '50px "Fira"'; This gives: (process:14880): Pango-WARNING **: 20:25:33.039: couldn't load font "Fira…
Arya Anish
  • 85
  • 2
  • 9
0
votes
1 answer

I want to use canvas but there is an error

Code: 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…
0
votes
1 answer

canvas.toDataURL() returns [object Promise]

Can someone please tell me why canvas.toDataURL() shows [object Promise]? I want to load a node-canvas image on my website with an image tag in HTML. Here is my code: Handlebars.registerHelper('updateImage', async function (id, user) { const…
zLowyG
  • 21
  • 3
0
votes
2 answers

Deploy Firebase Cloud-Function with Node Canvas fails on Mac M1

I just got a new Mac M1 and i am trying to deploy a Firebase Cloud Function. It works fine, as long as I do not include the node canvas module. When I try to deploy, i am getting the following error: Error: Error occurred while parsing your function…
Lukas
  • 11
  • 2
0
votes
1 answer

How to avoid multi-byte file path bug of node-canvas's loadImage?

node-canvas (2.7.0) has bug which cannot load image from the path includes multi-bytes characters. const { loadImage } = require('canvas'); const image = await loadImage('/Users/ユーザ名/Documents/test.png'); Such case causes "File not found"…
kochizufan
  • 2,120
  • 2
  • 30
  • 50
0
votes
4 answers

Symbol not found: ____chkstk_darwin

I'm on Mac OS and I have a problem with the canvas module. When I want to do an action with canvas, I have this error: dyld: lazy symbol binding failed: Symbol not found: ____chkstk_darwin Referenced…
Theo
  • 171
  • 1
  • 4
  • 5
0
votes
2 answers

discord.js canvas image manipulation

I wan't to make a command that put the user avatar in my wanted image const { createCanvas, loadImage } = require('canvas') const { MessageAttachment } = require('discord.js'); const Command = require('../../structures/Command') …
pulse
  • 19
  • 8
0
votes
1 answer

CanvasGradient type error in NPM package text-to-image

I am trying to create an image using a given text so I used npm's text-to-image package but it's giving me an error when compiling typescript. I am getting the below errors when running the typescript compilation command. It's coming from the…
0
votes
1 answer

Why can repl.it not load a default font config?

Info: Using NodeJS, Discord.js, and canvas in this file, along with repl.it hosting. This code worked on my local machine, but upon moving to repl.it to host it, I got the error "Fontconfig error: Cannot load default config file" Code below const…
0
votes
1 answer

node-canvas in electron -- "mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed."

I'm cresting electron app using node-canvas. I generated an app-installer by the following command: $ electron-builder --mac --x64 --config ./build_mac.js build_mac.js const config = { "appId": "jp.maplat.editor", "asarUnpack": [ …
kochizufan
  • 2,120
  • 2
  • 30
  • 50
0
votes
2 answers

node canvas getImageData() out of memory

I have a nodejs application that transforms images. I run my application in pm2 with 32gb of ram. When trying to get the image data of an image i am getting this error. I have tried to increase the node js memory limit using…
0
votes
0 answers

node-canvas on Heroku

I have a discord.js bot and it runs on Heroku. I added canvas just now, and now the bot is failing to build. This is the log: -----> Installing dependencies Prebuild detected (node_modules already exists) Rebuilding any native modules …
0
votes
1 answer

DiscordJS / Canvas - Image not loading from URL

Code: const Discord = require('discord.js'), client = new Discord.Client(); const Canvas = require('canvas'); module.exports = { name: 'canvas', async execute(m, args) { const canvas = Canvas.createCanvas(762, 528); const ctx =…
EvernoteMC
  • 3
  • 1
  • 4
0
votes
1 answer

Add line break in string on last character before n characters

To start off, this is probably worded badly, as I am not sure how to put what I want into wordsLets say I have this canvas (I'm using node-canvas) and I want to make it display text from a user input. However, the way I am doing it limits the…
Komali
  • 196
  • 9