使用Jimp调整输入文件中图像的大小

Grz*_*icz 5 javascript image image-resizing

我想调整通过输入文件获得的图像的大小。我发现jimp 似乎是一个不错的选择。我的问题是我不知道如何在文件上使用它。我尝试使用这种方法:

Jimp.read(lenna.buffer)
    .then(image => {
        // do stuff with the image
    })
    .catch(err => {
        // handle an exception
    });
Run Code Online (Sandbox Code Playgroud)

lenna我的文件在哪里,但出现错误:

 No matching constructor overloading was found. 
Please see the docs for how to call the Jimp constructor.
Run Code Online (Sandbox Code Playgroud)

小智 -1

也许你的文件类型不受支持,我认为 jimp 只支持 png、jpg、bmp。祝你今天过得愉快!