Friday, February 3, 2023
HomeiOS Developmentios - Discover picture measurement and optimise in Swift

ios – Discover picture measurement and optimise in Swift

In my utility, I am utilizing YPImagepicker for choosing pictures from library and digicam. I wish to know picture measurement in MB after choosing the photographs or capturing a photograph. Process is to transform the pictures into knowledge and ship to backend through REST API. As of now we’re limiting pictures into 5. So I wish to see the scale of each pictures whether it is greater than 1 Mb have to compress into 1mb.

let imgData = NSData(knowledge: picture.jpegData(compressionQuality: 1)!)
var imageSize: Int = imgData.depend
print("precise measurement of picture in KB: %f ", Double(imageSize) / 1024.0 / 1024.0)

the above pattern I’ve used to test the scale of the picture however I am not seeing the right file measurement. For eg, I am capturing one picture by app and it’s getting saved in album after I test the picture measurement it exhibits 3.4 MB in picture element however in code I am not getting the identical measurement. What’s greatest strategy to obtain this?



Please enter your comment!
Please enter your name here

11 + seven =

Most Popular

Recent Comments