-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexif_data.c
More file actions
31 lines (29 loc) · 927 Bytes
/
exif_data.c
File metadata and controls
31 lines (29 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <libexif/exif-loader.h>
int exif_orientation(char *fname) {
ExifData *data;
data = exif_data_new_from_file(fname);
if (!data) {
// this fprintf should go into verbose section
// fprintf (stderr, "unable to retreive exif data\n");
/*
* The way exif data is currently used suggests that
* it is safe to proceed with no data, so just return
* 'no orientation' without an error code
*/
return 0;
}
ExifEntry *entry;
ExifByteOrder byte_order;
byte_order= exif_data_get_byte_order(data);
/* get orientation*/
if ((entry= exif_content_get_entry( data->ifd[EXIF_IFD_0],
EXIF_TAG_ORIENTATION)))
return (int)exif_get_short(entry->data,byte_order);
else
fprintf (stderr, "exif orientation missing\n");
exif_data_unref(data);
// exif_data_free(data);
/* safe to proceed regardless of errors so return 'no orientation' */
return 0;
}