Ali Raza
Ali Raza

Reputation: 2816

How to check an image selected is panorama image or not?

i am using UIImagePicker to get an image from the library. I just want to hide panorama library. Is there any option for hide this library in UIImagePicker.Thanks in advance.

Upvotes: 2

Views: 2237

Answers (1)

Fogmeister
Fogmeister

Reputation: 77641

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

There is no minimum or maximum (OK, there might be a maximum) size.

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

Something like...

CGFloat smallest = MIN(image.size.width, image.size.height);
CGFloat largest = MAX(image.size.width, image.size.height);

CGFloat ratio = largest/smallest;

CGFloat maximumRatioForNonePanorama = 4 / 3; // set this yourself depending on 

if (ratio > maximumRatioForNonePanorama) {
    // it is probably a panorama
}

However, also note that when taking a panorama you can start it a stop it without moving the camera at all so it will just be a standard photo.

This is why you have to use the ratio like this. There isn't a flag you can rely on (I think).

Upvotes: 1

Related Questions