ReferenceError: FileReader is not defined (node.js)
danyhiol opened this issue · 1 comments
Issue Description
Apply face recognition on a 2 base64 string.
Steps to Reproduce
Apply face recognition using a 2 base64 string.
Expected Behavior
The API should be able to handle base64 images directly.
**Environment
macOS M1
- Module version?
"@vladmandic/face-api": "^1.7.7"
- Built-in demo or custom code?
Code to convert the image:const imgSourceRef = await faceapi.fetchImage(source);
Wheresource
is abase64
string. This produces the above error - Type of module used (e.g.
js
,esm
,esm-nobundle
)? - Browser or NodeJS and version (e.g. NodeJS 14.15 or Chrome 89)?
➜ terminal ✗ node -v
v18.12.1
- OS and Hardware platform (e.g. Windows 10, Ubuntu Linux on x64, Android 10)?
- Packager (if any) (e.g, webpack, rollup, parcel, esbuild, etc.)?
Additional
- For installation or startup issues include your
package.json
- For usage issues, it is recommended to post your code as gist
Expected Behavior
The API should be able to handle base64 images directly.
why would you expect that library should be able to handle base64 images directly?
library cannot be expected to "just know" how to handle every possible input type.
and base64
does not even contain information about image encoding - is it rgb pixel-data, or rgba, or jpeg, or png.
i'm afraid you'll have to decode it yourself before using faceapi
btw, note that fetchImage
is just a wrapper around platform fetch
followed by filling resulting blob
to image
element using FileReader
- so no chance that would work even if fileReader
was implemented differently for nodejs.