0

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.

Nico
  • 1,788
  • 2
  • 23
  • 41

3 Answers3

2

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).

Agent Smith
  • 2,873
  • 17
  • 32
  • @Cristik If this does'nt help you, you can try [this](https://stackoverflow.com/questions/21744404/how-to-check-a-image-selected-is-panorama-image-or-not) – Agent Smith Feb 22 '18 at 06:20
  • Ohh Sorry @Nico If this does'nt help you, you can try [this](https://stackoverflow.com/questions/21744404/how-to-check-a-image-selected-is-panorama-image-or-not) – Agent Smith Feb 22 '18 at 06:37
1

panorama images have different resolution their ratio will be 2:1 ,4:1 and 10:1. To identify panorama image use below code snippet

 let smallest = min(YOUR_IMAGE.size.width, YOUR_IMAGE.size.height)
 let largest = max(YOUR_IMAGE.size.width, YOUR_IMAGE.size.height)
 let ratio = largest/smallest
 if (ratio >= CGFloat(2/1)) || (ratio >= CGFloat(4/1)) || (ratio >= CGFloat(10/1)) {

    // Panorama image

 } else {

    //NON -Panorama image 

 }

Hope this will help you

Ganesh Manickam
  • 2,113
  • 3
  • 20
  • 28
0

PHAsset has a property named mediaSubtypes. Just check if this array contains panorama subtype.

if mediaSubtypes.contains(.photoPanorama) {
    // ...
}
LukasHromadnik
  • 387
  • 4
  • 8