0

I've searched stackoverflow and numerous websites for an answer to this. But I can't find any proper information regarding this. I am stuck.

I want to convert jpg into Webp by Using C++ dll file in nodejs. For this i Installed FFi Also, But getting error in Response. Can you Please Check my Code.

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 is FileType Like jpg

Getting this Error.

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

C++ Dll Function SelectSingleFile Role.

//Select single file
BOOL bCheck = SelectSingleFile(PathName, ImageType);//SDK function
If bcheck true file is valid if false file is invalid.
amit joshi
  • 39
  • 4
  • Just to make sure that it's not a XY problem - are you sure that you want to do this using c++? This can be done without it (I mean jpg to webp) – Konrad Nov 08 '22 at 17:14
  • `ffi` seems to be dead. Try using [`ffi-napi`](https://github.com/node-ffi-napi/node-ffi-napi) which should be still supported – Konrad Nov 08 '22 at 17:24
  • you might find [sharp](https://sharp.pixelplumbing.com/) easier than writing this stuff yourself. For more help on your crashing issue there should be some more information on the console saying why the application crashed. If not you might need to break out gdb – Alan Birtles Nov 08 '22 at 17:28

0 Answers0