我正在获取从相机捕获的图像。我正在将该图像上传到服务器。从服务器获取相同的图像后,它旋转90度。我搜索并尝试了更多代码。但没有奏效。请指导我。
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
let image = info[UIImagePickerControllerOriginalImage] as! UIImage
// let imgData: NSData = NSData(data: UIImageJPEGRepresentation((image), 1.0)!)
uploadImageToServer(img: image)
}
答案 0 :(得分:0)
解决此问题的最简单方法是允许在UIImagePickerController中编辑照片:
let imagePicker = UIImagePickerController()
imagePicker.allowsEditing = true
在代表中拍摄已编辑的图片:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
guard let image = info[UIImagePickerControllerEditedImage] as? UIImage else { return }
picker.dismiss(animated: true, completion: nil)
}