I want to encode a UIImage object into Base64 String. Generally, I'm a getting quite a large string and the process is taking a long execustion time as well.
func convertImageToBase64String () -> String {
guard let imageData: Data = UIImage.jpegData()
let imgString = imageData.base64EncodedString(options: .init(rawValue: 0))
return imgString
}
class func convertBase64StringToImage (imageBase64String: String) -> UIImage? {
guard let imageData = Data.init(base64Encoded: imageBase64String, options: .init(rawValue: 0)) else { return nil }
let image = UIImage(data: imageData)
return image
}
Please provide me a li'l help here.