简体   繁体   中英

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?

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)  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM