Click here to Skip to main content
15,667,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm coding a discord bot using discord.js I want to use canvas and merge-images to edit my images but I get error "Error: Couldn't load image" when trying to make a command
const mergeImages = require('merge-images')
const { Canvas, Image } = require('canvas');

module.exports = {
    name: 'avatar',
    description: 'avatar',
    async execute(message, args) {
        let avatarText = `> **${}**`;
        let items = [];
        items = ['../../assets/colors/yellow.png']

        let b64 = await mergeImages(items, { Canvas: Canvas, Image: Image });
        b64 = b64.split(';base64,').pop();
        await, { files: [{ attachment: Buffer.from(b64, 'base64'), name: `yellow.png` }] });

What I have tried:

I tried trying a different pic or making sure of the dir but nothing works and gives the same error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900