Share

JPEGDeux

Tracker: Feature Requests

5 Autorotate via Exif information - ID: 1742986
Last Update: Tracker Item Submitted ( ivanschou )

If you use libexif (http://libexif.sourceforge.net/) you can read the exif
header information and look for the "Orientation" item. This field will be
populated with one of eight values, though only four of which is actually
valid for most digital photography (per this URL:
http://www.impulseadventure.com/photo/exif-orientation.html).

It would be great to be able to have images automatically rotated to the
correct orientation based on the EXIF header information.

Basically the values are: 6-rotate 90 CCW, 3-rotate 180, 8-rotate 270 CCW.

Sample code using would be something like:

// in the main:
#include <exif.h>

// somewhere at the top of main:
exif_init ( malloc, free, realloc );

// where you read the jpeg
exif_data_t* ed;
exif_record_t* er;
ed = exif_parse_file ( argv[--argc] );
er = exif_find_record ( ed, "Orientation" );
switch ( er->rec_data.l )
{
case 8:
myRotation = 270;
break;
case 3:
myRotation = 180;
break;
case 6:
myRotation = 90;
break;
}

Caveat on libexif. I downloaded the tarball release and found that exif.c
and exif.h were missing from the release, and I had to manually download
those two files from the SourceForge CVS repository.


Ivans Chou ( ivanschou ) - 2007-06-25 17:48

5

Open

None

Nobody/Anonymous

None

None

Public


Comments




Log in to comment.

No follow-up comments have been posted.

Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.