I created an app to take an image and convert this image to binary and send to server. I take the image but I can't convert it.
I use this code :
func cameraa(){
let picker = UIImagePickerController()
picker.delegate = self
picker.sourceType = .Camera
presentViewController(picker, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
ImageDisplay.image = info[UIImagePickerControllerOriginalImage] as? UIImage;dismissViewControllerAnimated(true, completion: nil)
}
@IBAction func Encode(sender: UIButton) {
var imageEncode = ImageDisplay.image
let image : UIImage = UIImage(imageEncode)
let imageData = UIImagePNGRepresentation(image)
print(imageData)
My error in parse image(imageEncode) to (let image : UIImage = UIImage(imageEncode))
imageDatais already a binary representation of your image. What is your problem?