Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extract exif orientation data from image [duplicate]

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 !

like image 455
jujule Avatar asked Jan 11 '13 02:01

jujule


People also ask

How do I get rid of EXIF orientation?

To fix the EXIF orientation, open the image in an image editing program. Rotate the image to the correct orientation, then save the file and reupload your image. As an alternative, you can simply remove all EXIF data from images in Windows and macOS.

What is EXIF Extractor?

Details. Retrieve Exif Data from image binary data. This extension can be used in page or logic actions, to retrieve stored Exif data from an image. The image binary can be presented as a parameter to one of the functions in the XIF.

What is EXIF orientation metadata?

EXIF data is useful information about a JPEG image, hidden inside the file. When images are photographed, digital cameras use orientation sensors to store an EXIF orientation value for how the camera is held. There are 8 possible values (not just landscape and portrait!).

What does image orientation do in CSS?

The image-orientation CSS property specifies a layout-independent correction to the orientation of an image.


1 Answers

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);
like image 109
Colin Pear Avatar answered Oct 19 '22 12:10

Colin Pear