Quantcast
Viewing all articles
Browse latest Browse all 37

Answer by Sargis for How to know Image file Size when using SDWebImages?

Try this:

imageView.sd_setImage(with: URL(string: imgUrl), completed: { (image, error, cache, url) in                let imageSize = image?.size                print("imageSize", imageSize)                var imgData: NSData = NSData(data: image.jpegData(compressionQuality: 1))                // var imgData: NSData = UIImagePNGRepresentation(image)                // you can also replace UIImageJPEGRepresentation with UIImagePNGRepresentation.                var imageSizeBytes: Int = imgData.count                print("size of image in KB: %f ", Double(imageSizeBytes) / 1000.0)            })

Viewing all articles
Browse latest Browse all 37

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>