question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to load image from local node js server

See original GitHub issue

i 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:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
justadudewhohackscommented, Aug 5, 2019

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.

0reactions
CodeApeAlphacommented, Apr 19, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found