Display image uploaded from iphone in correct orientation


#1

Hi All,
I have come across a very handy library to load the image in correct orientation (if image was taken with iphone and uploaded into TM1)
You can find more info on the following link


I have made easy function to parse the image through and render in tag to passed div id
The following function does all the work
window.loadImage.scale(img, {maxWidth: w,cover:true,orientation: orientation || 0, canvas: true});

  $rootScope.loadImageIntoCanvas = function(imagesrc, containerid,w,h){
    console.log(imagesrc, "$$$$$$IMAGE SRC$$$$$$");
    $timeout(
      function(){
    
       window.loadImage(imagesrc, function (img) {
        if (img.type === "error") {
            console.log("couldn't load image:", img);
        } else {
            window.EXIF.getData(img, function () {
                console.log("done!");
                var orientation = window.EXIF.getTag(this, "Orientation");
                var canvas = window.loadImage.scale(img, {maxWidth: w,cover:true,orientation: orientation || 0, canvas: true});
                document.getElementById(containerid).innerHTML = "";
                
                

                document.getElementById(containerid).appendChild(canvas);
               
                // or using jquery $("#container").append(canvas);
            });
        }
    } );
      },1000
    )

  }

$rootScope.loadImageIntoCanvas(“images/logo.png”, “container”, 300,300);