Home

Published

- 1 min read

convert image to base64 in swift ui

img of convert image to base64 in swift ui

The solution for this is noted below

convert image to base64 in swift ui

Solution

   func convertImageToBase64(image: UIImage) -> String? {
    let imageData = image.jpegData(compressionQuality: 1)
    return imageData?.base64EncodedString(options:
    Data.Base64EncodingOptions.lineLength64Characters)
   }

Try other methods by searching on the site. That is if this doesn’t work