Mercurial > geeqie
annotate src/exif.h @ 47:aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
* exif.[ch]: Export several parsing functions for use by the exif
makernote parsers, and add hook for MakerNote data parsing.
* format_canon.[ch]: Add Canon EXIF MakerNote support.
* format_raw.c: Fix warning printf grammar.
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
##### an offical release when making enhancements and translation updates. #####
author | gqview |
---|---|
date | Fri, 03 Jun 2005 06:07:02 +0000 |
parents | d907d608745f |
children | 276ea4c98d33 |
rev | line source |
---|---|
9 | 1 /* |
2 * GQView | |
3 * (C) 2004 John Ellis | |
4 * | |
5 * Authors: | |
6 * Support for Exif file format, originally written by Eric Swalens. | |
7 * Modified by Quy Tonthat | |
8 * Reimplemented with generic data storage by John Ellis | |
9 * | |
10 | |
11 This program is free software; you can redistribute it and/or modify | |
12 it under the terms of the GNU General Public License as published by | |
13 the Free Software Foundation; either version 2 of the License, or | |
14 (at your option) any later version. | |
15 | |
16 This program is distributed in the hope that it will be useful, | |
17 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 GNU General Public License for more details. | |
20 | |
21 You should have received a copy of the GNU General Public License | |
22 along with this program; if not, write to the Free Software | |
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 */ | |
25 | |
26 #ifndef __EXIF_H | |
27 #define __EXIF_H | |
28 | |
29 | |
30 /* | |
31 *----------------------------------------------------------------------------- | |
32 * Tag formats | |
33 *----------------------------------------------------------------------------- | |
34 */ | |
35 | |
36 typedef enum { | |
37 EXIF_FORMAT_UNKNOWN = 0, | |
38 EXIF_FORMAT_BYTE_UNSIGNED = 1, | |
39 EXIF_FORMAT_STRING = 2, | |
40 EXIF_FORMAT_SHORT_UNSIGNED = 3, | |
41 EXIF_FORMAT_LONG_UNSIGNED = 4, | |
42 EXIF_FORMAT_RATIONAL_UNSIGNED = 5, | |
43 EXIF_FORMAT_BYTE = 6, | |
44 EXIF_FORMAT_UNDEFINED = 7, | |
45 EXIF_FORMAT_SHORT = 8, | |
46 EXIF_FORMAT_LONG = 9, | |
47 EXIF_FORMAT_RATIONAL = 10, | |
48 EXIF_FORMAT_FLOAT = 11, | |
49 EXIF_FORMAT_DOUBLE = 12 | |
50 } ExifFormatType; | |
51 | |
52 typedef struct _ExifFormatAttrib ExifFormatAttrib; | |
53 struct _ExifFormatAttrib | |
54 { | |
55 ExifFormatType type; | |
56 int size; | |
57 const char *short_name; | |
58 const char *description; | |
59 }; | |
60 | |
61 /* the list of known tag data formats */ | |
62 extern ExifFormatAttrib ExifFormatList[]; | |
63 | |
64 | |
65 /* | |
66 *----------------------------------------------------------------------------- | |
67 * Data storage | |
68 *----------------------------------------------------------------------------- | |
69 */ | |
70 | |
71 typedef struct _ExifData ExifData; | |
72 struct _ExifData | |
73 { | |
74 GList *items; /* list of (ExifItem *) */ | |
75 }; | |
76 | |
77 typedef struct _ExifRational ExifRational; | |
78 struct _ExifRational | |
79 { | |
80 unsigned long int num; | |
81 unsigned long int den; | |
82 }; | |
83 | |
84 | |
85 typedef struct _ExifItem ExifItem; | |
86 typedef struct _ExifMarker ExifMarker; | |
87 typedef struct _ExifTextList ExifTextList; | |
88 | |
89 struct _ExifItem | |
90 { | |
91 ExifFormatType format; | |
92 int tag; | |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
93 const ExifMarker *marker; |
9 | 94 int elements; |
95 gpointer data; | |
96 int data_len; | |
97 }; | |
98 | |
99 struct _ExifMarker | |
100 { | |
101 int tag; | |
102 ExifFormatType format; | |
103 int components; | |
104 char *key; | |
105 char *description; | |
106 ExifTextList *list; | |
107 }; | |
108 | |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
109 #define EXIF_MARKER_LIST_END { 0x0000, EXIF_FORMAT_UNKNOWN, 0, NULL, NULL, NULL } |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
110 |
9 | 111 struct _ExifTextList |
112 { | |
113 int value; | |
114 const char* description; | |
115 }; | |
116 | |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
117 #define EXIF_TEXT_LIST_END { -1, NULL } |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
118 |
9 | 119 |
120 typedef struct _ExifFormattedText ExifFormattedText; | |
121 struct _ExifFormattedText | |
122 { | |
123 const char *key; | |
124 const char *description; | |
125 }; | |
126 | |
127 | |
128 /* | |
129 *----------------------------------------------------------------------------- | |
130 * Data | |
131 *----------------------------------------------------------------------------- | |
132 */ | |
133 | |
134 /* enums useful for image manipulation */ | |
135 | |
136 typedef enum { | |
137 EXIF_ORIENTATION_UNKNOWN = 0, | |
138 EXIF_ORIENTATION_TOP_LEFT = 1, | |
139 EXIF_ORIENTATION_TOP_RIGHT = 2, | |
140 EXIF_ORIENTATION_BOTTOM_RIGHT = 3, | |
141 EXIF_ORIENTATION_BOTTOM_LEFT = 4, | |
142 EXIF_ORIENTATION_LEFT_TOP = 5, | |
143 EXIF_ORIENTATION_RIGHT_TOP = 6, | |
144 EXIF_ORIENTATION_RIGHT_BOTTOM = 7, | |
145 EXIF_ORIENTATION_LEFT_BOTTOM = 8 | |
146 } ExifOrientationType; | |
147 | |
148 typedef enum { | |
149 EXIF_UNIT_UNKNOWN = 0, | |
150 EXIF_UNIT_NOUNIT = 1, | |
151 EXIF_UNIT_INCH = 2, | |
152 EXIF_UNIT_CENTIMETER = 3 | |
153 } ExifUnitType; | |
154 | |
155 | |
156 /* the known exif tags list */ | |
157 extern ExifMarker ExifKnownMarkersList[]; | |
158 | |
159 /* the unknown tags utilize this generic list */ | |
160 extern ExifMarker ExifUnknownMarkersList[]; | |
161 | |
162 /* the list of specially formatted keys, for human readable output */ | |
163 extern ExifFormattedText ExifFormattedList[]; | |
164 | |
165 | |
166 /* | |
167 *----------------------------------------------------------------------------- | |
168 * functions | |
169 *----------------------------------------------------------------------------- | |
170 */ | |
171 | |
172 ExifData *exif_read(const gchar *path); | |
173 void exif_free(ExifData *exif); | |
174 | |
175 gchar *exif_get_data_as_text(ExifData *exif, const gchar *key); | |
176 gint exif_get_integer(ExifData *exif, const gchar *key, gint *value); | |
177 ExifRational *exif_get_rational(ExifData *exif, const gchar *key, gint *sign); | |
178 double exif_rational_to_double(ExifRational *r, gint sign); | |
179 | |
180 ExifItem *exif_get_item(ExifData *exif, const gchar *key); | |
181 | |
182 const char *exif_item_get_tag_name(ExifItem *item); | |
183 const char *exif_item_get_description(ExifItem *item); | |
184 const char *exif_item_get_format_name(ExifItem *item, gint brief); | |
185 gchar *exif_item_get_data_as_text(ExifItem *item); | |
186 gint exif_item_get_integer(ExifItem *item, gint *value); | |
187 ExifRational *exif_item_get_rational(ExifItem *item, gint *sign); | |
188 | |
189 const gchar *exif_get_description_by_key(const gchar *key); | |
190 | |
191 /* usually for debugging to stdout */ | |
192 void exif_write_data_list(ExifData *exif, FILE *f, gint human_readable_list); | |
193 | |
194 | |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
195 |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
196 /* These funcs for use by makernote parsers only */ |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
197 |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
198 ExifItem *exif_item_new(ExifFormatType format, unsigned int tag, |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
199 unsigned int elements, const ExifMarker *marker); |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
200 void exif_item_copy_data(ExifItem *item, void *src, int len, ExifFormatType src_format, int byte_order); |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
201 |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
202 gint exif_parse_IFD_table(ExifData *exif, |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
203 unsigned char *tiff, int offset, |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
204 int size, int byte_order, |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
205 const ExifMarker *list); |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
206 |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
207 |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
208 |
9 | 209 #endif |