File path to image jimp image

I tried to load an image file I pack with my node but if I

Jimp.read("./test.png")

or

Jimp.read("test.png")

I get "Error: ENOENT: no such file or directory, open './test.png'" even though it is right beside the js file
grafik

__dirname is local to each module. Use path.resolve and path.join to get full path to files relative to your node module.

1 Like
var path = require("path");
var imagePath = path.join(__dirname, "test.png");

Jimp.read(imagePath)

Works thank for the help.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.