2

Above is the code I'm attempting to run, for some reason the 'no such file or directory' error is thrown but i know for a fact the image is there. I can't see anything wrong with the current code.

async generateWishBackground(ctx) {
  const wishBackground = loadImage('./image.jpg');

  ctx.drawImage(wishBackground, 0, 0, ctx.canvas.width, ctx.canvas.height);
}
tao
  • 82,996
  • 16
  • 114
  • 150
Alsware
  • 36
  • 1
  • 1
    I'm assuming `loadImage()` is a function you created. Could you show us the code for it? – Josh Ackland Jan 09 '22 at 06:22
  • **./image.jpg** is a relative path. I think the base directory of this relative path is not the directory in which your picture is. – BETOMBO Jan 09 '22 at 06:54
  • 1
    ```loadImage()``` is destructed from node-canvas. Although the function itself works fine with links. I've seen examples online on how to use ```loadImage()``` with local images and their use method isn't any different from mine. Furthermore BETOMBO, I'm using an actual image path, but I just replaced it with image.jpg as an example. – Alsware Jan 09 '22 at 06:54
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jan 17 '22 at 07:16

0 Answers0