nodeca / probe-image-size

Get image size without full download. Supported image types: JPG, GIF, PNG, WebP, BMP, TIFF, SVG, PSD, ICO.
MIT License
978 stars 77 forks source link

JPEG image produces unrecognized file format error #68

Closed jakowenko closed 2 years ago

jakowenko commented 2 years ago

I have what I believe is a valid JPEG image from a camera and when I try to obtain the size I get the ProbeError: unrecognized file format message.

const sizeOf = require('probe-image-size');

(async () => {
  console.log(
    await sizeOf(
      'https://user-images.githubusercontent.com/1081811/141005965-09e60140-5a30-42ab-989a-dea0c3c361d7.jpg'
    )
  );
})();
reject(last_error || new ProbeError('unrecognized file format', 'ECONTENT'));
                           ^
ProbeError: unrecognized file format
    at ParserStream.parserEnd (/Users/Jako/Dev/github/double-take-alt/api/node_modules/probe-image-size/stream.js:39:28)
    at Object.onceWrapper (node:events:509:28)
    at ParserStream.emit (node:events:390:28)
    at endReadableNT (node:internal/streams/readable:1343:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'ECONTENT'
}

snapshot

puzrin commented 2 years ago

Quick reproduce:

node ./support/dump.js https://user-images.githubusercontent.com/1081811/141005965-09e60140-5a30-42ab-989a-dea0c3c361d7.jpg
puzrin commented 2 years ago

@jakowenko file seems partially broken or non-standard (investigation in progress). Could you describe details, how you got it? Camera model, photo params and so on. Anything about how to reproduce images of this kind.

rsteckler commented 2 years ago

The image comes from a Dahua Camera with official Dahua firmware Device Type: IPC-T5442T-ZE System Version: V2.820.0000000.5.R, Build Date: 2021-07-05

The image is pulled by hitting the camera's "snapshot" url: http://ip_address/cgi-bin/snapshot.cgi

The camera is behind a private network, so you won't be able to pull more images from it, but I'm happy to grab as many as you need and send them over. I've looked at four and all had the same issue within probe-image-size and the same error.

jakowenko commented 2 years ago

FYI @puzrin, I originally created the ticket on behalf of @rsteckler, which is why I asked him to provide that info.

puzrin commented 2 years ago

Also, if possible, please provide more such photos. Currently we have two:

That's enough to prove "problem is reproducible", but i'd like to understand details - is that from new camera, old camera, and why we missed such case.

jakowenko commented 2 years ago

@puzrin, Oops, the one with the person should not be included. Let me edit that out of the original issue. Can you remove from your comment too please.

I'll have @rsteckler provide some more photos though.

rsteckler commented 2 years ago

It's a relatively new camera, released early 2020, but I don't imagine it's any different than what other Dahua cameras produce.
Here are more images: 4 3

Here's one I generated with a slightly different URL. Curious if this one is any different?: 5

I'm happy to grab as many as you need, but the camera itself is on my private network and I'm pretty hesitant to expose it publicly.

rsteckler commented 2 years ago

(and as menitoned, please remove the image with my face in it. I don't need a bunch of women blowing up my inbox on github ;) )

puzrin commented 2 years ago

My question is about camera model. Need to understand who can produce such "strange" images. Difference from common - multiple 0x00 between jpeg segments.

rsteckler commented 2 years ago

The camera model is Dahua IPC-T5442T-ZE

It's become pretty popular in the security community in the last year.

Appreciate you implementing a fix even though these seems like an edge case and is being caused by a non-standards-compliant device.

jakowenko commented 2 years ago

Thank you @rlidwka, do you know when this will be included in the next release?

puzrin commented 2 years ago

See 7.2.2 with fixes.