Auto Detect Image for 360 nature in PHP Auto Detect Image for 360 nature in PHP codeigniter codeigniter

Auto Detect Image for 360 nature in PHP


According to Facebook 360 Group:

There isn't yet a standard for tagging a photo as containing 360 content.

It suggest that you look for the EXIF tag

Projection Type : equirectangular

You can also look for

Use Panorama Viewer : True

Those two tags are present on photos taken with my LG 360.


I faced a similar problem for Unity3D platform, but I figured this considering that Equirectangular images usually have proportion as 2:1.

Likely width 2000px and height 1000px(I already have seen software generating heights a bit higher).

Here is the pseudo code, keep in mind that this code considers posX and posY starting from bottom left:

//this is how much the image should be close the 2:1 proportion, or 0.5-proportionThreshold.proportionThreshold = 0.01;//images smaller than this should not have resolution enough to be a panorama.//it is important here to minimumWidth = 2000;minimumHeight = 1080;//in case of the image is not a panorama, this variable determines the maximum size it could be projectedmaxFill = 0.65;//what is the amount of the view the pamorama should view:scaleX = 1;scaleY = 1;//where the panorama should be positioned in the view:posX = 0;posY = 0;currentWidth = source.width;currentHeight = source.height;if(isFullPanorama()){    Log("Full Panorama");    //the variables are already set for that}else if(isPartialPanorama()){    Log("Partial Panorama");    scale = currentHeight/currentWidth * 2f;    scaleX = 1;    scaleY = scale;    posX = 0;    posY = 0.5-scale/2;}else{    Debug.Log("Not Panorama");    proportion = currentHeight/currentWidth;    w = currentWidth > minimumWidth*maxFill ? minimumWidth*maxFill : currentWidth;    scaleX = w / minimumWidth / 2;    scaleY = scaleX * proportion * 2;    if(scaleY>1) {        h = currentHeight > minimumHeight*maxFill ? minimumHeight*maxFill : currentHeight;        scaleY = h / minimumHeight / 2;        scaleX = scaleY * proportion / 2;    }    posX = 0.5-scaleX/2;    posY = 0.5-scaleY/2;}bool isFullPanorama(){    proportion = currentHeight/currentWidth;    return proportion>=0.5-proportionThreshold &&    proportion<=0.5+proportionThreshold &&    source.height >= minimumHeight;}bool isPartialPanorama(){    return currentHeight/currentWidth<=0.5 &&    source.width >= minimumWidth;}