I have converted my images with this codes below and this will return base64 of my images but the problem is that when I upload them into the server I just see the white image - can you suggest me the better way to convert images to base64 or this is the best way that I choose here is the converting image to base64
func base64(from image: UIImage) -> String? {
UIGraphicsBeginImageContext(image.size)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
let imageData = UIImageJPEGRepresentation(image!, 1.0)
if let imageString = imageData?.base64EncodedString(options: .endLineWithLineFeed) {
return imageString
}
return nil
}