extract exif orientation data from image

jujule picture jujule · Jan 11, 2013 · Viewed 33.9k times · Source

Possible Duplicate:
Accessing JPEG EXIF rotation data in Javascript on the client side

I'd need to extract the orientation EXIF data from an HTML JPEG image with Javascript.

according to exiftool's documentation the orientation flag is found at offset 0x112 within the EXIF marker, and occupies 2 bytes.

I guess we just need to extract the data at good offset and 'convert' the value but i don't have any idea how to achieve this in the browser. The result value should be a number between 1 and 8 describing the orientation.

How to read that data from a simple IMG tag ? I need a webkit only solution, but browser only.

Thanks !

Answer

Colin Pear picture Colin Pear · Jan 11, 2013

Possible duplicate of this question.

thanks. here's the final code example to get orientation :

var b64 = "data:image/jpeg;base64,/9j/4AAQSkZJRgABA......";
var bin = atob(b64.split(',')[1]);
var exif = EXIF.readFromBinaryFile(new BinaryFile(bin));
alert(exif.Orientation);