started exiv2 integration
[geeqie.git] / src / exif.h
1 /*
2  *  GQView
3  *  (C) 2006 John Ellis
4  *
5  *  Authors:
6  *    Support for Exif file format, originally written by Eric Swalens.    
7  *    Modified by Quy Tonthat
8  *    Reimplemented with generic data storage by John Ellis
9  *
10
11     This program is free software; you can redistribute it and/or modify
12     it under the terms of the GNU General Public License as published by
13     the Free Software Foundation; either version 2 of the License, or
14     (at your option) any later version.
15
16     This program is distributed in the hope that it will be useful,
17     but WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19     GNU General Public License for more details.
20
21     You should have received a copy of the GNU General Public License
22     along with this program; if not, write to the Free Software
23     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26 #ifndef __EXIF_H
27 #define __EXIF_H
28
29
30 /*
31  *-----------------------------------------------------------------------------
32  * Tag formats
33  *-----------------------------------------------------------------------------
34  */
35
36 #define EXIF_FORMAT_COUNT 13
37
38 typedef enum {
39         EXIF_FORMAT_UNKNOWN             = 0,
40         EXIF_FORMAT_BYTE_UNSIGNED       = 1,
41         EXIF_FORMAT_STRING              = 2,
42         EXIF_FORMAT_SHORT_UNSIGNED      = 3,
43         EXIF_FORMAT_LONG_UNSIGNED       = 4,
44         EXIF_FORMAT_RATIONAL_UNSIGNED   = 5,
45         EXIF_FORMAT_BYTE                = 6,
46         EXIF_FORMAT_UNDEFINED           = 7,
47         EXIF_FORMAT_SHORT               = 8,
48         EXIF_FORMAT_LONG                = 9,
49         EXIF_FORMAT_RATIONAL            = 10,
50         EXIF_FORMAT_FLOAT               = 11,
51         EXIF_FORMAT_DOUBLE              = 12
52 } ExifFormatType;
53
54 /*
55  *-----------------------------------------------------------------------------
56  * Data storage
57  *-----------------------------------------------------------------------------
58  */
59
60 typedef struct _ExifItem ExifItem;
61
62 typedef struct _ExifData ExifData;
63
64 typedef struct _ExifRational ExifRational;
65 struct _ExifRational
66 {
67         guint32 num;
68         guint32 den;
69 };
70
71
72 /* enums useful for image manipulation */
73
74 typedef enum {
75         EXIF_ORIENTATION_UNKNOWN        = 0,
76         EXIF_ORIENTATION_TOP_LEFT       = 1,
77         EXIF_ORIENTATION_TOP_RIGHT      = 2,
78         EXIF_ORIENTATION_BOTTOM_RIGHT   = 3,
79         EXIF_ORIENTATION_BOTTOM_LEFT    = 4,
80         EXIF_ORIENTATION_LEFT_TOP       = 5,
81         EXIF_ORIENTATION_RIGHT_TOP      = 6,
82         EXIF_ORIENTATION_RIGHT_BOTTOM   = 7,
83         EXIF_ORIENTATION_LEFT_BOTTOM    = 8
84 } ExifOrientationType;
85
86 typedef enum {
87         EXIF_UNIT_UNKNOWN       = 0,
88         EXIF_UNIT_NOUNIT        = 1,
89         EXIF_UNIT_INCH          = 2,
90         EXIF_UNIT_CENTIMETER    = 3
91 } ExifUnitType;
92
93
94 /*
95  *-----------------------------------------------------------------------------
96  * functions
97  *-----------------------------------------------------------------------------
98  */
99
100 ExifData *exif_read(gchar *path, gint parse_color_profile);
101 void exif_free(ExifData *exif);
102
103 gchar *exif_get_data_as_text(ExifData *exif, const gchar *key);
104 gint exif_get_integer(ExifData *exif, const gchar *key, gint *value);
105 ExifRational *exif_get_rational(ExifData *exif, const gchar *key, gint *sign);
106 double exif_rational_to_double(ExifRational *r, gint sign);
107
108 ExifItem *exif_get_item(ExifData *exif, const gchar *key);
109 ExifItem *exif_get_first_item(ExifData *exif);
110 ExifItem *exif_get_next_item(ExifData *exif);
111
112 const char *exif_item_get_tag_name(ExifItem *item);
113 guint exif_item_get_tag_id(ExifItem *item);
114 guint exif_item_get_elements(ExifItem *item);
115 char *exif_item_get_data(ExifItem *item, guint *data_len);
116 const char *exif_item_get_description(ExifItem *item);
117 guint exif_item_get_format_id(ExifItem *item);
118 const char *exif_item_get_format_name(ExifItem *item, gint brief);
119 gchar *exif_item_get_data_as_text(ExifItem *item);
120 gint exif_item_get_integer(ExifItem *item, gint *value);
121 ExifRational *exif_item_get_rational(ExifItem *item, gint *sign);
122
123 const gchar *exif_get_description_by_key(const gchar *key);
124
125 gint format_raw_img_exif_offsets_fd(int fd, const gchar *path,
126                                     unsigned char *header_data, const guint header_len,
127                                     guint *image_offset, guint *exif_offset);
128
129
130 #endif
131