Does anyone know how to convert a UIImage
to a Base64 string, and then reverse it?
I have the below code; the original image before encoding is good, but I only get a blank image after I encode and decode it.
NSData *imageData = UIImagePNGRepresentation(viewImage);
NSString *b64EncStr = [self encode: imageData];
NSString *base64String = [self encodeBase64:imageData];
For iOS 7+, Objective-C, here's how to make the conversion starting with an image URL:
Swift 3.0
To convert image to base64 string
Tested in playground
Swift 4.2 | Xcode 10
Swift 4
Encoding
Decoding
Note: Tested in xcode 9.4.1
Swift iOS8