Reputation: 46410
Is it possible to retrieve information about images on a web site without having to atually download the actual image? I am interested in width/height and kb size.
Upvotes: 1
Views: 1120
Reputation: 37567
No. You can get the file size using the Content-Length
header but you would need to at least start downloading the image to get the width/height.
Once the image starts downloading you could parse the stream and as @BrokenGlass and @Ed Swangren suggest try to find the image width/height that way.
Having said that, it sounds like an awful lot of work given that you can quickly find the image width/height using available libraries if you download the entire image. Unless you're dealing with massive images or a massive number of images it may just be easier to download the files and check their size that way.
Upvotes: 1
Reputation: 160952
The file size of the image you could determine with an HTTP HEAD request, the response will contain the content-length, in the case of .NET that would be HttpResponse.ContentLength
.
For determining the width/height of many image formats you only need some bytes at the beginning of the file, so you could start with that - as mentioned it depends on the actual image format though.
Upvotes: 1
Reputation: 124732
Some image formats contain size information in the header. You could parse the header to figure out the size, but of course the implementation will vary depending upon the image format.
Upvotes: 3