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
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.
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.
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.
31 *-----------------------------------------------------------------------------
33 *-----------------------------------------------------------------------------
36 #define EXIF_FORMAT_COUNT 13
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,
46 EXIF_FORMAT_UNDEFINED = 7,
47 EXIF_FORMAT_SHORT = 8,
49 EXIF_FORMAT_RATIONAL = 10,
50 EXIF_FORMAT_FLOAT = 11,
51 EXIF_FORMAT_DOUBLE = 12
55 EXIF_BYTE_ORDER_INTEL,
56 EXIF_BYTE_ORDER_MOTOROLA
59 typedef struct _ExifFormatAttrib ExifFormatAttrib;
60 struct _ExifFormatAttrib
64 const gchar *short_name;
65 const gchar *description;
68 /* the list of known tag data formats */
69 extern ExifFormatAttrib ExifFormatList[];
73 *-----------------------------------------------------------------------------
75 *-----------------------------------------------------------------------------
78 typedef struct _ExifData ExifData;
81 GList *items; /* list of (ExifItem *) */
84 typedef struct _ExifRational ExifRational;
92 typedef struct _ExifItem ExifItem;
93 typedef struct _ExifMarker ExifMarker;
94 typedef struct _ExifTextList ExifTextList;
98 ExifFormatType format;
100 const ExifMarker *marker;
109 ExifFormatType format;
116 #define EXIF_MARKER_LIST_END { 0x0000, EXIF_FORMAT_UNKNOWN, 0, NULL, NULL, NULL }
121 const gchar* description;
124 #define EXIF_TEXT_LIST_END { -1, NULL }
127 typedef struct _ExifFormattedText ExifFormattedText;
128 struct _ExifFormattedText
131 const gchar *description;
136 *-----------------------------------------------------------------------------
138 *-----------------------------------------------------------------------------
141 /* enums useful for image manipulation */
144 EXIF_ORIENTATION_UNKNOWN = 0,
145 EXIF_ORIENTATION_TOP_LEFT = 1,
146 EXIF_ORIENTATION_TOP_RIGHT = 2,
147 EXIF_ORIENTATION_BOTTOM_RIGHT = 3,
148 EXIF_ORIENTATION_BOTTOM_LEFT = 4,
149 EXIF_ORIENTATION_LEFT_TOP = 5,
150 EXIF_ORIENTATION_RIGHT_TOP = 6,
151 EXIF_ORIENTATION_RIGHT_BOTTOM = 7,
152 EXIF_ORIENTATION_LEFT_BOTTOM = 8
153 } ExifOrientationType;
156 EXIF_UNIT_UNKNOWN = 0,
157 EXIF_UNIT_NOUNIT = 1,
159 EXIF_UNIT_CENTIMETER = 3
163 /* the known exif tags list */
164 extern ExifMarker ExifKnownMarkersList[];
166 /* the unknown tags utilize this generic list */
167 extern ExifMarker ExifUnknownMarkersList[];
169 /* the list of specially formatted keys, for human readable output */
170 extern ExifFormattedText ExifFormattedList[];
174 *-----------------------------------------------------------------------------
176 *-----------------------------------------------------------------------------
179 ExifData *exif_read(const gchar *path);
180 void exif_free(ExifData *exif);
182 gchar *exif_get_data_as_text(ExifData *exif, const gchar *key);
183 gint exif_get_integer(ExifData *exif, const gchar *key, gint *value);
184 ExifRational *exif_get_rational(ExifData *exif, const gchar *key, gint *sign);
185 double exif_rational_to_double(ExifRational *r, gint sign);
187 ExifItem *exif_get_item(ExifData *exif, const gchar *key);
189 const char *exif_item_get_tag_name(ExifItem *item);
190 const char *exif_item_get_description(ExifItem *item);
191 const char *exif_item_get_format_name(ExifItem *item, gint brief);
192 gchar *exif_item_get_data_as_text(ExifItem *item);
193 gint exif_item_get_integer(ExifItem *item, gint *value);
194 ExifRational *exif_item_get_rational(ExifItem *item, gint *sign);
196 const gchar *exif_get_description_by_key(const gchar *key);
198 /* usually for debugging to stdout */
199 void exif_write_data_list(ExifData *exif, FILE *f, gint human_readable_list);
203 /* These funcs for use by makernote/tiff parsers only */
205 #define EXIF_TIFF_MAX_LEVELS 4
207 #define EXIF_TIFD_OFFSET_TAG 0
208 #define EXIF_TIFD_OFFSET_FORMAT 2
209 #define EXIF_TIFD_OFFSET_COUNT 4
210 #define EXIF_TIFD_OFFSET_DATA 8
211 #define EXIF_TIFD_SIZE 12
214 guint16 exif_byte_get_int16(unsigned char *f, ExifByteOrder bo);
215 guint32 exif_byte_get_int32(unsigned char *f, ExifByteOrder bo);
216 void exif_byte_put_int16(unsigned char *f, guint16 n, ExifByteOrder bo);
217 void exif_byte_put_int32(unsigned char *f, guint32 n, ExifByteOrder bo);
219 ExifItem *exif_item_new(ExifFormatType format, guint tag,
220 guint elements, const ExifMarker *marker);
221 void exif_item_copy_data(ExifItem *item, void *src, guint len,
222 ExifFormatType src_format, ExifByteOrder bo);
224 gint exif_parse_IFD_table(ExifData *exif,
225 unsigned char *tiff, guint offset,
226 guint size, ExifByteOrder bo,
228 const ExifMarker *list);
230 gint exif_tiff_directory_offset(unsigned char *data, const guint len,
231 guint *offset, ExifByteOrder *bo);
232 gint exif_tiff_parse(ExifData *exif, unsigned char *tiff, guint size, ExifMarker *list);
234 gchar *exif_text_list_find_value(ExifTextList *list, guint value);