I am trying to convert my selected image to base64 and then upload to the server but I seem to be getting a strange error when I go into the image picker I get the error Creating an image format with an unknown type is an error

```
@IBAction func selectImage(_ sender: AnyObject) {

        selectImage.allowsEditing = true //2
        selectImage.sourceType = .photoLibrary //3
        present(selectImage, animated: true, completion: nil)//4

    }

func imagePickerController(_ selectImage: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
            let chosenImage = info[UIImagePickerControllerEditedImage] as! UIImage //2

            profilePic.contentMode = .scaleAspectFit //3
            profilePic.image = chosenImage //4

            let quality = 1.0
            base64String = (UIImageJPEGRepresentation(chosenImage, CGFloat(quality))?.base64EncodedString())!
            //print (base64String)

            self.dismiss(animated: true, completion: nil) //5
        }

```