OLD | NEW |
(Empty) | |
| 1 /*! \file exif-data.h |
| 2 * \brief Defines the ExifData type and the associated functions. |
| 3 */ |
| 4 /* |
| 5 * \author Lutz Mueller <lutz@users.sourceforge.net> |
| 6 * \date 2001-2005 |
| 7 * |
| 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. |
| 12 * |
| 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. |
| 17 * |
| 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., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301 USA. |
| 22 */ |
| 23 |
| 24 #ifndef __EXIF_DATA_H__ |
| 25 #define __EXIF_DATA_H__ |
| 26 |
| 27 #ifdef __cplusplus |
| 28 extern "C" { |
| 29 #endif /* __cplusplus */ |
| 30 |
| 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> |
| 36 |
| 37 /*! Represents the entire EXIF data found in an image */ |
| 38 typedef struct _ExifData ExifData; |
| 39 typedef struct _ExifDataPrivate ExifDataPrivate; |
| 40 |
| 41 #include <libexif/exif-content.h> |
| 42 #include <libexif/exif-mnote-data.h> |
| 43 #include <libexif/exif-mem.h> |
| 44 |
| 45 /*! Represents the entire EXIF data found in an image */ |
| 46 struct _ExifData |
| 47 { |
| 48 /*! Data for each IFD */ |
| 49 ExifContent *ifd[EXIF_IFD_COUNT]; |
| 50 |
| 51 /*! Pointer to thumbnail image, or NULL if not available */ |
| 52 unsigned char *data; |
| 53 |
| 54 /*! Number of bytes in thumbnail image at \c data */ |
| 55 unsigned int size; |
| 56 |
| 57 ExifDataPrivate *priv; |
| 58 }; |
| 59 |
| 60 /*! Allocate a new #ExifData. The #ExifData contains an empty |
| 61 * #ExifContent for each IFD and the default set of options, |
| 62 * which has #EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS |
| 63 * and #EXIF_DATA_OPTION_FOLLOW_SPECIFICATION set. |
| 64 * |
| 65 * \return allocated #ExifData, or NULL on error |
| 66 */ |
| 67 ExifData *exif_data_new (void); |
| 68 |
| 69 /*! Allocate a new #ExifData using the given memory allocator. |
| 70 * The #ExifData contains an empty #ExifContent for each IFD and the default |
| 71 * set of options, which has #EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS and |
| 72 * #EXIF_DATA_OPTION_FOLLOW_SPECIFICATION set. |
| 73 * |
| 74 * \return allocated #ExifData, or NULL on error |
| 75 */ |
| 76 ExifData *exif_data_new_mem (ExifMem *); |
| 77 |
| 78 /*! Allocate a new #ExifData and load EXIF data from a JPEG file. |
| 79 * Uses an #ExifLoader internally to do the loading. |
| 80 * |
| 81 * \param[in] path filename including path |
| 82 * \return allocated #ExifData, or NULL on error |
| 83 */ |
| 84 ExifData *exif_data_new_from_file (const char *path); |
| 85 |
| 86 /*! Allocate a new #ExifData and load EXIF data from a memory buffer. |
| 87 * |
| 88 * \param[in] data pointer to raw JPEG or EXIF data |
| 89 * \param[in] size number of bytes of data at data |
| 90 * \return allocated #ExifData, or NULL on error |
| 91 */ |
| 92 ExifData *exif_data_new_from_data (const unsigned char *data, |
| 93 unsigned int size); |
| 94 |
| 95 /*! Load the #ExifData structure from the raw JPEG or EXIF data in the given |
| 96 * memory buffer. If the EXIF data contains a recognized MakerNote, it is |
| 97 * loaded and stored as well for later retrieval by #exif_data_get_mnote_data. |
| 98 * If the EXIF_DATA_OPTION_FOLLOW_SPECIFICATION has been set on this #ExifData, |
| 99 * then the tags are fixed after loading. |
| 100 * |
| 101 * \param[in,out] data EXIF data |
| 102 * \param[in] d pointer to raw JPEG or EXIF data |
| 103 * \param[in] size number of bytes of data at d |
| 104 */ |
| 105 void exif_data_load_data (ExifData *data, const unsigned char *d, |
| 106 unsigned int size); |
| 107 |
| 108 /*! Store raw EXIF data representing the #ExifData structure into a memory |
| 109 * buffer. The buffer is allocated by this function and must subsequently be |
| 110 * freed by the caller using the matching free function as used by the #ExifMem |
| 111 * in use by this #ExifData. |
| 112 * |
| 113 * \param[in] data EXIF data |
| 114 * \param[out] d pointer to buffer pointer containing raw EXIF data on return |
| 115 * \param[out] ds pointer to variable to hold the number of bytes of |
| 116 * data at d, or set to 0 on error |
| 117 */ |
| 118 void exif_data_save_data (ExifData *data, unsigned char **d, |
| 119 unsigned int *ds); |
| 120 |
| 121 void exif_data_ref (ExifData *data); |
| 122 void exif_data_unref (ExifData *data); |
| 123 void exif_data_free (ExifData *data); |
| 124 |
| 125 /*! Return the byte order in use by this EXIF structure. |
| 126 * |
| 127 * \param[in] data EXIF data |
| 128 * \return byte order |
| 129 */ |
| 130 ExifByteOrder exif_data_get_byte_order (ExifData *data); |
| 131 |
| 132 /*! Set the byte order to use for this EXIF data. If any tags already exist |
| 133 * (including MakerNote tags) they are are converted to the specified byte |
| 134 * order. |
| 135 * |
| 136 * \param[in,out] data EXIF data |
| 137 * \param[in] order byte order |
| 138 */ |
| 139 void exif_data_set_byte_order (ExifData *data, ExifByteOrder order); |
| 140 |
| 141 /*! Return the MakerNote data out of the EXIF data. Only certain |
| 142 * MakerNote formats that are recognized by libexif are supported. |
| 143 * The pointer references a member of the #ExifData structure and must NOT be |
| 144 * freed by the caller. |
| 145 * |
| 146 * \param[in] d EXIF data |
| 147 * \return MakerNote data, or NULL if not found or not supported |
| 148 */ |
| 149 ExifMnoteData *exif_data_get_mnote_data (ExifData *d); |
| 150 |
| 151 /*! Fix the EXIF data to bring it into specification. Call #exif_content_fix |
| 152 * on each IFD to fix existing entries, create any new entries that are |
| 153 * mandatory but do not yet exist, and remove any entries that are not |
| 154 * allowed. |
| 155 * |
| 156 * \param[in,out] d EXIF data |
| 157 */ |
| 158 void exif_data_fix (ExifData *d); |
| 159 |
| 160 typedef void (* ExifDataForeachContentFunc) (ExifContent *, void *user_data); |
| 161 |
| 162 /*! Execute a function on each IFD in turn. |
| 163 * |
| 164 * \param[in] data EXIF data over which to iterate |
| 165 * \param[in] func function to call for each entry |
| 166 * \param[in] user_data data to pass into func on each call |
| 167 */ |
| 168 void exif_data_foreach_content (ExifData *data, |
| 169 ExifDataForeachContentFunc func, |
| 170 void *user_data); |
| 171 |
| 172 /*! Options to configure the behaviour of #ExifData */ |
| 173 typedef enum { |
| 174 /*! Act as though unknown tags are not present */ |
| 175 EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS = 1 << 0, |
| 176 |
| 177 /*! Fix the EXIF tags to follow the spec */ |
| 178 EXIF_DATA_OPTION_FOLLOW_SPECIFICATION = 1 << 1, |
| 179 |
| 180 /*! Leave the MakerNote alone, which could cause it to be corrupted */ |
| 181 EXIF_DATA_OPTION_DONT_CHANGE_MAKER_NOTE = 1 << 2 |
| 182 } ExifDataOption; |
| 183 |
| 184 /*! Return a short textual description of the given #ExifDataOption. |
| 185 * |
| 186 * \param[in] o option |
| 187 * \return localized textual description of the option |
| 188 */ |
| 189 const char *exif_data_option_get_name (ExifDataOption o); |
| 190 |
| 191 /*! Return a verbose textual description of the given #ExifDataOption. |
| 192 * |
| 193 * \param[in] o option |
| 194 * \return verbose localized textual description of the option |
| 195 */ |
| 196 const char *exif_data_option_get_description (ExifDataOption o); |
| 197 |
| 198 /*! Set the given option on the given #ExifData. |
| 199 * |
| 200 * \param[in] d EXIF data |
| 201 * \param[in] o option |
| 202 */ |
| 203 void exif_data_set_option (ExifData *d, ExifDataOption o); |
| 204 |
| 205 /*! Clear the given option on the given #ExifData. |
| 206 * |
| 207 * \param[in] d EXIF data |
| 208 * \param[in] o option |
| 209 */ |
| 210 void exif_data_unset_option (ExifData *d, ExifDataOption o); |
| 211 |
| 212 /*! Set the data type for the given #ExifData. |
| 213 * |
| 214 * \param[in] d EXIF data |
| 215 * \param[in] dt data type |
| 216 */ |
| 217 void exif_data_set_data_type (ExifData *d, ExifDataType dt); |
| 218 |
| 219 /*! Return the data type for the given #ExifData. |
| 220 * |
| 221 * \param[in] d EXIF data |
| 222 * \return data type, or #EXIF_DATA_TYPE_UNKNOWN on error |
| 223 */ |
| 224 ExifDataType exif_data_get_data_type (ExifData *d); |
| 225 |
| 226 /*! Dump all EXIF data to stdout. |
| 227 * This is intended for diagnostic purposes only. |
| 228 * |
| 229 * \param[in] data EXIF data |
| 230 */ |
| 231 void exif_data_dump (ExifData *data); |
| 232 |
| 233 /*! Set the log message object for all IFDs. |
| 234 * |
| 235 * \param[in] data EXIF data |
| 236 * \param[in] log #ExifLog |
| 237 */ |
| 238 void exif_data_log (ExifData *data, ExifLog *log); |
| 239 |
| 240 /*! Return an #ExifEntry for the given tag if found in any IFD. |
| 241 * Each IFD is searched in turn and the first containing a tag with |
| 242 * this number is returned. |
| 243 * |
| 244 * \param[in] d #ExifData |
| 245 * \param[in] t #ExifTag |
| 246 * \return #ExifEntry* if found, else NULL if not found |
| 247 */ |
| 248 #define exif_data_get_entry(d,t) \ |
| 249 (exif_content_get_entry(d->ifd[EXIF_IFD_0],t) ? \ |
| 250 exif_content_get_entry(d->ifd[EXIF_IFD_0],t) : \ |
| 251 exif_content_get_entry(d->ifd[EXIF_IFD_1],t) ? \ |
| 252 exif_content_get_entry(d->ifd[EXIF_IFD_1],t) : \ |
| 253 exif_content_get_entry(d->ifd[EXIF_IFD_EXIF],t) ? \ |
| 254 exif_content_get_entry(d->ifd[EXIF_IFD_EXIF],t) : \ |
| 255 exif_content_get_entry(d->ifd[EXIF_IFD_GPS],t) ? \ |
| 256 exif_content_get_entry(d->ifd[EXIF_IFD_GPS],t) : \ |
| 257 exif_content_get_entry(d->ifd[EXIF_IFD_INTEROPERABILITY],t) ? \ |
| 258 exif_content_get_entry(d->ifd[EXIF_IFD_INTEROPERABILITY],t) : NULL) |
| 259 |
| 260 #ifdef __cplusplus |
| 261 } |
| 262 #endif /* __cplusplus */ |
| 263 |
| 264 #endif /* __EXIF_DATA_H__ */ |
OLD | NEW |