I've written a method which can extract all the img tags from an HTML file, get the width and height attributes when they're given and calculate the area from that.
Unfortunately, I don't control the HTML files and sometimes I end up with img tags without the width and/or height attributes. In those cases, the dimensions will simply be the dimensions of the image file. How should I determine the dimensions of the image? I'd like this method to:
1 - Consume as little data as possible for each image, since it may be running on a cellular network with multiple requests per minute for hours on end.
2 - Be Lightweight (it runs in the background)
Is the best method really going to be download the image, load it into an UIImage, and get the dimensions from that, or is there some shortcut I can take where I only send something like a HEAD request?
Unfortunately, I don't control the HTML files and sometimes I end up with img tags without the width and/or height attributes. In those cases, the dimensions will simply be the dimensions of the image file. How should I determine the dimensions of the image? I'd like this method to:
1 - Consume as little data as possible for each image, since it may be running on a cellular network with multiple requests per minute for hours on end.
2 - Be Lightweight (it runs in the background)
Is the best method really going to be download the image, load it into an UIImage, and get the dimensions from that, or is there some shortcut I can take where I only send something like a HEAD request?