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 typedef struct _ExifFormattedText ExifFormattedText;
56 struct _ExifFormattedText
59 const gchar *description;
63 *-----------------------------------------------------------------------------
65 *-----------------------------------------------------------------------------
68 typedef struct _ExifItem ExifItem;
70 typedef struct _ExifData ExifData;
72 typedef struct _ExifRational ExifRational;
80 /* enums useful for image manipulation */
83 EXIF_ORIENTATION_UNKNOWN = 0,
84 EXIF_ORIENTATION_TOP_LEFT = 1,
85 EXIF_ORIENTATION_TOP_RIGHT = 2,
86 EXIF_ORIENTATION_BOTTOM_RIGHT = 3,
87 EXIF_ORIENTATION_BOTTOM_LEFT = 4,
88 EXIF_ORIENTATION_LEFT_TOP = 5,
89 EXIF_ORIENTATION_RIGHT_TOP = 6,
90 EXIF_ORIENTATION_RIGHT_BOTTOM = 7,
91 EXIF_ORIENTATION_LEFT_BOTTOM = 8
92 } ExifOrientationType;
95 EXIF_UNIT_UNKNOWN = 0,
98 EXIF_UNIT_CENTIMETER = 3
103 *-----------------------------------------------------------------------------
105 *-----------------------------------------------------------------------------
108 ExifData *exif_read(gchar *path, gchar *sidecar_path);
110 ExifData *exif_read_fd(FileData *fd);
113 int exif_write(ExifData *exif);
114 void exif_free(ExifData *exif);
116 gchar *exif_get_data_as_text(ExifData *exif, const gchar *key);
117 gint exif_get_integer(ExifData *exif, const gchar *key, gint *value);
118 ExifRational *exif_get_rational(ExifData *exif, const gchar *key, gint *sign);
119 double exif_rational_to_double(ExifRational *r, gint sign);
120 double exif_get_rational_as_double(ExifData *exif, const gchar *key);
122 ExifItem *exif_get_item(ExifData *exif, const gchar *key);
123 ExifItem *exif_add_item(ExifData *exif, const gchar *key);
124 ExifItem *exif_get_first_item(ExifData *exif);
125 ExifItem *exif_get_next_item(ExifData *exif);
128 char *exif_item_get_tag_name(ExifItem *item);
129 guint exif_item_get_tag_id(ExifItem *item);
130 guint exif_item_get_elements(ExifItem *item);
131 char *exif_item_get_data(ExifItem *item, guint *data_len);
132 char *exif_item_get_description(ExifItem *item);
133 guint exif_item_get_format_id(ExifItem *item);
134 const char *exif_item_get_format_name(ExifItem *item, gint brief);
135 gchar *exif_item_get_data_as_text(ExifItem *item);
136 gint exif_item_get_integer(ExifItem *item, gint *value);
137 ExifRational *exif_item_get_rational(ExifItem *item, gint *sign);
139 gchar *exif_item_get_string(ExifItem *item, int idx);
141 const gchar *exif_get_description_by_key(const gchar *key);
142 const gchar *exif_get_tag_description_by_key(const gchar *key);
144 gchar *exif_get_formatted_by_key(ExifData *exif, const gchar *key, gint *key_valid);
146 int exif_item_delete(ExifData *exif, ExifItem *item);
147 int exif_item_set_string(ExifItem *item, const char *str);
149 unsigned char *exif_get_color_profile(ExifData *exif, guint *data_len);
151 /* jpeg embedded icc support */
153 void exif_add_jpeg_color_profile(ExifData *exif, unsigned char *cp_data, guint cp_length);
156 gint exif_jpeg_segment_find(unsigned char *data, guint size,
157 guchar app_marker, const gchar *magic, guint magic_len,
158 guint *seg_offset, guint *seg_length);
159 gint exif_jpeg_parse_color(ExifData *exif, unsigned char *data, guint size);
162 gint format_raw_img_exif_offsets_fd(int fd, const gchar *path,
163 unsigned char *header_data, const guint header_len,
164 guint *image_offset, guint *exif_offset);