2 * \brief Defines the ExifData type and the associated functions.
5 * \author Lutz Mueller <lutz@users.sourceforge.net>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 #ifndef __EXIF_DATA_H__
25 #define __EXIF_DATA_H__
29 #endif /* __cplusplus */
31 #include <libexif/exif-byte-order.h>
32 #include <libexif/exif-data-type.h>
33 #include <libexif/exif-ifd.h>
34 #include <libexif/exif-log.h>
35 #include <libexif/exif-tag.h>
37 /*! Represents the entire EXIF data found in an image */
38 typedef struct _ExifData ExifData;
39 typedef struct _ExifDataPrivate ExifDataPrivate;
41 #include <libexif/exif-content.h>
42 #include <libexif/exif-mnote-data.h>
43 #include <libexif/exif-mem.h>
45 /*! Represents the entire EXIF data found in an image */
48 /*! Data for each IFD */
49 ExifContent *ifd[EXIF_IFD_COUNT];
51 /*! Pointer to thumbnail image, or NULL if not available */
54 /*! Number of bytes in thumbnail image at \c data */
57 ExifDataPrivate *priv;
60 /*! Allocate a new, empty #ExifData.
62 * \return allocated #ExifData, or NULL on error
64 ExifData *exif_data_new (void);
66 ExifData *exif_data_new_mem (ExifMem *);
68 /*! Allocate a new #ExifData and load EXIF data from a JPEG file.
69 * Uses an #ExifLoader internally to do the loading.
71 * \param[in] path filename including path
72 * \return allocated #ExifData, or NULL on error
74 ExifData *exif_data_new_from_file (const char *path);
76 /*! Allocate a new #ExifData and load EXIF data from a memory buffer.
78 * \param[in] data pointer to raw JPEG or EXIF data
79 * \param[in] size number of bytes of data at data
80 * \return allocated #ExifData, or NULL on error
82 ExifData *exif_data_new_from_data (const unsigned char *data,
85 /*! Load the #ExifData structure from the raw JPEG or EXIF data in the given
86 * memory buffer. If the EXIF data contains a recognized MakerNote, it is
87 * loaded and stored as well for later retrieval by #exif_data_get_mnote_data.
89 * \param[in,out] data EXIF data
90 * \param[in] d pointer to raw JPEG or EXIF data
91 * \param[in] size number of bytes of data at d
93 void exif_data_load_data (ExifData *data, const unsigned char *d,
96 /*! Store raw EXIF data representing the #ExifData structure into a memory
97 * buffer. The buffer is allocated by this function and must subsequently be
98 * freed by the caller.
100 * \param[in] data EXIF data
101 * \param[out] d pointer to buffer pointer containing raw EXIF data on return
102 * \param[out] ds pointer to variable to hold the number of bytes of
103 * data at d, or set to 0 on error
105 void exif_data_save_data (ExifData *data, unsigned char **d,
108 void exif_data_ref (ExifData *data);
109 void exif_data_unref (ExifData *data);
110 void exif_data_free (ExifData *data);
112 /*! Return the byte order in use by this EXIF structure.
114 * \param[in] data EXIF data
117 ExifByteOrder exif_data_get_byte_order (ExifData *data);
119 /*! Set the byte order to use for this EXIF data. If any tags already exist
120 * (including MakerNote tags) they are are converted to the specified byte
123 * \param[in,out] data EXIF data
124 * \param[in] order byte order
126 void exif_data_set_byte_order (ExifData *data, ExifByteOrder order);
128 /*! Return the MakerNote data out of the EXIF data. Only certain
129 * MakerNote formats that are recognized by libexif are supported.
130 * The pointer references a member of the #ExifData structure and must NOT be
131 * freed by the caller.
133 * \param[in] d EXIF data
134 * \return MakerNote data, or NULL if not found or not supported
136 ExifMnoteData *exif_data_get_mnote_data (ExifData *d);
138 /*! Fix the EXIF data to bring it into specification. Call #exif_content_fix
139 * on each IFD to fix existing entries, create any new entries that are
140 * mandatory but do not yet exist, and remove any entries that are not
143 * \param[in,out] d EXIF data
145 void exif_data_fix (ExifData *d);
147 typedef void (* ExifDataForeachContentFunc) (ExifContent *, void *user_data);
149 /*! Execute a function on each IFD in turn.
151 * \param[in] data EXIF data over which to iterate
152 * \param[in] func function to call for each entry
153 * \param[in] user_data data to pass into func on each call
155 void exif_data_foreach_content (ExifData *data,
156 ExifDataForeachContentFunc func,
159 /*! Options to configure the behaviour of #ExifData */
161 /*! Act as though unknown tags are not present */
162 EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS = 1 << 0,
164 /*! Fix the EXIF tags to follow the spec */
165 EXIF_DATA_OPTION_FOLLOW_SPECIFICATION = 1 << 1,
167 /*! Leave the MakerNote alone, which could cause it to be corrupted */
168 EXIF_DATA_OPTION_DONT_CHANGE_MAKER_NOTE = 1 << 2
171 /*! Return a short textual description of the given #ExifDataOption.
173 * \param[in] o option
174 * \return localized textual description of the option
176 const char *exif_data_option_get_name (ExifDataOption o);
178 /*! Return a verbose textual description of the given #ExifDataOption.
180 * \param[in] o option
181 * \return verbose localized textual description of the option
183 const char *exif_data_option_get_description (ExifDataOption o);
185 /*! Set the given option on the given #ExifData.
187 * \param[in] d EXIF data
188 * \param[in] o option
190 void exif_data_set_option (ExifData *d, ExifDataOption o);
192 /*! Clear the given option on the given #ExifData.
194 * \param[in] d EXIF data
195 * \param[in] o option
197 void exif_data_unset_option (ExifData *d, ExifDataOption o);
199 /*! Set the data type for the given #ExifData.
201 * \param[in] d EXIF data
202 * \param[in] dt data type
204 void exif_data_set_data_type (ExifData *d, ExifDataType dt);
206 /*! Return the data type for the given #ExifData.
208 * \param[in] d EXIF data
209 * \return data type, or #EXIF_DATA_TYPE_COUNT on error
211 ExifDataType exif_data_get_data_type (ExifData *d);
213 /*! Dump all EXIF data to stdout.
214 * This is intended for diagnostic purposes only.
216 * \param[in] data EXIF data
218 void exif_data_dump (ExifData *data);
220 /*! Set the log message object for all IFDs.
222 * \param[in] data EXIF data
223 * \param[in] log #ExifLog
225 void exif_data_log (ExifData *data, ExifLog *log);
227 /*! Return an #ExifEntry for the given tag if found in any IFD.
228 * Each IFD is searched in turn and the first containing a tag with
229 * this number is returned.
231 * \param[in] d #ExifData
232 * \param[in] t #ExifTag
233 * \return #ExifEntry* if found, else NULL if not found
235 #define exif_data_get_entry(d,t) \
236 (exif_content_get_entry(d->ifd[EXIF_IFD_0],t) ? \
237 exif_content_get_entry(d->ifd[EXIF_IFD_0],t) : \
238 exif_content_get_entry(d->ifd[EXIF_IFD_1],t) ? \
239 exif_content_get_entry(d->ifd[EXIF_IFD_1],t) : \
240 exif_content_get_entry(d->ifd[EXIF_IFD_EXIF],t) ? \
241 exif_content_get_entry(d->ifd[EXIF_IFD_EXIF],t) : \
242 exif_content_get_entry(d->ifd[EXIF_IFD_GPS],t) ? \
243 exif_content_get_entry(d->ifd[EXIF_IFD_GPS],t) : \
244 exif_content_get_entry(d->ifd[EXIF_IFD_INTEROPERABILITY],t) ? \
245 exif_content_get_entry(d->ifd[EXIF_IFD_INTEROPERABILITY],t) : NULL)
249 #endif /* __cplusplus */
251 #endif /* __EXIF_DATA_H__ */