来自相机挑选的图像的图像旋转问题



我正在获得从相机捕获的图像。我将该图像上传到服务器。从服务器获得相同的图像后,将其旋转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)
    }

解决此操作的最简单方法是允许在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)
}

相关内容

  • 没有找到相关文章

最新更新