nodeca / probe-image-size

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

No size for some images #22

Closed drey101 closed 6 years ago

drey101 commented 6 years ago

I've noticed that for some urls, the library isn't able to retrieve the length.

Here is a sample url wherein length was not retrieved: https://www.red7.me/asset/user_files/c/227258.jpg

It happened more often in the previous version, and I thought it was fixed in v4.0.0, but it still occurs.

drey101 commented 6 years ago

Here is the retrieved result:

{
  width: 595,
  height: 183,
  type: 'jpg',
  mime: 'image/jpeg',
  wUnits: 'px',
  hUnits: 'px',
  url: 'https://www.red7.me/asset/user_files/c/227258.jpg'
}
puzrin commented 6 years ago

IMHO that's a server side issue. You could check error details and retry. Or try to increase timeout. If file is received, parcer looks ok.

Can i close this?

drey101 commented 6 years ago

Thanks for the advice, I'll try to increase timeout as there doesn't seem to be any errors, and the file is accessible. The image is not held by my server so I won't be able to check if there are errors on their end.

drey101 commented 6 years ago

Increasing timeout didn't do anything. On checking the headers of the image url (https://www.red7.me/asset/user_files/c/227258.jpg) by logging it in probe-image-size/http, it seems it doesn't return 'content-length' because it's 'transfer-encoding' is 'chunked'.

puzrin commented 6 years ago

Content-length is not mandatory. Can you provide a reproducible sample? Existing talk does not add anything new - if server can be unstable, that's not prober issue.

drey101 commented 6 years ago

@puzrin Sorry for the late reply.

The above url is a reproducible sample. Using that url, length is not returned consistently...

Aside from the above, I've noticed that it can sometimes occur for other links as well, but not very often, and there seems to be no consistency to it... For other urls, there's a very high likelihood of it returning length, but not all the time. I haven't been able to gather data yet on how often it fails with regards to the number of requests based on real world data.

puzrin commented 6 years ago

Sorry, i misunderstood initial post.

length is optional and not guaranteed by design, since this package use partial download. It will be set only if server send length info header. So, that's not a bug.

drey101 commented 6 years ago

Alright, thanks!