android - Calculate image's Dimensions/Size without downloading it -


is there way image dimensions or size without downloading server.

like if image hosted on https://500px.com/ or https://imgur.com/ , want calculations want save bandwidth. if image size quite large , user bandwidth not want queue image later.

assuming api doesn't provide such information.

in didrecieveresponse delegate method nsurlconnection recieve response contains such info. if , if has been set on server:

the following gets disk size of image:

- (void)connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response {     nshttpurlresponse *httpresponse = (nshttpurlresponse *) response;     int state = [httpresponse statuscode];      if (state >= 400 && state <600)     {          // wrong happen     }      nslog(@"download response : %@", [response description]);  // shows info. available server.       int file_size = [response expectedcontentlength]; } 

you can check size , cancel connection if want to.

for image dimensions. check question. answer claims can done suggested fastimage category.

the logical way done downloading first part of image contains image header. contains such info image type(png, jpg ...) , image dimensions. believe library so.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -