Not able to load image from local node js server
See original GitHub issuei tried the following two ways o loading image and output of the following codes are commemnted
1st try
var imageAsBase64 = fs.readFileSync(path, 'base64');
console.log('Exists ' + typeof (imageAsBase64)) // output :Exists string
const image = await faceapi.bufferToImage(imageAsBase64)
.then(res =>{console.log(res)})
.catch(e=> console.log("Error e "+e)) //output :Error e TypeError: Right-hand side of 'instanceof' is not an object
2nd try
var imageAsBase64 = fs.readFileSync(path);
console.log('Exists ' + typeof (imageAsBase64)) // Exists object
const image = await faceapi.fetchImage(imageAsBase64)
.then(res =>{console.log(res)})
.catch(e=> console.log("Error e "+e)) //Error e Type Error: Only absolute URLs are supported
should i missing something or i need to try different way please help…
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Images are not loading on NodeJS server using localhost
When I am trying to create a nodeJs server and running it, with the html file, it is not able to load the...
Read more >How to fetch images from Node.js server ? - GeeksforGeeks
node server.js. 3. Open any browser and to go http://localhost:3000/images/geeksforgeeks.png and you will see the following output:.
Read more >Upload An Image With Node.js - PQINA
This short and concise guide shows how to set up image uploading with Node.js and Express.
Read more >[Solved]-can not read image from folder in node.js-node.js
This line app.use(express.static(__dirname + '/public/images'));. Maps the static content in the /public/images folder to the root of your web application.
Read more >Build your Node image - Docker Documentation
js application that we can use as our example. Create a directory in your local machine named node-docker and follow the steps below...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
faceapi.bufferToImage
returns uses Blob under the hood, so you would need a node polyfill for that.faceapi.fetchImage
as the name implies uses fetch under the hood, thus it doesn’t work with filepaths to local files.I would recommend you to use the node canvas package for reading and writing images as stated in the README and shown in the node examples.
Tech Stack -MERN
I’m am having a similar issue, when attempting to buffer the image sent from the request body express server.
const image= await faceapi.bufferToImage(req.files.image);
ReferenceError: Blob is not defined
To put it simple how can I, buffer the image to perform something as simple as this.
// Detect all faces from buffered image
const detections =await faceapi.detectAllFaces(image).withFaceLandmarks().withFaceDescriptors(); console.log(detections.length);
@WebDevSimplified Watched your videos, they are very helpful @justadudewhohacks Thanks for contributing to the community.