0

I have been researching this for a long time.

I need to know how to get an image's orientation by reading it from the metadata tags.

I have looked at Exif, and other 3rd party code. I'am just interested to learn how to do it just from the reading the metadata tags.

I had a code that reads the IIOMetadata but the image dimension tag or orientation will just say normal.

Any suggestions?

António Ribeiro
  • 4,129
  • 5
  • 32
  • 49
  • 1
    Could you please provide what you've done so far? – António Ribeiro Feb 25 '16 at 21:31
  • Possible duplicate of [How to rotate JPEG images based on the orientation metadata?](http://stackoverflow.com/questions/5905868/how-to-rotate-jpeg-images-based-on-the-orientation-metadata) – dnault Feb 25 '16 at 21:53

1 Answers1

0

https://github.com/exif-js/exif-js/blob/master/exif.js

function base64ToArrayBuffer (base64) {
    base64 = base64.replace(/^data\:([^\;]+)\;base64,/gmi, '');
    var binaryString = atob(base64);
    var len = binaryString.length;
    var bytes = new Uint8Array(len);
    for (var i = 0; i < len; i++) {
        bytes[i] = binaryString.charCodeAt(i);
    }
            return bytes.buffer;
}

reader.onload = function (e) {
    var image = new Image();
    image.src = e.target.result;
    exif = EXIF.readFromBinaryFile(base64ToArrayBuffer(e.target.result));
    console.log(exif.Orientation, exif.Make);
Cleriston
  • 750
  • 5
  • 11