mikezang
mikezang

Reputation: 2489

how to check image size before download

I have image at url as below:

http://ipcamera-viewer.com/image/?p=199619_20170221_162149_7208.jpg

Because I can't download it easily so I used way like this

browser.get(urlServer)
browser.save_screenshot(pathLocal)

I don't want to download image only black that size is small, so I want to check the file size, I tried to use

imgData = browser.get_get_screenshot_as_base64()
if len(imgData) > 5000: browser.save_screenshot(pathLocal)  

But base64 is not the same as image size, what can I do?

Upvotes: 0

Views: 505

Answers (1)

Darney
Darney

Reputation: 449

This question may provide some insight. It says to multiply by .75 to get an estimated result of the size of the image in bytes which you can compare to.

if (len(imgData)*.75) > desiredBytes: browser.save_screenshot(pathLocal)  

Upvotes: 1

Related Questions