iosswiftpanoramas

iOS | How to identify a panoramic image programatically


Is there any method or technique to identify a bitmap (png/jpeg) is actually a 360 degree panoramic image or a normal image. What is the mechanism to distinguish panoramic image from normal image in swift for iOS.


Solution

  • A panorama is just a picture with a large ratio between width and height (or vice versa).

    There is no minimum size but there would be a maximum(Probably).

    The ratio of a standard photo is around 4:3 so you could find the ratio and determine whether or not it is a panorama.

    You can do something like :

    let smallest = min(image.size.width, image.size.height)
    let largest = max(image.size.width, image.size.height)
    
    let ratio = largest/smallest
    
    let maximumRatioForNonePanorama = 4 / 3 // check with your ratio 
    
    if ratio > maximumRatioForNonePanorama {
        // it is probably a panorama
    }
    

    But, also note that when capturing a panorama you can start it a stop it without moving the camera at all so it can just be a normal photo.

    This is why you have to use the ratio like this.I think there's not a flag for this(Yet).