8e4ae4d391474f236b46288d1c11a821467a019b
[platform/upstream/libexif.git] / libexif / exif-tag.c
1 /* exif-tag.c
2  *
3  * Copyright (c) 2001 Lutz Mueller <lutz@users.sourceforge.net>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful, 
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details. 
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA  02110-1301  USA.
19  */
20
21 #include <config.h>
22
23 #include <libexif/exif-tag.h>
24 #include <libexif/i18n.h>
25
26 #include <stdlib.h>
27 #include <string.h>
28
29 #define ESL_NNNN { EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_NOT_RECORDED }
30 #define ESL_OOOO { EXIF_SUPPORT_LEVEL_OPTIONAL, EXIF_SUPPORT_LEVEL_OPTIONAL, EXIF_SUPPORT_LEVEL_OPTIONAL, EXIF_SUPPORT_LEVEL_OPTIONAL }
31 #define ESL_MMMN { EXIF_SUPPORT_LEVEL_MANDATORY, EXIF_SUPPORT_LEVEL_MANDATORY, EXIF_SUPPORT_LEVEL_MANDATORY, EXIF_SUPPORT_LEVEL_NOT_RECORDED }
32 #define ESL_MMMM { EXIF_SUPPORT_LEVEL_MANDATORY, EXIF_SUPPORT_LEVEL_MANDATORY, EXIF_SUPPORT_LEVEL_MANDATORY, EXIF_SUPPORT_LEVEL_MANDATORY }
33 #define ESL_OMON { EXIF_SUPPORT_LEVEL_OPTIONAL, EXIF_SUPPORT_LEVEL_MANDATORY, EXIF_SUPPORT_LEVEL_OPTIONAL, EXIF_SUPPORT_LEVEL_NOT_RECORDED }
34 #define ESL_NNOO { EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_OPTIONAL, EXIF_SUPPORT_LEVEL_OPTIONAL }
35 #define ESL_NNMN { EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_MANDATORY, EXIF_SUPPORT_LEVEL_NOT_RECORDED }
36 #define ESL_NNMM { EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_MANDATORY, EXIF_SUPPORT_LEVEL_MANDATORY }
37 #define ESL_NNNM { EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_MANDATORY }
38 #define ESL_NNNO { EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_NOT_RECORDED, EXIF_SUPPORT_LEVEL_OPTIONAL }
39 #define ESL_UUUU { EXIF_SUPPORT_LEVEL_UNKNOWN, EXIF_SUPPORT_LEVEL_UNKNOWN, EXIF_SUPPORT_LEVEL_UNKNOWN, EXIF_SUPPORT_LEVEL_UNKNOWN }
40 #define ESL_GPS { ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN }
41 #define ESL_UNKNOWN { ESL_UUUU, ESL_UUUU, ESL_UUUU, ESL_UUUU, ESL_UUUU }
42
43 /*!
44  * Table giving information about each EXIF tag.
45  * There may be more than one entry with the same tag value because some tags
46  * have different meanings depending on the IFD in which they appear.
47  * When there are such duplicate entries, there must be no overlap in their
48  * support levels.
49  * The entries MUST be sorted in tag order.
50  * The name and title are mandatory, but the description may be an empty
51  * string. None of the entries may be NULL except the final array terminator.
52  */
53 static const struct TagEntry {
54         /*! Tag ID. There may be duplicate tags when the same number is used for
55          * different meanings in different IFDs. */
56         ExifTag tag;
57         const char *name;
58         const char *title;
59         const char *description;
60         /*! indexed by the types [ExifIfd][ExifDataType] */
61         ExifSupportLevel esl[EXIF_IFD_COUNT][EXIF_DATA_TYPE_COUNT];
62 } ExifTagTable[] = {
63 #ifndef NO_VERBOSE_TAG_STRINGS
64         {EXIF_TAG_GPS_VERSION_ID, "GPSVersionID", N_("GPS Tag Version"),
65          N_("Indicates the version of <GPSInfoIFD>. The version is given "
66             "as 2.0.0.0. This tag is mandatory when <GPSInfo> tag is "
67             "present. (Note: The <GPSVersionID> tag is given in bytes, "
68             "unlike the <ExifVersion> tag. When the version is "
69             "2.0.0.0, the tag value is 02000000.H)."), ESL_GPS},
70         {EXIF_TAG_INTEROPERABILITY_INDEX, "InteroperabilityIndex",
71          N_("Interoperability Index"),
72          N_("Indicates the identification of the Interoperability rule. "
73             "Use \"R98\" for stating ExifR98 Rules. Four bytes used "
74             "including the termination code (NULL). see the separate "
75             "volume of Recommended Exif Interoperability Rules (ExifR98) "
76             "for other tags used for ExifR98."),
77          { ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_OOOO } },
78         {EXIF_TAG_GPS_LATITUDE_REF, "GPSLatitudeRef", N_("North or South Latitude"),
79          N_("Indicates whether the latitude is north or south latitude. The "
80             "ASCII value 'N' indicates north latitude, and 'S' is south "
81             "latitude."), ESL_GPS},
82         {EXIF_TAG_INTEROPERABILITY_VERSION, "InteroperabilityVersion",
83          N_("Interoperability Version"), "",
84          { ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_OOOO } },
85         {EXIF_TAG_GPS_LATITUDE, "GPSLatitude", N_("Latitude"),
86          N_("Indicates the latitude. The latitude is expressed as three "
87             "RATIONAL values giving the degrees, minutes, and seconds, "
88             "respectively. When degrees, minutes and seconds are expressed, "
89             "the format is dd/1,mm/1,ss/1. When degrees and minutes are used "
90             "and, for example, fractions of minutes are given up to two "
91             "decimal places, the format is dd/1,mmmm/100,0/1."),
92          ESL_GPS},
93         {EXIF_TAG_GPS_LONGITUDE_REF, "GPSLongitudeRef", N_("East or West Longitude"),
94          N_("Indicates whether the longitude is east or west longitude. "
95             "ASCII 'E' indicates east longitude, and 'W' is west "
96             "longitude."), ESL_GPS},
97         {EXIF_TAG_GPS_LONGITUDE, "GPSLongitude", N_("Longitude"),
98          N_("Indicates the longitude. The longitude is expressed as three "
99             "RATIONAL values giving the degrees, minutes, and seconds, "
100             "respectively. When degrees, minutes and seconds are expressed, "
101             "the format is ddd/1,mm/1,ss/1. When degrees and minutes are "
102             "used and, for example, fractions of minutes are given up to "
103             "two decimal places, the format is ddd/1,mmmm/100,0/1."),
104          ESL_GPS},
105         {EXIF_TAG_GPS_ALTITUDE_REF, "GPSAltitudeRef", N_("Altitude Reference"),
106          N_("Indicates the altitude used as the reference altitude. If the "
107             "reference is sea level and the altitude is above sea level, 0 "
108             "is given. If the altitude is below sea level, a value of 1 is given "
109             "and the altitude is indicated as an absolute value in the "
110             "GPSAltitude tag. The reference unit is meters. Note that this tag "
111             "is BYTE type, unlike other reference tags."), ESL_GPS},
112         {EXIF_TAG_GPS_ALTITUDE, "GPSAltitude", N_("Altitude"),
113          N_("Indicates the altitude based on the reference in GPSAltitudeRef. "
114             "Altitude is expressed as one RATIONAL value. The reference unit "
115             "is meters."), ESL_GPS},
116         {EXIF_TAG_GPS_TIME_STAMP, "GPSTimeStamp", N_("GPS Time (Atomic Clock)"),
117          N_("Indicates the time as UTC (Coordinated Universal Time). "
118             "TimeStamp is expressed as three RATIONAL values giving "
119             "the hour, minute, and second."), ESL_GPS},
120         {EXIF_TAG_GPS_SATELLITES, "GPSSatellites", N_("GPS Satellites"),
121          N_("Indicates the GPS satellites used for measurements. This "
122             "tag can be used to describe the number of satellites, their ID "
123             "number, angle of elevation, azimuth, SNR and other information "
124             "in ASCII notation. The format is not specified. If the GPS "
125             "receiver is incapable of taking measurements, value of the tag "
126             "shall be set to NULL."), ESL_GPS},
127         {EXIF_TAG_GPS_STATUS, "GPSStatus", N_("GPS Receiver Status"),
128          N_("Indicates the status of the GPS receiver when the image is "
129             "recorded. 'A' means measurement is in progress, and 'V' means "
130             "the measurement is Interoperability."), ESL_GPS},
131         {EXIF_TAG_GPS_MEASURE_MODE, "GPSMeasureMode", N_("GPS Measurement Mode"),
132          N_("Indicates the GPS measurement mode. '2' means "
133             "two-dimensional measurement and '3' means three-dimensional "
134             "measurement is in progress."), ESL_GPS},
135         {EXIF_TAG_GPS_DOP, "GPSDOP", N_("Measurement Precision"),
136          N_("Indicates the GPS DOP (data degree of precision). An HDOP "
137             "value is written during two-dimensional measurement, and PDOP "
138             "during three-dimensional measurement."), ESL_GPS},
139         {EXIF_TAG_GPS_SPEED_REF, "GPSSpeedRef", N_("Speed Unit"),
140          N_("Indicates the unit used to express the GPS receiver speed "
141             "of movement. 'K', 'M' and 'N' represent kilometers per hour, "
142             "miles per hour, and knots."), ESL_GPS},
143         {EXIF_TAG_GPS_SPEED, "GPSSpeed", N_("Speed of GPS Receiver"),
144          N_("Indicates the speed of GPS receiver movement."), ESL_GPS},
145         {EXIF_TAG_GPS_TRACK_REF, "GPSTrackRef", N_("Reference for direction of movement"),
146          N_("Indicates the reference for giving the direction of GPS "
147             "receiver movement. 'T' denotes true direction and 'M' is "
148             "magnetic direction."), ESL_GPS},
149         {EXIF_TAG_GPS_TRACK, "GPSTrack", N_("Direction of Movement"),
150          N_("Indicates the direction of GPS receiver movement. The range "
151             "of values is from 0.00 to 359.99."), ESL_GPS},
152         {EXIF_TAG_GPS_IMG_DIRECTION_REF, "GPSImgDirectionRef", N_("GPS Image Direction Reference"),
153          N_("Indicates the reference for giving the direction of the image when it is captured. "
154             "'T' denotes true direction and 'M' is magnetic direction."), ESL_GPS},
155         {EXIF_TAG_GPS_IMG_DIRECTION, "GPSImgDirection", N_("GPS Image Direction"),
156          N_("Indicates the direction of the image when it was captured. The range of values is "
157             "from 0.00 to 359.99."), ESL_GPS},
158         {EXIF_TAG_GPS_MAP_DATUM, "GPSMapDatum", N_("Geodetic Survey Data Used"),
159          N_("Indicates the geodetic survey data used by the GPS "
160             "receiver. If the survey data is restricted to Japan, the value "
161             "of this tag is 'TOKYO' or 'WGS-84'. If a GPS Info tag is "
162             "recorded, it is strongly recommended that this tag be recorded."), ESL_GPS},
163         {EXIF_TAG_GPS_DEST_LATITUDE_REF, "GPSDestLatitudeRef", N_("Reference For Latitude of Destination"),
164          N_("Indicates whether the latitude of the destination point is "
165             "north or south latitude. The ASCII value 'N' indicates north "
166             "latitude, and 'S' is south latitude."), ESL_GPS},
167         {EXIF_TAG_GPS_DEST_LATITUDE, "GPSDestLatitude", N_("Latitude of Destination"),
168          N_("Indicates the latitude of the destination point. The "
169             "latitude is expressed as three RATIONAL values giving the "
170             "degrees, minutes, and seconds, respectively. If latitude is "
171             "expressed as degrees, minutes and seconds, a typical format "
172             "would be dd/1,mm/1,ss/1. When degrees and minutes are used and, "
173             "for example, fractions of minutes are given up to two decimal "
174             "places, the format would be dd/1,mmmm/100,0/1."), ESL_GPS},
175         {EXIF_TAG_GPS_DEST_LONGITUDE_REF, "GPSDestLongitudeRef", N_("Reference for Longitude of Destination"),
176          N_("Indicates whether the longitude of the destination point is "
177             "east or west longitude. ASCII 'E' indicates east longitude, and "
178             "'W' is west longitude."), ESL_GPS},
179         {EXIF_TAG_GPS_DEST_LONGITUDE, "GPSDestLongitude", N_("Longitude of Destination"),
180          N_("Indicates the longitude of the destination point. The "
181             "longitude is expressed as three RATIONAL values giving the "
182             "degrees, minutes, and seconds, respectively. If longitude is "
183             "expressed as degrees, minutes and seconds, a typical format "
184             "would be ddd/1,mm/1,ss/1. When degrees and minutes are used "
185             "and, for example, fractions of minutes are given up to two "
186             "decimal places, the format would be ddd/1,mmmm/100,0/1."),
187          ESL_GPS},
188         {EXIF_TAG_GPS_DEST_BEARING_REF, "GPSDestBearingRef", N_("Reference for Bearing of Destination"),
189          N_("Indicates the reference used for giving the bearing to "
190             "the destination point. 'T' denotes true direction and 'M' is "
191             "magnetic direction."), ESL_GPS},
192         {EXIF_TAG_GPS_DEST_BEARING, "GPSDestBearing", N_("Bearing of Destination"),
193          N_("Indicates the bearing to the destination point. The range "
194             "of values is from 0.00 to 359.99."), ESL_GPS},
195         {EXIF_TAG_GPS_DEST_DISTANCE_REF, "GPSDestDistanceRef", N_("Reference for Distance to Destination"),
196          N_("Indicates the unit used to express the distance to the "
197             "destination point. 'K', 'M' and 'N' represent kilometers, miles "
198             "and nautical miles."), ESL_GPS},
199         {EXIF_TAG_GPS_DEST_DISTANCE, "GPSDestDistance", N_("Distance to Destination"),
200          N_("Indicates the distance to the destination point."), ESL_GPS},
201         {EXIF_TAG_GPS_PROCESSING_METHOD, "GPSProcessingMethod", N_("Name of GPS Processing Method"),
202          N_("A character string recording the name of the method used "
203             "for location finding. The first byte indicates the character "
204             "code used, and this is followed by the name "
205             "of the method. Since the Type is not ASCII, NULL termination is "
206             "not necessary."), ESL_GPS},
207         {EXIF_TAG_GPS_AREA_INFORMATION, "GPSAreaInformation", N_("Name of GPS Area"),
208          N_("A character string recording the name of the GPS area. The "
209             "first byte indicates the character code used, "
210             "and this is followed by the name of the GPS area. Since "
211             "the Type is not ASCII, NULL termination is not necessary."), ESL_GPS},
212         {EXIF_TAG_GPS_DATE_STAMP, "GPSDateStamp", N_("GPS Date"),
213          N_("A character string recording date and time information "
214             "relative to UTC (Coordinated Universal Time). The format is "
215             "\"YYYY:MM:DD\". The length of the string is 11 bytes including "
216             "NULL."), ESL_GPS},
217         {EXIF_TAG_GPS_DIFFERENTIAL, "GPSDifferential", N_("GPS Differential Correction"),
218          N_("Indicates whether differential correction is applied to the "
219             "GPS receiver."), ESL_GPS},
220         {EXIF_TAG_GPS_H_POSITIONING_ERROR, "GPSHPositioningError", N_("GPS Horizontal Positioning Error"),
221          N_("Indicates the horizontal positioning errors in meters. This is "
222             "expressed as one RATIONAL value."), ESL_GPS},
223         /* Not in EXIF 2.2 */
224         {EXIF_TAG_NEW_SUBFILE_TYPE, "NewSubfileType",
225          N_("New Subfile Type"), N_("A general indication of the kind of data "
226             "contained in this subfile."),
227          ESL_UNKNOWN},
228         {EXIF_TAG_IMAGE_WIDTH, "ImageWidth", N_("Image Width"),
229          N_("The number of columns of image data, equal to the number of "
230             "pixels per row. In JPEG compressed data a JPEG marker is "
231             "used instead of this tag."),
232          { ESL_MMMN, ESL_MMMN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
233         {EXIF_TAG_IMAGE_LENGTH, "ImageLength", N_("Image Length"),
234          N_("The number of rows of image data. In JPEG compressed data a "
235             "JPEG marker is used instead of this tag."), 
236          { ESL_MMMN, ESL_MMMN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
237         {EXIF_TAG_BITS_PER_SAMPLE, "BitsPerSample", N_("Bits per Sample"),
238          N_("The number of bits per image component. In this standard each "
239             "component of the image is 8 bits, so the value for this "
240             "tag is 8. See also <SamplesPerPixel>. In JPEG compressed data "
241             "a JPEG marker is used instead of this tag."),
242          { ESL_MMMN, ESL_MMMN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
243         {EXIF_TAG_COMPRESSION, "Compression", N_("Compression"),
244          N_("The compression scheme used for the image data. When a "
245             "primary image is JPEG compressed, this designation is "
246             "not necessary and is omitted. When thumbnails use JPEG "
247             "compression, this tag value is set to 6."),
248          { ESL_MMMN, ESL_MMMM, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
249         {EXIF_TAG_PHOTOMETRIC_INTERPRETATION, "PhotometricInterpretation",
250          N_("Photometric Interpretation"),
251          N_("The pixel composition. In JPEG compressed data a JPEG "
252             "marker is used instead of this tag."),
253          { ESL_MMMN, ESL_MMMN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
254         /* Not in EXIF 2.2 */
255         {EXIF_TAG_FILL_ORDER, "FillOrder", N_("Fill Order"), "", ESL_UNKNOWN},
256         /* Not in EXIF 2.2 */
257         {EXIF_TAG_DOCUMENT_NAME, "DocumentName", N_("Document Name"), "",
258          ESL_UNKNOWN},
259         {EXIF_TAG_IMAGE_DESCRIPTION, "ImageDescription",
260          N_("Image Description"),
261          N_("A character string giving the title of the image. It may be "
262             "a comment such as \"1988 company picnic\" or "
263             "the like. Two-bytes character codes cannot be used. "
264             "When a 2-bytes code is necessary, the Exif Private tag "
265             "<UserComment> is to be used."),
266          { ESL_OOOO, ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
267         {EXIF_TAG_MAKE, "Make", N_("Manufacturer"),
268          N_("The manufacturer of the recording "
269             "equipment. This is the manufacturer of the DSC, scanner, "
270             "video digitizer or other equipment that generated the "
271             "image. When the field is left blank, it is treated as "
272             "unknown."),
273          { ESL_OOOO, ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
274         {EXIF_TAG_MODEL, "Model", N_("Model"),
275          N_("The model name or model number of the equipment. This is the "
276             "model name or number of the DSC, scanner, video digitizer "
277             "or other equipment that generated the image. When the field "
278             "is left blank, it is treated as unknown."),
279          { ESL_OOOO, ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
280         {EXIF_TAG_STRIP_OFFSETS, "StripOffsets", N_("Strip Offsets"),
281          N_("For each strip, the byte offset of that strip. It is "
282             "recommended that this be selected so the number of strip "
283             "bytes does not exceed 64 Kbytes. With JPEG compressed "
284             "data this designation is not needed and is omitted. See also "
285             "<RowsPerStrip> and <StripByteCounts>."),
286          { ESL_MMMN, ESL_MMMN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
287         {EXIF_TAG_ORIENTATION, "Orientation", N_("Orientation"),
288          N_("The image orientation viewed in terms of rows and columns."),
289          { ESL_OOOO, ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
290         {EXIF_TAG_SAMPLES_PER_PIXEL, "SamplesPerPixel",
291          N_("Samples per Pixel"),
292          N_("The number of components per pixel. Since this standard applies "
293             "to RGB and YCbCr images, the value set for this tag is 3. "
294             "In JPEG compressed data a JPEG marker is used instead of this "
295             "tag."), 
296          { ESL_MMMN, ESL_MMMN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
297         {EXIF_TAG_ROWS_PER_STRIP, "RowsPerStrip", N_("Rows per Strip"),
298          N_("The number of rows per strip. This is the number of rows "
299             "in the image of one strip when an image is divided into "
300             "strips. With JPEG compressed data this designation is not "
301             "needed and is omitted. See also <StripOffsets> and "
302             "<StripByteCounts>."),
303          { ESL_MMMN, ESL_MMMN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
304         {EXIF_TAG_STRIP_BYTE_COUNTS, "StripByteCounts", N_("Strip Byte Count"),
305          N_("The total number of bytes in each strip. With JPEG compressed "
306             "data this designation is not needed and is omitted."),
307          { ESL_MMMN, ESL_MMMN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
308         {EXIF_TAG_X_RESOLUTION, "XResolution", N_("X-Resolution"),
309          N_("The number of pixels per <ResolutionUnit> in the <ImageWidth> "
310             "direction. When the image resolution is unknown, 72 [dpi] "
311             "is designated."),
312          { ESL_MMMM, ESL_MMMM, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
313         {EXIF_TAG_Y_RESOLUTION, "YResolution", N_("Y-Resolution"),
314          N_("The number of pixels per <ResolutionUnit> in the <ImageLength> "
315             "direction. The same value as <XResolution> is designated."),
316          { ESL_MMMM, ESL_MMMM, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
317         {EXIF_TAG_PLANAR_CONFIGURATION, "PlanarConfiguration",
318          N_("Planar Configuration"),
319          N_("Indicates whether pixel components are recorded in a chunky "
320             "or planar format. In JPEG compressed files a JPEG marker "
321             "is used instead of this tag. If this field does not exist, "
322             "the TIFF default of 1 (chunky) is assumed."),
323          { ESL_OMON, ESL_OMON, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
324         {EXIF_TAG_RESOLUTION_UNIT, "ResolutionUnit", N_("Resolution Unit"),
325          N_("The unit for measuring <XResolution> and <YResolution>. The same "
326             "unit is used for both <XResolution> and <YResolution>. If "
327             "the image resolution is unknown, 2 (inches) is designated."),
328          { ESL_MMMM, ESL_MMMM, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
329         {EXIF_TAG_TRANSFER_FUNCTION, "TransferFunction",
330          N_("Transfer Function"),
331          N_("A transfer function for the image, described in tabular style. "
332             "Normally this tag is not necessary, since color space is "
333             "specified in the color space information tag (<ColorSpace>)."),
334          { ESL_OOOO, ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
335         {EXIF_TAG_SOFTWARE, "Software", N_("Software"),
336          N_("This tag records the name and version of the software or "
337             "firmware of the camera or image input device used to "
338             "generate the image. The detailed format is not specified, but "
339             "it is recommended that the example shown below be "
340             "followed. When the field is left blank, it is treated as "
341             "unknown."),
342          { ESL_OOOO, ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
343         {EXIF_TAG_DATE_TIME, "DateTime", N_("Date and Time"),
344          N_("The date and time of image creation. In this standard "
345             "(EXIF-2.1) it is the date and time the file was changed."),
346          { ESL_OOOO, ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
347         {EXIF_TAG_ARTIST, "Artist", N_("Artist"),
348          N_("This tag records the name of the camera owner, photographer or "
349             "image creator. The detailed format is not specified, but it is "
350             "recommended that the information be written as in the example "
351             "below for ease of Interoperability. When the field is "
352             "left blank, it is treated as unknown."),
353          { ESL_OOOO, ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
354         {EXIF_TAG_WHITE_POINT, "WhitePoint", N_("White Point"),
355          N_("The chromaticity of the white point of the image. Normally "
356             "this tag is not necessary, since color space is specified "
357             "in the color space information tag (<ColorSpace>)."),
358          { ESL_OOOO, ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
359         {EXIF_TAG_PRIMARY_CHROMATICITIES, "PrimaryChromaticities",
360          N_("Primary Chromaticities"),
361          N_("The chromaticity of the three primary colors of the image. "
362             "Normally this tag is not necessary, since color space is "
363             "specified in the color space information tag (<ColorSpace>)."),
364          { ESL_OOOO, ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
365         /* Not in EXIF 2.2 */
366         {EXIF_TAG_SUB_IFDS, "SubIFDs", "SubIFD Offsets", N_("Defined by Adobe Corporation "
367             "to enable TIFF Trees within a TIFF file."), ESL_UNKNOWN},
368         /* Not in EXIF 2.2 */
369         {EXIF_TAG_TRANSFER_RANGE, "TransferRange", N_("Transfer Range"), "",
370          ESL_UNKNOWN},
371         /* Not in EXIF 2.2 */
372         {EXIF_TAG_JPEG_PROC, "JPEGProc", "JPEGProc", "", ESL_UNKNOWN},
373         {EXIF_TAG_JPEG_INTERCHANGE_FORMAT, "JPEGInterchangeFormat",
374          N_("JPEG Interchange Format"),
375          N_("The offset to the start byte (SOI) of JPEG compressed "
376             "thumbnail data. This is not used for primary image "
377             "JPEG data."),
378          { ESL_NNNN, ESL_NNNM, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
379         {EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH,
380          "JPEGInterchangeFormatLength", N_("JPEG Interchange Format Length"),
381          N_("The number of bytes of JPEG compressed thumbnail data. This "
382             "is not used for primary image JPEG data. JPEG thumbnails "
383             "are not divided but are recorded as a continuous JPEG "
384             "bitstream from SOI to EOI. Appn and COM markers should "
385             "not be recorded. Compressed thumbnails must be recorded in no "
386             "more than 64 Kbytes, including all other data to be "
387             "recorded in APP1."),
388          { ESL_NNNN, ESL_NNNM, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
389         {EXIF_TAG_YCBCR_COEFFICIENTS, "YCbCrCoefficients",
390          N_("YCbCr Coefficients"),
391          N_("The matrix coefficients for transformation from RGB to YCbCr "
392             "image data. No default is given in TIFF; but here the "
393             "value given in \"Color Space Guidelines\", is used "
394             "as the default. The color space is declared in a "
395             "color space information tag, with the default being the value "
396             "that gives the optimal image characteristics "
397             "Interoperability this condition."),
398          { ESL_NNOO, ESL_NNOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
399         {EXIF_TAG_YCBCR_SUB_SAMPLING, "YCbCrSubSampling",
400          N_("YCbCr Sub-Sampling"),
401          N_("The sampling ratio of chrominance components in relation to the "
402             "luminance component. In JPEG compressed data a JPEG marker "
403             "is used instead of this tag."),
404          { ESL_NNMN, ESL_NNMN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
405         {EXIF_TAG_YCBCR_POSITIONING, "YCbCrPositioning",
406          N_("YCbCr Positioning"),
407          N_("The position of chrominance components in relation to the "
408             "luminance component. This field is designated only for "
409             "JPEG compressed data or uncompressed YCbCr data. The TIFF "
410             "default is 1 (centered); but when Y:Cb:Cr = 4:2:2 it is "
411             "recommended in this standard that 2 (co-sited) be used to "
412             "record data, in order to improve the image quality when viewed "
413             "on TV systems. When this field does not exist, the reader shall "
414             "assume the TIFF default. In the case of Y:Cb:Cr = 4:2:0, the "
415             "TIFF default (centered) is recommended. If the reader "
416             "does not have the capability of supporting both kinds of "
417             "<YCbCrPositioning>, it shall follow the TIFF default regardless "
418             "of the value in this field. It is preferable that readers "
419             "be able to support both centered and co-sited positioning."),
420          { ESL_NNMM, ESL_NNOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
421         {EXIF_TAG_REFERENCE_BLACK_WHITE, "ReferenceBlackWhite",
422          N_("Reference Black/White"),
423          N_("The reference black point value and reference white point "
424             "value. No defaults are given in TIFF, but the values "
425             "below are given as defaults here. The color space is declared "
426             "in a color space information tag, with the default "
427             "being the value that gives the optimal image characteristics "
428             "Interoperability these conditions."),
429          { ESL_OOOO, ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
430         /* Not in EXIF 2.2 */
431         {EXIF_TAG_XML_PACKET, "XMLPacket", N_("XML Packet"), N_("XMP Metadata"),
432          ESL_UNKNOWN},
433         /* Not in EXIF 2.2 */
434         {EXIF_TAG_RELATED_IMAGE_FILE_FORMAT, "RelatedImageFileFormat",
435          "RelatedImageFileFormat", "", ESL_UNKNOWN},
436         /* Not in EXIF 2.2 */
437         {EXIF_TAG_RELATED_IMAGE_WIDTH, "RelatedImageWidth",
438          "RelatedImageWidth", "", ESL_UNKNOWN},
439         /* Not in EXIF 2.2 */
440         {EXIF_TAG_RELATED_IMAGE_LENGTH, "RelatedImageLength",
441          "RelatedImageLength", "", ESL_UNKNOWN},
442         /* Not in EXIF 2.2 */
443         {EXIF_TAG_CFA_REPEAT_PATTERN_DIM, "CFARepeatPatternDim",
444          "CFARepeatPatternDim", "", ESL_UNKNOWN},
445         /* Not in EXIF 2.2 */
446         {EXIF_TAG_CFA_PATTERN, "CFAPattern",
447          N_("CFA Pattern"),
448          N_("Indicates the color filter array (CFA) geometric pattern of the "
449             "image sensor when a one-chip color area sensor is used. "
450             "It does not apply to all sensing methods."), ESL_UNKNOWN},
451         /* Not in EXIF 2.2 */
452         {EXIF_TAG_BATTERY_LEVEL, "BatteryLevel", N_("Battery Level"), "",
453          ESL_UNKNOWN},
454         {EXIF_TAG_COPYRIGHT, "Copyright", N_("Copyright"),
455          N_("Copyright information. In this standard the tag is used to "
456             "indicate both the photographer and editor copyrights. It is "
457             "the copyright notice of the person or organization claiming "
458             "rights to the image. The Interoperability copyright "
459             "statement including date and rights should be written in this "
460             "field; e.g., \"Copyright, John Smith, 19xx. All rights "
461             "reserved.\". In this standard the field records both the "
462             "photographer and editor copyrights, with each recorded in a "
463             "separate part of the statement. When there is a clear "
464             "distinction between the photographer and editor copyrights, "
465             "these are to be written in the order of photographer followed "
466             "by editor copyright, separated by NULL (in this case, "
467             "since the statement also ends with a NULL, there are two NULL "
468             "codes) (see example 1). When only the photographer is given, "
469             "it is terminated by one NULL code (see example 2). When only "
470             "the editor copyright is given, "
471             "the photographer copyright part consists of one space followed "
472             "by a terminating NULL code, then the editor copyright is given "
473             "(see example 3). When the field is left blank, it is treated "
474             "as unknown."),
475          { ESL_OOOO, ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
476         {EXIF_TAG_EXPOSURE_TIME, "ExposureTime", N_("Exposure Time"),
477          N_("Exposure time, given in seconds (sec)."),
478          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
479         {EXIF_TAG_FNUMBER, "FNumber", N_("F-Number"),
480          N_("The F number."),
481          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
482         /* Not in EXIF 2.2 */
483         {EXIF_TAG_IPTC_NAA, "IPTC/NAA", "IPTC/NAA", "", ESL_UNKNOWN},
484         /* Not in EXIF 2.2 */
485         {EXIF_TAG_IMAGE_RESOURCES, "ImageResources", N_("Image Resources Block"), "",
486          ESL_UNKNOWN},
487         {EXIF_TAG_EXIF_IFD_POINTER, "ExifIfdPointer", "ExifIFDPointer",
488          N_("A pointer to the Exif IFD. Interoperability, Exif IFD has the "
489             "same structure as that of the IFD specified in TIFF. "
490             "ordinarily, however, it does not contain image data as in "
491             "the case of TIFF."),
492          { ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
493         /* Not in EXIF 2.2 */
494         {EXIF_TAG_INTER_COLOR_PROFILE, "InterColorProfile",
495          "InterColorProfile", "", ESL_UNKNOWN},
496         {EXIF_TAG_EXPOSURE_PROGRAM, "ExposureProgram", N_("Exposure Program"),
497          N_("The class of the program used by the camera to set exposure "
498             "when the picture is taken."),
499          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
500         {EXIF_TAG_SPECTRAL_SENSITIVITY, "SpectralSensitivity",
501          N_("Spectral Sensitivity"),
502          N_("Indicates the spectral sensitivity of each channel of the "
503             "camera used. The tag value is an ASCII string compatible "
504             "with the standard developed by the ASTM Technical Committee."),
505          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
506         {EXIF_TAG_GPS_INFO_IFD_POINTER, "GPSInfoIFDPointer", 
507          N_("GPS Info IFD Pointer"),
508          N_("A pointer to the GPS Info IFD. The "
509             "Interoperability structure of the GPS Info IFD, like that of "
510             "Exif IFD, has no image data."),
511          { ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
512
513         {EXIF_TAG_ISO_SPEED_RATINGS, "ISOSpeedRatings",
514          N_("ISO Speed Ratings"),
515          N_("Indicates the ISO Speed and ISO Latitude of the camera or "
516             "input device as specified in ISO 12232."),
517          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
518         {EXIF_TAG_OECF, "OECF", N_("Opto-Electronic Conversion Function"),
519          N_("Indicates the Opto-Electronic Conversion Function (OECF) "
520             "specified in ISO 14524. <OECF> is the relationship between "
521             "the camera optical input and the image values."),
522          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
523         /* Not in EXIF 2.2 */
524         {EXIF_TAG_TIME_ZONE_OFFSET, "TimeZoneOffset", N_("Time Zone Offset"),
525          N_("Encodes time zone of camera clock relative to GMT."),
526          ESL_UNKNOWN},
527         {EXIF_TAG_EXIF_VERSION, "ExifVersion", N_("Exif Version"),
528          N_("The version of this standard supported. Nonexistence of this "
529             "field is taken to mean nonconformance to the standard."),
530          { ESL_NNNN, ESL_NNNN, ESL_MMMM, ESL_NNNN, ESL_NNNN } },
531         {EXIF_TAG_DATE_TIME_ORIGINAL, "DateTimeOriginal",
532          N_("Date and Time (Original)"),
533          N_("The date and time when the original image data was generated. "
534             "For a digital still camera "
535             "the date and time the picture was taken are recorded."),
536          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
537         {EXIF_TAG_DATE_TIME_DIGITIZED, "DateTimeDigitized",
538          N_("Date and Time (Digitized)"),
539          N_("The date and time when the image was stored as digital data."),
540          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
541         {EXIF_TAG_COMPONENTS_CONFIGURATION, "ComponentsConfiguration",
542          N_("Components Configuration"),
543          N_("Information specific to compressed data. The channels of "
544             "each component are arranged in order from the 1st "
545             "component to the 4th. For uncompressed data the data "
546             "arrangement is given in the <PhotometricInterpretation> tag. "
547             "However, since <PhotometricInterpretation> can only "
548             "express the order of Y, Cb and Cr, this tag is provided "
549             "for cases when compressed data uses components other than "
550             "Y, Cb, and Cr and to enable support of other sequences."),
551          { ESL_NNNN, ESL_NNNN, ESL_NNNM, ESL_NNNN, ESL_NNNN } },
552         {EXIF_TAG_COMPRESSED_BITS_PER_PIXEL, "CompressedBitsPerPixel",
553          N_("Compressed Bits per Pixel"),
554          N_("Information specific to compressed data. The compression mode "
555             "used for a compressed image is indicated in unit bits "
556             "per pixel."),
557          { ESL_NNNN, ESL_NNNN, ESL_NNNO, ESL_NNNN, ESL_NNNN } },
558         {EXIF_TAG_SHUTTER_SPEED_VALUE, "ShutterSpeedValue", N_("Shutter Speed"),
559          N_("Shutter speed. The unit is the APEX (Additive System of "
560             "Photographic Exposure) setting."),
561          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
562         {EXIF_TAG_APERTURE_VALUE, "ApertureValue", N_("Aperture"),
563          N_("The lens aperture. The unit is the APEX value."),
564          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
565         {EXIF_TAG_BRIGHTNESS_VALUE, "BrightnessValue", N_("Brightness"),
566          N_("The value of brightness. The unit is the APEX value. "
567             "Ordinarily it is given in the range of -99.99 to 99.99."),
568          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
569         {EXIF_TAG_EXPOSURE_BIAS_VALUE, "ExposureBiasValue",
570          N_("Exposure Bias"),
571          N_("The exposure bias. The units is the APEX value. Ordinarily "
572             "it is given in the range of -99.99 to 99.99."),
573          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
574         {EXIF_TAG_MAX_APERTURE_VALUE, "MaxApertureValue", N_("Maximum Aperture Value"),
575          N_("The smallest F number of the lens. The unit is the APEX value. "
576             "Ordinarily it is given in the range of 00.00 to 99.99, "
577             "but it is not limited to this range."),
578          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
579         {EXIF_TAG_SUBJECT_DISTANCE, "SubjectDistance",
580          N_("Subject Distance"),
581          N_("The distance to the subject, given in meters."),
582          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
583         {EXIF_TAG_METERING_MODE, "MeteringMode", N_("Metering Mode"),
584          N_("The metering mode."),
585          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
586         {EXIF_TAG_LIGHT_SOURCE, "LightSource", N_("Light Source"),
587          N_("The kind of light source."),
588          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
589         {EXIF_TAG_FLASH, "Flash", N_("Flash"),
590          N_("This tag is recorded when an image is taken using a strobe "
591             "light (flash)."),
592          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
593         {EXIF_TAG_FOCAL_LENGTH, "FocalLength", N_("Focal Length"),
594          N_("The actual focal length of the lens, in mm. Conversion is not "
595             "made to the focal length of a 35 mm film camera."),
596          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
597         {EXIF_TAG_SUBJECT_AREA, "SubjectArea", N_("Subject Area"),
598          N_("This tag indicates the location and area of the main subject "
599             "in the overall scene."),
600          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
601         /* Not in EXIF 2.2 */
602         {EXIF_TAG_TIFF_EP_STANDARD_ID, "TIFF/EPStandardID", N_("TIFF/EP Standard ID"), "",
603          ESL_UNKNOWN},
604         {EXIF_TAG_MAKER_NOTE, "MakerNote", N_("Maker Note"),
605          N_("A tag for manufacturers of Exif writers to record any desired "
606             "information. The contents are up to the manufacturer."),
607          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
608         {EXIF_TAG_USER_COMMENT, "UserComment", N_("User Comment"),
609          N_("A tag for Exif users to write keywords or comments on the image "
610             "besides those in <ImageDescription>, and without the "
611             "character code limitations of the <ImageDescription> tag. The "
612             "character code used in the <UserComment> tag is identified "
613             "based on an ID code in a fixed 8-byte area at the start of "
614             "the tag data area. The unused portion of the area is padded "
615             "with NULL (\"00.h\"). ID codes are assigned by means of "
616             "registration. The designation method and references for each "
617             "character code are defined in the specification. The value of "
618             "CountN is determined based on the 8 bytes in the character code "
619             "area and the number of bytes in the user comment part. Since "
620             "the TYPE is not ASCII, NULL termination is not necessary. "
621             "The ID code for the <UserComment> area may be a Defined code "
622             "such as JIS or ASCII, or may be Undefined. The Undefined name "
623             "is UndefinedText, and the ID code is filled with 8 bytes of all "
624             "\"NULL\" (\"00.H\"). An Exif reader that reads the "
625             "<UserComment> tag must have a function for determining the "
626             "ID code. This function is not required in Exif readers that "
627             "do not use the <UserComment> tag. "
628             "When a <UserComment> area is set aside, it is recommended that "
629             "the ID code be ASCII and that the following user comment "
630             "part be filled with blank characters [20.H]."),
631          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
632         {EXIF_TAG_SUB_SEC_TIME, "SubsecTime", N_("Sub-second Time"),
633          N_("A tag used to record fractions of seconds for the "
634             "<DateTime> tag."),
635          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
636         {EXIF_TAG_SUB_SEC_TIME_ORIGINAL, "SubSecTimeOriginal",
637          N_("Sub-second Time (Original)"),
638          N_("A tag used to record fractions of seconds for the "
639             "<DateTimeOriginal> tag."),
640          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
641         {EXIF_TAG_SUB_SEC_TIME_DIGITIZED, "SubSecTimeDigitized",
642          N_("Sub-second Time (Digitized)"),
643          N_("A tag used to record fractions of seconds for the "
644             "<DateTimeDigitized> tag."),
645          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
646         /* Not in EXIF 2.2 (Microsoft extension) */
647         {EXIF_TAG_XP_TITLE, "XPTitle", N_("XP Title"),
648          N_("A character string giving the title of the image, encoded in "
649             "UTF-16LE."),
650          { ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
651         /* Not in EXIF 2.2 (Microsoft extension) */
652         {EXIF_TAG_XP_COMMENT, "XPComment", N_("XP Comment"), 
653          N_("A character string containing a comment about the image, encoded "
654             "in UTF-16LE."),
655          { ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
656         /* Not in EXIF 2.2 (Microsoft extension) */
657         {EXIF_TAG_XP_AUTHOR, "XPAuthor", N_("XP Author"), 
658          N_("A character string containing the name of the image creator, "
659             "encoded in UTF-16LE."),
660          { ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
661         /* Not in EXIF 2.2 (Microsoft extension) */
662         {EXIF_TAG_XP_KEYWORDS, "XPKeywords", N_("XP Keywords"), 
663          N_("A character string containing key words describing the image, "
664             "encoded in UTF-16LE."),
665          { ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
666         /* Not in EXIF 2.2 (Microsoft extension) */
667         {EXIF_TAG_XP_SUBJECT, "XPSubject", N_("XP Subject"), 
668          N_("A character string giving the image subject, encoded in "
669             "UTF-16LE."),
670          { ESL_OOOO, ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
671         {EXIF_TAG_FLASH_PIX_VERSION, "FlashPixVersion", "FlashPixVersion",
672          N_("The FlashPix format version supported by a FPXR file."),
673          { ESL_NNNN, ESL_NNNN, ESL_MMMM, ESL_NNNN, ESL_NNNN } },
674         {EXIF_TAG_COLOR_SPACE, "ColorSpace", N_("Color Space"),
675          N_("The color space information tag is always "
676             "recorded as the color space specifier. Normally sRGB (=1) "
677             "is used to define the color space based on the PC monitor "
678             "conditions and environment. If a color space other than "
679             "sRGB is used, Uncalibrated (=FFFF.H) is set. Image data "
680             "recorded as Uncalibrated can be treated as sRGB when it is "
681             "converted to FlashPix."),
682          { ESL_NNNN, ESL_NNNN, ESL_MMMM, ESL_NNNN, ESL_NNNN } },
683         {EXIF_TAG_PIXEL_X_DIMENSION, "PixelXDimension", N_("Pixel X Dimension"),
684          N_("Information specific to compressed data. When a "
685             "compressed file is recorded, the valid width of the "
686             "meaningful image must be recorded in this tag, whether or "
687             "not there is padding data or a restart marker. This tag "
688             "should not exist in an uncompressed file."),
689          { ESL_NNNN, ESL_NNNN, ESL_NNNM, ESL_NNNN, ESL_NNNN } },
690         {EXIF_TAG_PIXEL_Y_DIMENSION, "PixelYDimension", N_("Pixel Y Dimension"),
691          N_("Information specific to compressed data. When a compressed "
692             "file is recorded, the valid height of the meaningful image "
693             "must be recorded in this tag, whether or not there is padding "
694             "data or a restart marker. This tag should not exist in an "
695             "uncompressed file. "
696             "Since data padding is unnecessary in the vertical direction, "
697             "the number of lines recorded in this valid image height tag "
698             "will in fact be the same as that recorded in the SOF."),
699          { ESL_NNNN, ESL_NNNN, ESL_NNNM, ESL_NNNN, ESL_NNNN } },
700         {EXIF_TAG_RELATED_SOUND_FILE, "RelatedSoundFile",
701          N_("Related Sound File"),
702          N_("This tag is used to record the name of an audio file related "
703             "to the image data. The only relational information "
704             "recorded here is the Exif audio file name and extension (an "
705             "ASCII string consisting of 8 characters + '.' + 3 "
706             "characters). The path is not recorded. Stipulations on audio "
707             "and file naming conventions are defined in the specification. "
708             "When using this tag, audio files must be recorded in "
709             "conformance to the Exif audio format. Writers are also allowed "
710             "to store the data such as Audio within APP2 as FlashPix "
711             "extension stream data. "
712             "The mapping of Exif image files and audio files is done "
713             "in any of three ways, [1], [2] and [3]. If multiple files "
714             "are mapped to one file as in [2] or [3], the above "
715             "format is used to record just one audio file name. If "
716             "there are multiple audio files, the first recorded file is "
717             "given. In the case of [3], for example, for the "
718             "Exif image file \"DSC00001.JPG\" only  \"SND00001.WAV\" is "
719             "given as the related Exif audio file. When there are three "
720             "Exif audio files \"SND00001.WAV\", \"SND00002.WAV\" and "
721             "\"SND00003.WAV\", the Exif image file name for each of them, "
722             "\"DSC00001.JPG\", is indicated. By combining multiple "
723             "relational information, a variety of playback possibilities "
724             "can be supported. The method of using relational information "
725             "is left to the implementation on the playback side. Since this "
726             "information is an ASCII character string, it is terminated by "
727             "NULL. When this tag is used to map audio files, the relation "
728             "of the audio file to image data must also be indicated on the "
729             "audio file end."),
730          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
731         {EXIF_TAG_INTEROPERABILITY_IFD_POINTER, "InteroperabilityIFDPointer",
732          N_("Interoperability IFD Pointer"),
733          N_("Interoperability IFD is composed of tags which stores the "
734             "information to ensure the Interoperability and pointed "
735             "by the following tag located in Exif IFD. "
736             "The Interoperability structure of Interoperability IFD is "
737             "the same as TIFF defined IFD structure "
738             "but does not contain the "
739             "image data characteristically compared with normal TIFF "
740             "IFD."),
741          { ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_NNNN } },
742         {EXIF_TAG_FLASH_ENERGY, "FlashEnergy", N_("Flash Energy"),
743          N_("Indicates the strobe energy at the time the image is "
744             "captured, as measured in Beam Candle Power Seconds (BCPS)."),
745          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
746         {EXIF_TAG_SPATIAL_FREQUENCY_RESPONSE, "SpatialFrequencyResponse",
747          N_("Spatial Frequency Response"),
748          N_("This tag records the camera or input device spatial frequency "
749             "table and SFR values in the direction of image width, "
750             "image height, and diagonal direction, as specified in ISO "
751             "12233."),
752          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
753         {EXIF_TAG_FOCAL_PLANE_X_RESOLUTION, "FocalPlaneXResolution",
754          N_("Focal Plane X-Resolution"),
755          N_("Indicates the number of pixels in the image width (X) direction "
756             "per <FocalPlaneResolutionUnit> on the camera focal plane."),
757          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
758         {EXIF_TAG_FOCAL_PLANE_Y_RESOLUTION, "FocalPlaneYResolution",
759          N_("Focal Plane Y-Resolution"),
760          N_("Indicates the number of pixels in the image height (V) direction "
761             "per <FocalPlaneResolutionUnit> on the camera focal plane."),
762          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
763         {EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT, "FocalPlaneResolutionUnit",
764          N_("Focal Plane Resolution Unit"),
765          N_("Indicates the unit for measuring <FocalPlaneXResolution> and "
766             "<FocalPlaneYResolution>. This value is the same as the "
767             "<ResolutionUnit>."),
768          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
769         {EXIF_TAG_SUBJECT_LOCATION, "SubjectLocation",
770          N_("Subject Location"),
771          N_("Indicates the location of the main subject in the scene. The "
772             "value of this tag represents the pixel at the center of the "
773             "main subject relative to the left edge, prior to rotation "
774             "processing as per the <Rotation> tag. The first value "
775             "indicates the X column number and the second indicates "
776             "the Y row number."),
777          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
778         {EXIF_TAG_EXPOSURE_INDEX, "ExposureIndex", N_("Exposure Index"),
779          N_("Indicates the exposure index selected on the camera or "
780             "input device at the time the image is captured."),
781          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
782         {EXIF_TAG_SENSING_METHOD, "SensingMethod", N_("Sensing Method"),
783          N_("Indicates the image sensor type on the camera or input "
784             "device."),
785          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
786         {EXIF_TAG_FILE_SOURCE, "FileSource", N_("File Source"),
787          N_("Indicates the image source. If a DSC recorded the image, "
788             "the tag value of this tag always be set to 3, indicating "
789             "that the image was recorded on a DSC."),
790          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
791         {EXIF_TAG_SCENE_TYPE, "SceneType", N_("Scene Type"),
792          N_("Indicates the type of scene. If a DSC recorded the image, "
793             "this tag value must always be set to 1, indicating that the "
794             "image was directly photographed."),
795          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
796         {EXIF_TAG_NEW_CFA_PATTERN, "CFAPattern",
797          N_("CFA Pattern"),
798          N_("Indicates the color filter array (CFA) geometric pattern of the "
799             "image sensor when a one-chip color area sensor is used. "
800             "It does not apply to all sensing methods."),
801          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
802         {EXIF_TAG_CUSTOM_RENDERED, "CustomRendered", N_("Custom Rendered"),
803          N_("This tag indicates the use of special processing on image "
804             "data, such as rendering geared to output. When special "
805             "processing is performed, the reader is expected to disable "
806             "or minimize any further processing."),
807          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
808         {EXIF_TAG_EXPOSURE_MODE, "ExposureMode", N_("Exposure Mode"),
809          N_("This tag indicates the exposure mode set when the image was "
810             "shot. In auto-bracketing mode, the camera shoots a series of "
811             "frames of the same scene at different exposure settings."),
812          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
813         {EXIF_TAG_WHITE_BALANCE, "WhiteBalance", N_("White Balance"),
814          N_("This tag indicates the white balance mode set when the image "
815             "was shot."),
816          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
817         {EXIF_TAG_DIGITAL_ZOOM_RATIO, "DigitalZoomRatio",
818          N_("Digital Zoom Ratio"),
819          N_("This tag indicates the digital zoom ratio when the image was "
820             "shot. If the numerator of the recorded value is 0, this "
821             "indicates that digital zoom was not used."),
822          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
823         {EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM, "FocalLengthIn35mmFilm",
824          N_("Focal Length in 35mm Film"),
825          N_("This tag indicates the equivalent focal length assuming a "
826             "35mm film camera, in mm. A value of 0 means the focal "
827             "length is unknown. Note that this tag differs from the "
828             "FocalLength tag."),
829          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
830         {EXIF_TAG_SCENE_CAPTURE_TYPE, "SceneCaptureType",
831          N_("Scene Capture Type"),
832          N_("This tag indicates the type of scene that was shot. It can "
833             "also be used to record the mode in which the image was "
834             "shot. Note that this differs from the scene type "
835             "<SceneType> tag."),
836          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
837         {EXIF_TAG_GAIN_CONTROL, "GainControl", N_("Gain Control"),
838          N_("This tag indicates the degree of overall image gain "
839             "adjustment."),
840          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
841         {EXIF_TAG_CONTRAST, "Contrast", N_("Contrast"),
842          N_("This tag indicates the direction of contrast processing "
843             "applied by the camera when the image was shot."),
844          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
845         {EXIF_TAG_SATURATION, "Saturation", N_("Saturation"),
846          N_("This tag indicates the direction of saturation processing "
847             "applied by the camera when the image was shot."),
848          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
849         {EXIF_TAG_SHARPNESS, "Sharpness", N_("Sharpness"),
850          N_("This tag indicates the direction of sharpness processing "
851             "applied by the camera when the image was shot."),
852          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
853         {EXIF_TAG_DEVICE_SETTING_DESCRIPTION, "DeviceSettingDescription",
854          N_("Device Setting Description"),
855          N_("This tag indicates information on the picture-taking "
856             "conditions of a particular camera model. The tag is used "
857             "only to indicate the picture-taking conditions in the "
858             "reader."),
859          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
860         {EXIF_TAG_SUBJECT_DISTANCE_RANGE, "SubjectDistanceRange",
861          N_("Subject Distance Range"),
862          N_("This tag indicates the distance to the subject."),
863          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
864         {EXIF_TAG_IMAGE_UNIQUE_ID, "ImageUniqueID", N_("Image Unique ID"),
865          N_("This tag indicates an identifier assigned uniquely to "
866             "each image. It is recorded as an ASCII string equivalent "
867             "to hexadecimal notation and 128-bit fixed length."),
868          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
869         /* EXIF 2.3 */
870         {EXIF_TAG_CAMERA_OWNER_NAME, "CameraOwnerName", N_("Camera Owner Name"),
871          N_("This tag indicates the name of the camera owner, "
872             "photographer or image creator."),
873          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
874         /* EXIF 2.3 */
875         {EXIF_TAG_BODY_SERIAL_NUMBER, "BodySerialNumber", N_("Body Serial Number"),
876          N_("This tag indicates the serial number of the body of the camera"),
877          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
878         /* EXIF 2.3 */
879         {EXIF_TAG_LENS_SPECIFICATION, "LensSpecification", N_("Lens Specification"),
880          N_("This tag indicates minimum focal length, "
881             "maximum focal length, minimum F number in the "
882             "minimum focal length, and minimum F number in "
883             "the maximum focal length."),
884          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
885         /* EXIF 2.3 */
886         {EXIF_TAG_LENS_MAKE, "LensMake", N_("Lens Make"),
887          N_("This tag indicates the lens manufacturer."),
888          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
889         /* EXIF 2.3 */
890         {EXIF_TAG_LENS_MODEL, "LensModel", N_("Lens Model"),
891          N_("This tag indicates the lens' model name and model number."),
892          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
893         /* EXIF 2.3 */
894         {EXIF_TAG_LENS_SERIAL_NUMBER, "LensSerialNumber", N_("Lens Serial Number"),
895          N_("This tag indicates the serial number of the interchangeable lens."),
896          { ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
897         /* Not in EXIF 2.2 */
898         {EXIF_TAG_GAMMA, "Gamma", N_("Gamma"),
899          N_("Indicates the value of coefficient gamma."),
900          ESL_UNKNOWN},
901         /* Not in EXIF 2.2 */
902         {EXIF_TAG_PRINT_IMAGE_MATCHING, "PrintImageMatching", N_("PRINT Image Matching"),
903          N_("Related to Epson's PRINT Image Matching technology"),
904          ESL_UNKNOWN},
905         /* Not in EXIF 2.2 (from the Microsoft HD Photo specification) */
906         {EXIF_TAG_PADDING, "Padding", N_("Padding"),
907          N_("This tag reserves space that can be reclaimed later when "
908             "additional metadata are added. New metadata can be written "
909             "in place by replacing this tag with a smaller data element "
910             "and using the reclaimed space to store the new or expanded "
911             "metadata tags."),
912          { ESL_OOOO, ESL_NNNN, ESL_OOOO, ESL_NNNN, ESL_NNNN } },
913 #endif
914         {0, NULL, NULL, NULL, ESL_UNKNOWN}
915 };
916
917 /* For now, do not use these functions. */
918
919 /*!
920  * Return the number of entries in the EXIF tag table, including the
921  * terminating NULL entry.
922  */
923 unsigned int
924 exif_tag_table_count (void)
925 {
926         return sizeof (ExifTagTable) / sizeof (ExifTagTable[0]);
927 }
928
929
930 ExifTag
931 exif_tag_table_get_tag (unsigned int n)
932 {
933         return (n < exif_tag_table_count ()) ? ExifTagTable[n].tag : 0;
934 }
935
936 const char *
937 exif_tag_table_get_name (unsigned int n)
938 {
939         return (n < exif_tag_table_count ()) ? ExifTagTable[n].name : NULL;
940 }
941
942 /*!
943  * Compares the tag with that in entry.
944  * \param[in] tag pointer to integer tag value
945  * \param[in] entry pointer to a struct TagEntry
946  * \return 0 if tags are equal, <0 if tag < entry, >0 if tag > entry
947  */
948 static int
949 match_tag(const void *tag, const void *entry)
950 {
951         return *(int*)tag - ((struct TagEntry *)entry)->tag;
952 }
953
954
955 /*!
956  * Finds the first entry in the EXIF tag table with the given tag number
957  * using a binary search.
958  * \param[in] tag to find
959  * \return index into table, or -1 if not found
960  */
961 static int
962 exif_tag_table_first(ExifTag tag)
963 {
964         int i;
965         struct TagEntry *entry = bsearch(&tag, ExifTagTable,
966                 exif_tag_table_count()-1, sizeof(struct TagEntry), match_tag);
967         if (!entry)
968                 return -1;      /* Not found */
969
970         /* Calculate index of found entry */
971         i = entry - ExifTagTable;
972
973         /* There may be other entries with the same tag number, so search
974          * backwards to find the first
975          */
976         while ((i > 0) && (ExifTagTable[i-1].tag == tag)) {
977                 --i;
978         }
979         return i;
980 }
981
982 #define RECORDED \
983 ((ExifTagTable[i].esl[ifd][EXIF_DATA_TYPE_UNCOMPRESSED_CHUNKY] != EXIF_SUPPORT_LEVEL_NOT_RECORDED) || \
984  (ExifTagTable[i].esl[ifd][EXIF_DATA_TYPE_UNCOMPRESSED_PLANAR] != EXIF_SUPPORT_LEVEL_NOT_RECORDED) || \
985  (ExifTagTable[i].esl[ifd][EXIF_DATA_TYPE_UNCOMPRESSED_YCC] != EXIF_SUPPORT_LEVEL_NOT_RECORDED) || \
986  (ExifTagTable[i].esl[ifd][EXIF_DATA_TYPE_COMPRESSED] != EXIF_SUPPORT_LEVEL_NOT_RECORDED))
987
988 const char *
989 exif_tag_get_name_in_ifd (ExifTag tag, ExifIfd ifd)
990 {
991         unsigned int i;
992         int first;
993
994         if (ifd >= EXIF_IFD_COUNT)
995                 return NULL;
996         first = exif_tag_table_first(tag);
997         if (first < 0)
998                 return NULL;
999
1000         for (i = first; ExifTagTable[i].name; i++) {
1001                 if (ExifTagTable[i].tag == tag) {
1002                    if (RECORDED)
1003                            break;
1004                 } else
1005                         return NULL; /* Recorded tag not found in the table */
1006         }
1007         return ExifTagTable[i].name;
1008 }
1009
1010 const char *
1011 exif_tag_get_title_in_ifd (ExifTag tag, ExifIfd ifd)
1012 {
1013         unsigned int i;
1014         int first;
1015
1016         if (ifd >= EXIF_IFD_COUNT)
1017                 return NULL;
1018         first = exif_tag_table_first(tag);
1019         if (first < 0)
1020                 return NULL;
1021
1022         for (i = first; ExifTagTable[i].name; i++) {
1023                 if (ExifTagTable[i].tag == tag) {
1024                    if (RECORDED)
1025                            break;
1026                 } else
1027                         return NULL; /* Recorded tag not found in the table */
1028         }
1029         (void) bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1030         return _(ExifTagTable[i].title);
1031 }
1032
1033 const char *
1034 exif_tag_get_description_in_ifd (ExifTag tag, ExifIfd ifd)
1035 {
1036         unsigned int i;
1037         int first;
1038
1039         if (ifd >= EXIF_IFD_COUNT)
1040                 return NULL;
1041         first = exif_tag_table_first(tag);
1042         if (first < 0)
1043                 return NULL;
1044
1045         for (i = first; ExifTagTable[i].name; i++) {
1046                 if (ExifTagTable[i].tag == tag) {
1047                         if (RECORDED)
1048                                 break;
1049                 } else
1050                         return NULL; /* Recorded tag not found in the table */
1051         }
1052
1053         /* GNU gettext acts strangely when given an empty string */
1054         if (!ExifTagTable[i].description || !*ExifTagTable[i].description)
1055                 return "";
1056
1057         /* libexif should use the default system locale.
1058          * If an application specifically requires UTF-8, then we
1059          * must give the application a way to tell libexif that.
1060          * 
1061          * bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1062          */
1063         (void) bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1064         return _(ExifTagTable[i].description);
1065 }
1066
1067
1068 /**********************************************************************
1069  * convenience functions
1070  **********************************************************************/
1071
1072 /* generic part: iterate through IFD list and return first result */
1073 typedef const char * (*get_stuff_func) (ExifTag tag, ExifIfd ifd);
1074
1075 static const char *
1076 exif_tag_get_stuff (ExifTag tag, get_stuff_func func)
1077 {
1078         /* Search IFDs in this order, in decreasing order of number of valid tags */
1079         static const ExifIfd ifds[EXIF_IFD_COUNT] = {
1080                 EXIF_IFD_EXIF,
1081                 EXIF_IFD_0,
1082                 EXIF_IFD_1,
1083                 EXIF_IFD_INTEROPERABILITY,
1084                 EXIF_IFD_GPS
1085         };
1086         int i;
1087         for (i=0; i<EXIF_IFD_COUNT; i++) {
1088                 const char *result = func(tag, ifds[i]);
1089                 if (result != NULL) {
1090                         return result;
1091                 }
1092         }
1093         return (const char *) NULL;
1094 }
1095
1096 /* explicit functions */
1097 const char *
1098 exif_tag_get_name (ExifTag tag)
1099 {
1100         return exif_tag_get_stuff(tag, exif_tag_get_name_in_ifd);
1101 }
1102
1103 const char *
1104 exif_tag_get_title (ExifTag tag)
1105 {
1106         return exif_tag_get_stuff(tag, exif_tag_get_title_in_ifd);
1107 }
1108
1109 const char *
1110 exif_tag_get_description (ExifTag tag)
1111 {
1112         return exif_tag_get_stuff(tag, exif_tag_get_description_in_ifd);
1113 }
1114
1115
1116
1117 ExifTag 
1118 exif_tag_from_name (const char *name)
1119 {
1120         unsigned int i;
1121         unsigned int result=0;
1122
1123         if (!name) return 0;
1124
1125         for (i = 0; ExifTagTable[i].name; i++)
1126                 if (!strcmp (ExifTagTable[i].name, name))  {
1127                         result = ExifTagTable[i].tag;
1128                         break;
1129                 }
1130         return result;
1131 }
1132
1133 /*! Return the support level of a tag in the given IFD with the given data
1134  * type. If the tag is not specified in the EXIF standard, this function
1135  * returns EXIF_SUPPORT_LEVEL_NOT_RECORDED.
1136  *
1137  * \param[in] tag EXIF tag
1138  * \param[in] ifd a valid IFD (not EXIF_IFD_COUNT)
1139  * \param[in] t a valid data type (not EXIF_DATA_TYPE_UNKNOWN)
1140  * \return the level of support for this tag
1141  */
1142 static inline ExifSupportLevel
1143 get_support_level_in_ifd (ExifTag tag, ExifIfd ifd, ExifDataType t)
1144 {
1145         unsigned int i;
1146         int first = exif_tag_table_first(tag);
1147         if (first < 0)
1148                 return EXIF_SUPPORT_LEVEL_NOT_RECORDED;
1149
1150         for (i = first; ExifTagTable[i].name; i++) {
1151                 if (ExifTagTable[i].tag == tag) {
1152                         const ExifSupportLevel supp = ExifTagTable[i].esl[ifd][t];
1153                         if (supp != EXIF_SUPPORT_LEVEL_NOT_RECORDED)
1154                                 return supp;
1155                         /* Try looking for another entry */
1156                 } else {
1157                         break; /* We've reached the end of the matching tags */
1158                 }
1159         }
1160         return EXIF_SUPPORT_LEVEL_NOT_RECORDED;
1161 }
1162
1163 /*! Return the support level of a tag in the given IFD, regardless of the
1164  * data type. If the support level varies depending on the data type, this
1165  * function returns EXIF_SUPPORT_LEVEL_UNKNOWN. If the tag is not specified
1166  * in the EXIF standard, this function returns EXIF_SUPPORT_LEVEL_UNKNOWN.
1167  *
1168  * \param[in] tag EXIF tag
1169  * \param[in] ifd a valid IFD (not EXIF_IFD_COUNT)
1170  * \return the level of support for this tag
1171  */
1172 static inline ExifSupportLevel
1173 get_support_level_any_type (ExifTag tag, ExifIfd ifd)
1174 {
1175         unsigned int i;
1176         int first = exif_tag_table_first(tag);
1177         if (first < 0)
1178                 return EXIF_SUPPORT_LEVEL_UNKNOWN;
1179
1180         for (i = first; ExifTagTable[i].name; i++) {
1181                 if (ExifTagTable[i].tag == tag) {
1182                         /*
1183                          * Check whether the support level is the same for all possible
1184                          * data types and isn't marked not recorded.
1185                          */
1186                         const ExifSupportLevel supp = ExifTagTable[i].esl[ifd][0];
1187                         /* If level is not recorded, keep searching for another */
1188                         if (supp != EXIF_SUPPORT_LEVEL_NOT_RECORDED) {
1189                                 unsigned int dt;
1190                                 for (dt = 0; dt < EXIF_DATA_TYPE_COUNT; ++dt) {
1191                                         if (ExifTagTable[i].esl[ifd][dt] != supp)
1192                                                 break;
1193                                 }
1194                                 if (dt == EXIF_DATA_TYPE_COUNT)
1195                                         /* Support level is always the same, so return it */
1196                                         return supp;
1197                         }
1198                         /* Keep searching the table for another tag for our IFD */
1199                 } else {
1200                         break; /* We've reached the end of the matching tags */
1201                 }
1202         }
1203         return EXIF_SUPPORT_LEVEL_UNKNOWN;
1204 }
1205
1206 ExifSupportLevel
1207 exif_tag_get_support_level_in_ifd (ExifTag tag, ExifIfd ifd, ExifDataType t)
1208 {
1209         if (ifd >= EXIF_IFD_COUNT)
1210                 return EXIF_SUPPORT_LEVEL_UNKNOWN;
1211
1212         if (t >= EXIF_DATA_TYPE_COUNT)
1213                 return get_support_level_any_type (tag, ifd);
1214
1215         return get_support_level_in_ifd (tag, ifd, t);
1216 }