danm/image-hash

SOI not found

Closed this issue · 2 comments

Hi,

When trying to hash some images I get this:

/Volumes/Crypt/www/project/node_modules/jpeg-js/lib/decoder.js:597
        throw "SOI not found";
        ^
SOI not found

For instance with this URL: https://i.pinimg.com/originals/6c/15/55/6c1555fe2fd5db94213a6629ae589068.jpg

Script to reproduce:

const imageHash = require('image-hash');

imageHash('https://i.pinimg.com/originals/6c/15/55/6c1555fe2fd5db94213a6629ae589068.jpg', 8, false, function(error, hash) {
  if (error) {
    console.error(error);
  }
  else {
    console.log(hash);
  }
});

Any idea ?
I'd be glad to help fix it if I can

Cheers

I've been looking at js-jpeg code and apparently, for some files, it can't find the SOI (Start of file), I don't know why.

https://github.com/eugeneware/jpeg-js/blob/master/lib/decoder.js#L597

If the "fileMarker" is different than 0xFFD8 then it fails... I'll look into it

OK, so apparently "pinimg" sometimes returns an "Access denied" so the request fails and obviously it can't find the SOI.

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>1F1294596D7E8D76</RequestId>
<HostId>
zQxSRgjMBLmV5y6tE6EajTC7J//2CuhrFGF8IPtseAya6tRsg5XcmFAsGHdpz9a002FjoxOavIk=
</HostId>
</Error>