How to check a image selected is Panorama image or Not

前端 未结 2 772
不知归路
不知归路 2021-01-23 01:37

How to check, the image selected from UIImagePickerController is a Panorama Image or not?

2条回答
  •  广开言路
    2021-01-23 02:07

    Swift 3.0

    As per above suggestion we can check panorama images are more in width so we can ignore large width images

    Normal Image info " size {960, 960} orientation 1 scale 1.000000"

    Panorama Image Info " size {13632, 2936} orientation 1 scale 1.000000"

    let str = "\(info["UIImagePickerControllerOriginalImage"]!)"
    
       let s = str.slice(from: "{", to: "}")
    
        if let arr = s?.components(separatedBy: ","){
            if arr.count >= 2 {
                if Int(arr[0])! > 11000 {
                    picker.dismiss(animated:true, completion: nil)
                    self.makeToast("Invalid Image!!!")
                    return
                }
    
                if Int(arr[1])! > 11000 {
                     picker.dismiss(animated:true, completion: nil)
                    self.makeToast("Invalid Image!!!")
                    return
                }
            }
     }
    

提交回复
热议问题