Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Get size of image in bytes without UIImageJPEGRepresentation - Fast solution Swift

Andre Assadi:

I am a new Swift developer and need help finding the size of an image in bytes without UIImageJPEGRepresentation. I am loading the camera roll in my app and need to check the file size of each individual image. When I use JPEGRepresentation this process goes very slowly. Does anyone have a solution?

I am using swift 4 Xcode version 9.1

I have tried the following function:


func getBytes(image:UIImage) {

let cgImage = image.cgImage
print( cgImage!.height * cgImage!.bytesPerRow)

}

This is how I get the images:


let assets = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: nil)
assets.enumerateObjects({ (object, count, stop) in

self.images.append(object)


})



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Get size of image in bytes without UIImageJPEGRepresentation - Fast solution Swift

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×