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

Is there a way to get the file size? #74

Closed vincentsartoko closed 2 years ago

vincentsartoko commented 2 years ago

I need to download a file from a URL, and need to limit 2 things: dimension and size. probe-image-size will help on the dimension, but I can only check the content-length just after probe-image-size, ready to be downloaded (extra request), it would be nice to be able to check content-length as well as the dimension with a single request without triggering the download function...

puzrin commented 2 years ago

It returns length when available https://github.com/nodeca/probe-image-size/blob/master/http.js#L65. But that's not guaranteed.

vincentsartoko commented 2 years ago

This length attribute is based on content-length right? This is not related to probe-image-size, but do u know how to get the guaranteed size?

puzrin commented 2 years ago

The only way to know size with guarantee - full download.