You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Node.js调用C++ DLL实现JPG转WebP遇崩溃问题求助

Node.js调用WebpSdk.dll崩溃问题排查求助

我已经在Stack Overflow及多个网站查找解决方案,但未找到有效信息,目前陷入困境。我希望通过Node.js调用C++编写的WebpSdk.dll实现JPG转WebP,已安装ffi库,但调用时出现崩溃错误,以下是相关代码及信息,请求帮忙排查:

Node.js代码

const ffi = require('ffi');
const ref = require('ref');
const fs = require('fs');
var int = ref.types.int ;
const dllFile = './WebpSdk.dll';
if (!fs.existsSync(dllFile)) {
    throw (new Error('dll does not exist'));
}

const lib = ffi.Library(dllFile, {
    'SelectSingleFile': [ 'bool', [ref.types.Object,ref.types.int] ]
});
const filepath ='./thumb/file.jpg';
console.log(lib.SelectSingleFile(filepath,1));//1 代表文件类型为jpg

报错信息

[nodemon] app crashed - waiting for file changes before starting...

C++ DLL函数说明

//选择单个文件
BOOL bCheck = SelectSingleFile(PathName, ImageType);//SDK 函数
//返回值说明:bCheck为true表示文件有效,为false表示文件无效

内容的提问来源于stack exchange,提问作者amit joshi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 22:10:27