WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: hdsouza on November 24, 2014, 11:36:44 AM

Title: Size of image on a webpage
Post by: hdsouza on November 24, 2014, 11:36:44 AM
If there an easy way to get the size of the image on a webpage WITHOUT downloading the image first
Title: Re: Size of image on a webpage
Post by: td on November 24, 2014, 01:15:38 PM
Shot in the dark but maybe check the 'Content-Length' part of a response to a HTTP HEAD request?

Title: Re: Size of image on a webpage
Post by: td on November 24, 2014, 01:32:43 PM
If you can get the image URL then maybe something like the following

Code (winbatch) Select

WinHttpReq = ObjectCreate("WinHttp.WinHttpRequest.5.1")
WinHttpReq.Open("HEAD","http://forum.winbatch.com/Themes/Winbatch/current_forum.png", @FALSE)
WinHttpReq.Send()
WinHttpReq.WaitForResponse()
strHeader = WinHttpReq.GetResponseHeader("Content-Length")
Message("Image Size", strHeader:' bytes')
Title: Re: Size of image on a webpage
Post by: hdsouza on November 28, 2014, 01:13:21 PM
That works great. Thanks TD