2 * \brief Handling EXIF entries
5 * Copyright (c) 2001 Lutz Mueller <lutz@users.sourceforge.net>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301 USA.
23 #ifndef __EXIF_ENTRY_H__
24 #define __EXIF_ENTRY_H__
28 #endif /* __cplusplus */
30 /*! Data found in one EXIF tag.
31 * The #exif_entry_get_value function can provide access to the
32 * formatted contents, or the struct members can be used directly to
33 * access the raw contents.
35 typedef struct _ExifEntry ExifEntry;
36 typedef struct _ExifEntryPrivate ExifEntryPrivate;
38 #include <libexif/exif-content.h>
39 #include <libexif/exif-format.h>
40 #include <libexif/exif-mem.h>
42 /*! Data found in one EXIF tag */
44 /*! EXIF tag for this entry */
47 /*! Type of data in this entry */
50 /*! Number of elements in the array, if this is an array entry.
51 * Contains 1 for non-array data types. */
52 unsigned long components;
54 /*! Pointer to the raw EXIF data for this entry. It is allocated
55 * by #exif_entry_initialize and is NULL beforehand. Data contained
56 * here may be manipulated using the functions in exif-utils.h */
59 /*! Number of bytes in the buffer at \c data. This must be no less
60 * than exif_format_get_size(format)*components */
63 /*! #ExifContent containing this entry.
64 * \see exif_entry_get_ifd */
67 /*! Internal data to be used by libexif itself */
68 ExifEntryPrivate *priv;
73 /*! Reserve memory for and initialize a new #ExifEntry.
74 * No memory is allocated for the \c data element of the returned #ExifEntry.
76 * \return new allocated #ExifEntry, or NULL on error
78 * \see exif_entry_new_mem, exif_entry_unref
80 ExifEntry *exif_entry_new (void);
82 /*! Reserve memory for and initialize new #ExifEntry using the specified
84 * No memory is allocated for the \c data element of the returned #ExifEntry.
86 * \return new allocated #ExifEntry, or NULL on error
88 * \see exif_entry_new, exif_entry_unref
90 ExifEntry *exif_entry_new_mem (ExifMem *);
92 /*! Increase reference counter for #ExifEntry.
94 * \param[in] entry #ExifEntry
96 * \see exif_entry_unref
98 void exif_entry_ref (ExifEntry *entry);
100 /*! Decrease reference counter for #ExifEntry.
101 * When the reference count drops to zero, free the entry.
103 * \param[in] entry #ExifEntry
105 void exif_entry_unref (ExifEntry *entry);
107 /*! Actually free the #ExifEntry.
109 * \deprecated Should not be called directly. Use #exif_entry_ref and
110 * #exif_entry_unref instead.
112 * \param[in] entry EXIF entry
114 void exif_entry_free (ExifEntry *entry);
116 /*! Initialize an empty #ExifEntry with default data in the correct format
117 * for the given tag. If the entry is already initialized, this function
119 * This call allocates memory for the \c data element of the given #ExifEntry.
120 * That memory is freed at the same time as the #ExifEntry.
122 * \param[out] e entry to initialize
123 * \param[in] tag tag number to initialize as
125 void exif_entry_initialize (ExifEntry *e, ExifTag tag);
127 /*! Fix the type or format of the given EXIF entry to bring it into spec.
128 * If the data for this EXIF tag is in of the wrong type or is in an invalid
129 * format according to the EXIF specification, then it is converted to make it
130 * valid. This may involve, for example, converting an EXIF_FORMAT_LONG into a
131 * EXIF_FORMAT_SHORT. If the tag is unknown, its value is untouched.
133 * \note Unfortunately, some conversions are to a type with a more restricted
134 * range, which could have the side effect that the converted data becomes
135 * invalid. This is unlikely as the range of each tag in the standard is
136 * designed to encompass all likely data.
138 * \param[in,out] entry EXIF entry
140 void exif_entry_fix (ExifEntry *entry);
143 /* For your convenience */
145 /*! Return a localized textual representation of the value of the EXIF entry.
146 * This is meant for display to the user. The format of each tag is subject
147 * to change between locales and in newer versions of libexif. Users who
148 * require the tag data in an unambiguous form should access the data members
149 * of the #ExifEntry structure directly.
151 * \warning The character set of the returned string may be in
152 * the encoding of the current locale or the native encoding
154 * \bug The EXIF_TAG_XP_* tags are currently always returned in UTF-8,
155 * regardless of locale, and code points above U+FFFF are not
158 * \param[in] entry EXIF entry
159 * \param[out] val buffer in which to store value
160 * \param[in] maxlen length of the buffer val
161 * \return val pointer
163 const char *exif_entry_get_value (ExifEntry *entry, char *val,
164 unsigned int maxlen);
166 /*! Dump text representation of #ExifEntry to stdout.
167 * This is intended for diagnostic purposes only.
169 * \param[in] entry EXIF tag data
170 * \param[in] indent how many levels deep to indent the data
172 void exif_entry_dump (ExifEntry *entry, unsigned int indent);
174 /*! Return the IFD number of the given #ExifEntry
176 * \param[in] e an #ExifEntry*
177 * \return #ExifIfd, or #EXIF_IFD_COUNT on error
179 #define exif_entry_get_ifd(e) ((e)?exif_content_get_ifd((e)->parent):EXIF_IFD_COUNT)
183 #endif /* __cplusplus */
185 #endif /* __EXIF_ENTRY_H__ */