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 *-----------------------------------------------------------------------------
37 EXIF_FORMAT_UNKNOWN = 0,
38 EXIF_FORMAT_BYTE_UNSIGNED = 1,
39 EXIF_FORMAT_STRING = 2,
40 EXIF_FORMAT_SHORT_UNSIGNED = 3,
41 EXIF_FORMAT_LONG_UNSIGNED = 4,
42 EXIF_FORMAT_RATIONAL_UNSIGNED = 5,
44 EXIF_FORMAT_UNDEFINED = 7,
45 EXIF_FORMAT_SHORT = 8,
47 EXIF_FORMAT_RATIONAL = 10,
48 EXIF_FORMAT_FLOAT = 11,
49 EXIF_FORMAT_DOUBLE = 12
53 EXIF_BYTE_ORDER_INTEL,
54 EXIF_BYTE_ORDER_MOTOROLA
57 typedef struct _ExifFormatAttrib ExifFormatAttrib;
58 struct _ExifFormatAttrib
62 const gchar *short_name;
63 const gchar *description;
66 /* the list of known tag data formats */
67 extern ExifFormatAttrib ExifFormatList[];
71 *-----------------------------------------------------------------------------
73 *-----------------------------------------------------------------------------
76 typedef struct _ExifData ExifData;
79 GList *items; /* list of (ExifItem *) */
82 typedef struct _ExifRational ExifRational;
90 typedef struct _ExifItem ExifItem;
91 typedef struct _ExifMarker ExifMarker;
92 typedef struct _ExifTextList ExifTextList;
96 ExifFormatType format;
98 const ExifMarker *marker;
107 ExifFormatType format;
114 #define EXIF_MARKER_LIST_END { 0x0000, EXIF_FORMAT_UNKNOWN, 0, NULL, NULL, NULL }
119 const gchar* description;
122 #define EXIF_TEXT_LIST_END { -1, NULL }
125 typedef struct _ExifFormattedText ExifFormattedText;
126 struct _ExifFormattedText
129 const gchar *description;
134 *-----------------------------------------------------------------------------
136 *-----------------------------------------------------------------------------
139 /* enums useful for image manipulation */
142 EXIF_ORIENTATION_UNKNOWN = 0,
143 EXIF_ORIENTATION_TOP_LEFT = 1,
144 EXIF_ORIENTATION_TOP_RIGHT = 2,
145 EXIF_ORIENTATION_BOTTOM_RIGHT = 3,
146 EXIF_ORIENTATION_BOTTOM_LEFT = 4,
147 EXIF_ORIENTATION_LEFT_TOP = 5,
148 EXIF_ORIENTATION_RIGHT_TOP = 6,
149 EXIF_ORIENTATION_RIGHT_BOTTOM = 7,
150 EXIF_ORIENTATION_LEFT_BOTTOM = 8
151 } ExifOrientationType;
154 EXIF_UNIT_UNKNOWN = 0,
155 EXIF_UNIT_NOUNIT = 1,
157 EXIF_UNIT_CENTIMETER = 3
161 /* the known exif tags list */
162 extern ExifMarker ExifKnownMarkersList[];
164 /* the unknown tags utilize this generic list */
165 extern ExifMarker ExifUnknownMarkersList[];
167 /* the list of specially formatted keys, for human readable output */
168 extern ExifFormattedText ExifFormattedList[];
172 *-----------------------------------------------------------------------------
174 *-----------------------------------------------------------------------------
177 ExifData *exif_read(const gchar *path);
178 void exif_free(ExifData *exif);
180 gchar *exif_get_data_as_text(ExifData *exif, const gchar *key);
181 gint exif_get_integer(ExifData *exif, const gchar *key, gint *value);
182 ExifRational *exif_get_rational(ExifData *exif, const gchar *key, gint *sign);
183 double exif_rational_to_double(ExifRational *r, gint sign);
185 ExifItem *exif_get_item(ExifData *exif, const gchar *key);
187 const char *exif_item_get_tag_name(ExifItem *item);
188 const char *exif_item_get_description(ExifItem *item);
189 const char *exif_item_get_format_name(ExifItem *item, gint brief);
190 gchar *exif_item_get_data_as_text(ExifItem *item);
191 gint exif_item_get_integer(ExifItem *item, gint *value);
192 ExifRational *exif_item_get_rational(ExifItem *item, gint *sign);
194 const gchar *exif_get_description_by_key(const gchar *key);
196 /* usually for debugging to stdout */
197 void exif_write_data_list(ExifData *exif, FILE *f, gint human_readable_list);
201 /* These funcs for use by makernote parsers only */
204 guint16 exif_byte_get_int16(unsigned char *f, ExifByteOrder bo);
205 guint32 exif_byte_get_int32(unsigned char *f, ExifByteOrder bo);
206 guint16 exif_byte_swab_int16(guint16 n, ExifByteOrder bo);
207 guint32 exif_byte_swab_int32(guint32 n, ExifByteOrder bo);
209 ExifItem *exif_item_new(ExifFormatType format, guint tag,
210 guint elements, const ExifMarker *marker);
211 void exif_item_copy_data(ExifItem *item, void *src, guint len,
212 ExifFormatType src_format, ExifByteOrder byte_order);
214 gint exif_parse_IFD_table(ExifData *exif,
215 unsigned char *tiff, guint offset,
216 guint size, ExifByteOrder byte_order,
217 const ExifMarker *list);
219 gint exif_parse_TIFF(ExifData *exif, unsigned char *tiff, guint size, ExifMarker *list);