NodeJs,画布未处理的PromiseRejection警告:错误:不支持的图像类型

问题描述

Dependency : 
canvas > version: 2.6.1
node   > version: 12.12.62

我想做下面的事情:

   const { createCanvas,loadImage } = require('canvas');
   var image = await loadImage("png.png");

但是,同一段代码非常适合* .jpeg文件类型。

检查所有可能出现波纹管错误的点:

(node:2536) UnhandledPromiseRejectionWarning: Error: Unsupported image type
    at setSource (********\node_modules\canvas\lib\image.js:91:13)
    at Image.set (********\node_modules\canvas\lib\image.js:62:9)
    at ********\landmark-detection\node_modules\canvas\index.js:34:15
    at new Promise (<anonymous>)
    at loadImage (********\node_modules\canvas\index.js:23:10)
    at imageReconstruction (********\landmark-detection\app.js:159:22)
    at ********\app.js:102:36
(node:2536) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block,or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:2536) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,promise rejections that are not handled will terminate the Node.js 
process with a non-zero exit code.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)