Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Marker was not found #18

Open
midnightmarth opened this issue Apr 18, 2019 · 0 comments
Open

Error: Marker was not found #18

midnightmarth opened this issue Apr 18, 2019 · 0 comments

Comments

@midnightmarth
Copy link

midnightmarth commented Apr 18, 2019

So I am trying to loop through an array of image urls to get the average picture's color. When I go to try using a buffer as a picture source, I get an invalid GIF error of some sort. I then try downloading via an axios stream and am able to view the picture after downloading, but get this Marker was not found error...

Error: marker was not found
   at decodeScan (/Users/atechooff/Build/Ideea/Webscraper/node_modules/jpeg-js/lib/decoder.js:324:15)
   at constructor.parse (/Users/atechooff/Build/Ideea/Webscraper/node_modules/jpeg-js/lib/decoder.js:744:29)
   at Object.decode (/Users/atechooff/Build/Ideea/Webscraper/node_modules/jpeg-js/lib/decoder.js:983:11)
   at handleJPEG (/Users/atechooff/Build/Ideea/Webscraper/node_modules/get-pixels/node-pixels.js:32:21)
   at doParse (/Users/atechooff/Build/Ideea/Webscraper/node_modules/get-pixels/node-pixels.js:114:7)
   at /Users/atechooff/Build/Ideea/Webscraper/node_modules/get-pixels/node-pixels.js:190:7
   at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)

Here is my code.

let index2 = 0
let interval2 = setInterval(() => {

                downloadImage(images.data[index2].sizes[0].url).then((name) => {
                  console.log('Writting :', objectName, ' to file')

                  getColors(__dirname + '/images/' + name + '.jpg').then(colors => {
                    console.log(colors)
                    if (colors[0]._rgb[2] >= 180) {
                      console.log('found good image!')
                      imageLinks.push(images.data[image].sizes[0].url)
                    }
                  })
                    .catch(err => {
                      console.log("Error! ", err) //This is where I catch the Marker not found error
                    })
                })
                if (++index2 == images.data.length) {
                  console.log('finished looping through images... on to the next array.')
                  clearInterval(interval2)
                }

              }, 1000)

This is my downloadImage function just in case there is something wrong with how im downloading.

const downloadImage = async (url) => {
 let name = uuidv4()
 const writer = fs.createWriteStream(path.resolve(__dirname + ‘/images/’ + name + ‘.jpg’))
 const image = await axios({
   url,
   method: ‘GET’,
   responseType: ‘stream’
 })

 image.data.pipe(writer)

 return new Promise((resolve, reject) => {
   writer.on(‘finish’, resolve(name))
   writer.on(‘error’, reject)
 })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant