1. UIImage -> Data -> base64Encode String

2. base64Encode String -> Data -> UIImage

// Image Data to base64 String
let imageEncData = image.jpegData(compressionQuality: 0.7)
let encodeImageString = String(data: imageEncData.base64EncodedData(), encoding: .utf8) ?? ""

// base64 String to Image Data
if let imageData = Data(base64Encoded: encodeImageString) {
	let image = UIImage(data: imageData)
}

+ Recent posts