Mercurial > geeqie.yaz
annotate src/exif.c @ 1320:055ed09d5a03
improved bar_sort configuration
author | nadvornik |
---|---|
date | Tue, 24 Feb 2009 22:21:28 +0000 |
parents | 2abdd6e50120 |
children | fe4da037be21 |
rev | line source |
---|---|
9 | 1 /* |
541 | 2 * Geeqie |
3 * (C) 2006 John Ellis | |
1284 | 4 * Copyright (C) 2008 - 2009 The Geeqie Team |
9 | 5 * |
6 * Authors: | |
442 | 7 * Support for Exif file format, originally written by Eric Swalens. |
9 | 8 * Modified by Quy Tonthat |
9 * | |
10 * Reimplemented with generic data storage by John Ellis (Nov 2003) | |
11 * | |
12 * The tags were added with information from the FREE document: | |
13 * http://www.ba.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html | |
14 * | |
15 * For the official Exif Format, please refer to: | |
16 * http://www.exif.org | |
17 * http://www.exif.org/specifications.html (PDF spec sheets) | |
18 * | |
19 * Notes: | |
20 * Additional tag formats should be added to the proper | |
21 * location in ExifKnownMarkersList[]. | |
22 * | |
23 * Human readable ouput (that needs additional processing of data to | |
24 * be useable) can be defined by adding a key to ExifFormattedList[], | |
25 * then handling that tag in the function exif_get_formatted_by_key(). | |
26 * The human readable formatted keys must begin with the character 'f'. | |
27 * | |
28 * Unsupported at this time: | |
29 * IFD1 (thumbnail) | |
30 * MakerNote | |
31 * | |
32 * TODO: | |
33 * Convert data to useable form in the ??_as_text function for: | |
34 * ComponentsConfiguration | |
35 * UserComment (convert this to UTF-8?) | |
1052 | 36 * Add support for marker tag 0x0000 |
9 | 37 * |
38 | |
39 This program is free software; you can redistribute it and/or modify | |
40 it under the terms of the GNU General Public License as published by | |
41 the Free Software Foundation; either version 2 of the License, or | |
42 (at your option) any later version. | |
43 | |
44 This program is distributed in the hope that it will be useful, | |
45 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
46 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
47 GNU General Public License for more details. | |
48 | |
49 You should have received a copy of the GNU General Public License | |
50 along with this program; if not, write to the Free Software | |
51 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
52 */ | |
53 | |
54 #ifdef HAVE_CONFIG_H | |
55 # include "config.h" | |
56 #endif | |
57 | |
177 | 58 #ifndef HAVE_EXIV2 |
59 | |
9 | 60 #include <stdio.h> |
61 #include <string.h> | |
62 #include <fcntl.h> | |
63 #include <unistd.h> | |
64 #include <sys/types.h> | |
65 #include <sys/stat.h> | |
66 #include <sys/mman.h> | |
67 #include <math.h> | |
442 | 68 |
9 | 69 #include <glib.h> |
1305 | 70 #include <glib/gprintf.h> |
9 | 71 |
72 #include "intl.h" | |
73 | |
281 | 74 #include "main.h" |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
75 #include "exif-int.h" |
9 | 76 |
43
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
77 #include "format_raw.h" |
9 | 78 #include "ui_fileops.h" |
79 | |
80 | |
81 /* | |
82 *----------------------------------------------------------------------------- | |
83 * Tag formats | |
84 *----------------------------------------------------------------------------- | |
85 */ | |
86 | |
87 ExifFormatAttrib ExifFormatList[] = { | |
88 { EXIF_FORMAT_UNKNOWN, 1, "unknown", "unknown" }, | |
89 { EXIF_FORMAT_BYTE_UNSIGNED, 1, "ubyte", "unsigned byte" }, | |
90 { EXIF_FORMAT_STRING, 1, "string", "string" }, | |
91 { EXIF_FORMAT_SHORT_UNSIGNED, 2, "ushort", "unsigned short" }, | |
92 { EXIF_FORMAT_LONG_UNSIGNED, 4, "ulong", "unsigned long" }, | |
93 { EXIF_FORMAT_RATIONAL_UNSIGNED,8, "urational", "unsigned rational" }, | |
94 { EXIF_FORMAT_BYTE, 1, "byte", "byte" }, | |
95 { EXIF_FORMAT_UNDEFINED, 1, "undefined", "undefined" }, | |
96 { EXIF_FORMAT_SHORT, 2, "sshort", "signed short" }, | |
97 { EXIF_FORMAT_LONG, 4, "slong", "signed long" }, | |
98 { EXIF_FORMAT_RATIONAL, 8, "srational", "signed rational" }, | |
99 { EXIF_FORMAT_FLOAT, 4, "float", "float" }, | |
100 { EXIF_FORMAT_DOUBLE, 8, "double", "double" }, | |
749
f606e8962329
Silent few warnings that appeared when using --disable-exiv2 configure option.
zas_
parents:
673
diff
changeset
|
101 { -1, 0, NULL, NULL } |
9 | 102 }; |
103 | |
104 /* tags that are special, or need special treatment */ | |
105 #define TAG_EXIFOFFSET 0x8769 | |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
106 #define TAG_EXIFMAKERNOTE 0x927c |
1052 | 107 #define TAG_GPSOFFSET 0x8825 |
9 | 108 |
109 | |
110 /* | |
111 *----------------------------------------------------------------------------- | |
112 * Data | |
113 *----------------------------------------------------------------------------- | |
114 */ | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
115 static ExifTextList ExifCompressionList[] = { |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
116 { 1, "Uncompressed" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
117 { 2, "CCITT 1D" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
118 { 3, "T4/Group 3 Fax" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
119 { 4, "T6/Group 4 Fax" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
120 { 5, "LZW" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
121 { 6, "JPEG (old style)" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
122 { 7, "JPEG" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
123 { 8, "Adobe Deflate" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
124 { 9, "JBIG B&W" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
125 { 10, "JBIG Color" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
126 { 32766, "Next" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
127 { 32771, "CCIRLEW" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
128 { 32773, "PackBits" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
129 { 32809, "ThunderScan" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
130 { 32895, "IT8CTPAD" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
131 { 32896, "IT8LW" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
132 { 32897, "IT8MP" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
133 { 32898, "IT8BL" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
134 { 32908, "PixasFilm" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
135 { 32909, "PixasLog" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
136 { 32946, "Deflate" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
137 { 32947, "DCS" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
138 { 34661, "JBIG" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
139 { 34676, "SGILog" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
140 { 34677, "SGILog24" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
141 { 34712, "JPEF 2000" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
142 { 34713, "Nikon NEF Compressed" }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
143 EXIF_TEXT_LIST_END |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
144 }; |
9 | 145 |
146 static ExifTextList ExifOrientationList[] = { | |
147 { EXIF_ORIENTATION_UNKNOWN, N_("unknown") }, | |
148 { EXIF_ORIENTATION_TOP_LEFT, N_("top left") }, | |
149 { EXIF_ORIENTATION_TOP_RIGHT, N_("top right") }, | |
150 { EXIF_ORIENTATION_BOTTOM_RIGHT,N_("bottom right") }, | |
151 { EXIF_ORIENTATION_BOTTOM_LEFT, N_("bottom left") }, | |
152 { EXIF_ORIENTATION_LEFT_TOP, N_("left top") }, | |
153 { EXIF_ORIENTATION_RIGHT_TOP, N_("right top") }, | |
154 { EXIF_ORIENTATION_RIGHT_BOTTOM,N_("right bottom") }, | |
155 { EXIF_ORIENTATION_LEFT_BOTTOM, N_("left bottom") }, | |
156 EXIF_TEXT_LIST_END | |
157 }; | |
158 | |
159 static ExifTextList ExifUnitList[] = { | |
160 { EXIF_UNIT_UNKNOWN, N_("unknown") }, | |
161 { EXIF_UNIT_NOUNIT, "" }, | |
162 { EXIF_UNIT_INCH, N_("inch") }, | |
163 { EXIF_UNIT_CENTIMETER, N_("centimeter") }, | |
164 EXIF_TEXT_LIST_END | |
165 }; | |
166 | |
167 static ExifTextList ExifYCbCrPosList[] = { | |
168 { 1, "center" }, | |
169 { 2, "datum" }, | |
170 EXIF_TEXT_LIST_END | |
171 }; | |
172 | |
173 static ExifTextList ExifMeteringModeList[] = { | |
174 { 0, N_("unknown") }, | |
175 { 1, N_("average") }, | |
176 { 2, N_("center weighted") }, | |
177 { 3, N_("spot") }, | |
178 { 4, N_("multi-spot") }, | |
179 { 5, N_("multi-segment") }, | |
180 { 6, N_("partial") }, | |
181 { 255, N_("other") }, | |
182 EXIF_TEXT_LIST_END | |
183 }; | |
184 | |
185 static ExifTextList ExifExposureProgramList[] = { | |
186 { 0, N_("not defined") }, | |
187 { 1, N_("manual") }, | |
188 { 2, N_("normal") }, | |
189 { 3, N_("aperture") }, | |
190 { 4, N_("shutter") }, | |
191 { 5, N_("creative") }, | |
192 { 6, N_("action") }, | |
193 { 7, N_("portrait") }, | |
194 { 8, N_("landscape") }, | |
195 EXIF_TEXT_LIST_END | |
196 }; | |
197 | |
198 static ExifTextList ExifLightSourceList[] = { | |
199 { 0, N_("unknown") }, | |
200 { 1, N_("daylight") }, | |
201 { 2, N_("fluorescent") }, | |
202 { 3, N_("tungsten (incandescent)") }, | |
203 { 4, N_("flash") }, | |
262 | 204 { 9, N_("fine weather") }, |
205 { 10, N_("cloudy weather") }, | |
206 { 11, N_("shade") }, | |
207 { 12, N_("daylight fluorescent") }, | |
208 { 13, N_("day white fluorescent") }, | |
209 { 14, N_("cool white fluorescent") }, | |
293
faeda3c7c8f8
Fix a typo: "while fluorescent" -> "white fluorescent"
zas_
parents:
281
diff
changeset
|
210 { 15, N_("white fluorescent") }, |
262 | 211 { 17, N_("standard light A") }, |
212 { 18, N_("standard light B") }, | |
213 { 19, N_("standard light C") }, | |
214 { 20, N_("D55") }, | |
215 { 21, N_("D65") }, | |
216 { 22, N_("D75") }, | |
217 { 23, N_("D50") }, | |
218 { 24, N_("ISO studio tungsten") }, | |
9 | 219 { 255, N_("other") }, |
220 EXIF_TEXT_LIST_END | |
221 }; | |
222 | |
223 static ExifTextList ExifFlashList[] = { | |
224 { 0, N_("no") }, | |
225 { 1, N_("yes") }, | |
226 { 5, N_("yes, not detected by strobe") }, | |
227 { 7, N_("yes, detected by strobe") }, | |
228 EXIF_TEXT_LIST_END | |
229 }; | |
230 | |
231 static ExifTextList ExifColorSpaceList[] = { | |
262 | 232 { 1, N_("sRGB") }, |
233 { 65535,N_("uncalibrated") }, | |
9 | 234 EXIF_TEXT_LIST_END |
235 }; | |
236 | |
237 static ExifTextList ExifSensorList[] = { | |
262 | 238 { 1, N_("not defined") }, |
239 { 2, N_("1 chip color area") }, | |
240 { 2, N_("2 chip color area") }, | |
241 { 4, N_("3 chip color area") }, | |
242 { 5, N_("color sequential area") }, | |
243 { 7, N_("trilinear") }, | |
244 { 8, N_("color sequential linear") }, | |
9 | 245 EXIF_TEXT_LIST_END |
246 }; | |
247 | |
248 static ExifTextList ExifSourceList[] = { | |
262 | 249 { 3, N_("digital still camera") }, |
9 | 250 EXIF_TEXT_LIST_END |
251 }; | |
252 | |
253 static ExifTextList ExifSceneList[] = { | |
262 | 254 { 1, N_("direct photo") }, |
9 | 255 EXIF_TEXT_LIST_END |
256 }; | |
257 | |
258 static ExifTextList ExifCustRenderList[] = { | |
262 | 259 { 0, N_("normal") }, |
260 { 1, N_("custom") }, | |
9 | 261 EXIF_TEXT_LIST_END |
262 }; | |
263 | |
264 static ExifTextList ExifExposureModeList[] = { | |
262 | 265 { 0, N_("auto") }, |
266 { 1, N_("manual") }, | |
267 { 2, N_("auto bracket") }, | |
9 | 268 EXIF_TEXT_LIST_END |
269 }; | |
270 | |
271 static ExifTextList ExifWhiteBalanceList[] = { | |
262 | 272 { 0, N_("auto") }, |
273 { 1, N_("manual") }, | |
9 | 274 EXIF_TEXT_LIST_END |
275 }; | |
276 | |
277 static ExifTextList ExifSceneCaptureList[] = { | |
262 | 278 { 0, N_("standard") }, |
279 { 1, N_("landscape") }, | |
280 { 2, N_("portrait") }, | |
281 { 3, N_("night scene") }, | |
9 | 282 EXIF_TEXT_LIST_END |
283 }; | |
284 | |
285 static ExifTextList ExifGainControlList[] = { | |
262 | 286 { 0, N_("none") }, |
287 { 1, N_("low gain up") }, | |
288 { 2, N_("high gain up") }, | |
289 { 3, N_("low gain down") }, | |
290 { 4, N_("high gain down") }, | |
9 | 291 EXIF_TEXT_LIST_END |
292 }; | |
293 | |
294 static ExifTextList ExifContrastList[] = { | |
262 | 295 { 0, N_("normal") }, |
296 { 1, N_("soft") }, | |
297 { 2, N_("hard") }, | |
9 | 298 EXIF_TEXT_LIST_END |
299 }; | |
300 | |
301 static ExifTextList ExifSaturationList[] = { | |
262 | 302 { 0, N_("normal") }, |
303 { 1, N_("low") }, | |
304 { 2, N_("high") }, | |
9 | 305 EXIF_TEXT_LIST_END |
306 }; | |
307 | |
308 static ExifTextList ExifSharpnessList[] = { | |
262 | 309 { 0, N_("normal") }, |
310 { 1, N_("soft") }, | |
311 { 2, N_("hard") }, | |
9 | 312 EXIF_TEXT_LIST_END |
313 }; | |
314 | |
315 static ExifTextList ExifSubjectRangeList[] = { | |
262 | 316 { 0, N_("unknown") }, |
317 { 1, N_("macro") }, | |
318 { 2, N_("close") }, | |
319 { 3, N_("distant") }, | |
9 | 320 EXIF_TEXT_LIST_END |
321 }; | |
322 | |
442 | 323 /* |
324 Tag names should match to exiv2 keys, http://www.exiv2.org/metadata.html | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
325 Tags that don't match are not supported by exiv2 and should not be used anywhere in the code |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
326 */ |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
327 |
9 | 328 ExifMarker ExifKnownMarkersList[] = { |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
329 { 0x0100, EXIF_FORMAT_LONG_UNSIGNED, 1, "Exif.Image.ImageWidth", N_("Image Width"), NULL }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
330 { 0x0101, EXIF_FORMAT_LONG_UNSIGNED, 1, "Exif.Image.ImageLength", N_("Image Height"), NULL }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
331 { 0x0102, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Image.BitsPerSample", N_("Bits per Sample/Pixel"), NULL }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
332 { 0x0103, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Image.Compression", N_("Compression"), ExifCompressionList }, |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
333 { 0x010e, EXIF_FORMAT_STRING, -1, "Exif.Image.ImageDescription", N_("Image description"), NULL }, |
262 | 334 { 0x010f, EXIF_FORMAT_STRING, -1, "Exif.Image.Make", N_("Camera make"), NULL }, |
335 { 0x0110, EXIF_FORMAT_STRING, -1, "Exif.Image.Model", N_("Camera model"), NULL }, | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
336 { 0x0112, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Image.Orientation", N_("Orientation"), ExifOrientationList }, |
262 | 337 { 0x011a, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Image.XResolution", N_("X resolution"), NULL }, |
338 { 0x011b, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Image.YResolution", N_("Y Resolution"), NULL }, | |
339 { 0x0128, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Image.ResolutionUnit", N_("Resolution units"), ExifUnitList }, | |
340 { 0x0131, EXIF_FORMAT_STRING, -1, "Exif.Image.Software", N_("Firmware"), NULL }, | |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
341 { 0x0132, EXIF_FORMAT_STRING, 20, "Exif.Image.DateTime", N_("Date"), NULL }, |
262 | 342 { 0x013e, EXIF_FORMAT_RATIONAL_UNSIGNED, 2, "Exif.Image.WhitePoint", N_("White point"), NULL }, |
343 { 0x013f, EXIF_FORMAT_RATIONAL_UNSIGNED, 6, "Exif.Image.PrimaryChromaticities",N_("Primary chromaticities"), NULL }, | |
344 { 0x0211, EXIF_FORMAT_RATIONAL_UNSIGNED, 3, "Exif.Image.YCbCrCoefficients", N_("YCbCy coefficients"), NULL }, | |
345 { 0x0213, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Image.YCbCrPositioning", N_("YCbCr positioning"), ExifYCbCrPosList }, | |
346 { 0x0214, EXIF_FORMAT_RATIONAL_UNSIGNED, 6, "Exif.Image.ReferenceBlackWhite",N_("Black white reference"), NULL }, | |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
347 { 0x8298, EXIF_FORMAT_STRING, -1, "Exif.Image.Copyright", N_("Copyright"), NULL }, |
262 | 348 { 0x8769, EXIF_FORMAT_LONG_UNSIGNED, 1, "Exif.Image.ExifTag", N_("SubIFD Exif offset"), NULL }, |
9 | 349 /* subIFD follows */ |
262 | 350 { 0x829a, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Photo.ExposureTime", N_("Exposure time (seconds)"), NULL }, |
351 { 0x829d, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Photo.FNumber", N_("FNumber"), NULL }, | |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
352 { 0x8822, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.ExposureProgram", N_("Exposure program"), ExifExposureProgramList }, |
262 | 353 { 0x8824, EXIF_FORMAT_STRING, -1, "Exif.Photo.SpectralSensitivity",N_("Spectral Sensitivity"), NULL }, |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
354 { 0x8827, EXIF_FORMAT_SHORT_UNSIGNED, -1, "Exif.Photo.ISOSpeedRatings", N_("ISO sensitivity"), NULL }, |
262 | 355 { 0x8828, EXIF_FORMAT_UNDEFINED, -1, "Exif.Photo.OECF", N_("Optoelectric conversion factor"), NULL }, |
356 { 0x9000, EXIF_FORMAT_UNDEFINED, 4, "Exif.Photo.ExifVersion", N_("Exif version"), NULL }, | |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
357 { 0x9003, EXIF_FORMAT_STRING, 20, "Exif.Photo.DateTimeOriginal", N_("Date original"), NULL }, |
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
358 { 0x9004, EXIF_FORMAT_STRING, 20, "Exif.Photo.DateTimeDigitized", N_("Date digitized"), NULL }, |
262 | 359 { 0x9101, EXIF_FORMAT_UNDEFINED, -1, "Exif.Photo.ComponentsConfiguration",N_("Pixel format"), NULL }, |
360 { 0x9102, EXIF_FORMAT_RATIONAL_UNSIGNED,1, "Exif.Photo.CompressedBitsPerPixel",N_("Compression ratio"), NULL }, | |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
361 { 0x9201, EXIF_FORMAT_RATIONAL, 1, "Exif.Photo.ShutterSpeedValue", N_("Shutter speed"), NULL }, |
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
362 { 0x9202, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Photo.ApertureValue", N_("Aperture"), NULL }, |
262 | 363 { 0x9203, EXIF_FORMAT_RATIONAL, 1, "Exif.Photo.BrightnessValue", N_("Brightness"), NULL }, |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
364 { 0x9204, EXIF_FORMAT_RATIONAL, 1, "Exif.Photo.ExposureBiasValue", N_("Exposure bias"), NULL }, |
262 | 365 { 0x9205, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Photo.MaxApertureValue", N_("Maximum aperture"), NULL }, |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
366 { 0x9206, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Photo.SubjectDistance", N_("Subject distance"), NULL }, |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
367 { 0x9207, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.MeteringMode", N_("Metering mode"), ExifMeteringModeList }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
368 { 0x9208, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.LightSource", N_("Light source"), ExifLightSourceList }, |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
369 { 0x9209, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.Flash", N_("Flash"), ExifFlashList }, |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
370 { 0x920a, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Photo.FocalLength", N_("Focal length"), NULL }, |
262 | 371 { 0x9214, EXIF_FORMAT_SHORT_UNSIGNED, -1, "Exif.Photo.SubjectArea", N_("Subject area"), NULL }, |
372 { 0x927c, EXIF_FORMAT_UNDEFINED, -1, "Exif.Photo.MakerNote", N_("MakerNote"), NULL }, | |
373 { 0x9286, EXIF_FORMAT_UNDEFINED, -1, "Exif.Photo.UserComment", N_("UserComment"), NULL }, | |
374 { 0x9290, EXIF_FORMAT_STRING, -1, "Exif.Photo.SubSecTime", N_("Subsecond time"), NULL }, | |
375 { 0x9291, EXIF_FORMAT_STRING, -1, "Exif.Photo.SubSecTimeOriginal",N_("Subsecond time original"), NULL }, | |
376 { 0x9292, EXIF_FORMAT_STRING, -1, "Exif.Photo.SubSecTimeDigitized",N_("Subsecond time digitized"), NULL }, | |
377 { 0xa000, EXIF_FORMAT_UNDEFINED, 4, "Exif.Photo.FlashpixVersion", N_("FlashPix version"), NULL }, | |
378 { 0xa001, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.ColorSpace", N_("Colorspace"), ExifColorSpaceList }, | |
9 | 379 /* ExifImageWidth, ExifImageHeight can also be unsigned short */ |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
380 { 0xa002, EXIF_FORMAT_LONG_UNSIGNED, 1, "Exif.Photo.PixelXDimension", N_("Width"), NULL }, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
381 { 0xa003, EXIF_FORMAT_LONG_UNSIGNED, 1, "Exif.Photo.PixelYDimension", N_("Height"), NULL }, |
262 | 382 { 0xa004, EXIF_FORMAT_STRING, -1, "Exif.Photo.RelatedSoundFile", N_("Audio data"), NULL }, |
383 { 0xa005, EXIF_FORMAT_LONG_UNSIGNED, 1, "ExifInteroperabilityOffset", N_("ExifR98 extension"), NULL }, | |
384 { 0xa20b, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Photo.FlashEnergy", N_("Flash strength"), NULL }, | |
385 { 0xa20c, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.SpatialFrequencyResponse",N_("Spatial frequency response"), NULL }, | |
386 { 0xa20e, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Photo.FocalPlaneXResolution", N_("X Pixel density"), NULL }, | |
387 { 0xa20f, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Photo.FocalPlaneYResolution", N_("Y Pixel density"), NULL }, | |
388 { 0xa210, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.FocalPlaneResolutionUnit", N_("Pixel density units"), ExifUnitList }, | |
389 { 0x0214, EXIF_FORMAT_SHORT_UNSIGNED, 2, "Exif.Photo.SubjectLocation", N_("Subject location"), NULL }, | |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
390 { 0xa215, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Photo.ExposureIndex", N_("ISO sensitivity"), NULL }, |
262 | 391 { 0xa217, EXIF_FORMAT_SHORT_UNSIGNED, -1, "Exif.Photo.SensingMethod", N_("Sensor type"), ExifSensorList }, |
392 { 0xa300, EXIF_FORMAT_UNDEFINED, 1, "Exif.Photo.FileSource", N_("Source type"), ExifSourceList }, | |
393 { 0xa301, EXIF_FORMAT_UNDEFINED, 1, "Exif.Photo.SceneType", N_("Scene type"), ExifSceneList }, | |
394 { 0xa302, EXIF_FORMAT_UNDEFINED, -1, "Exif.Image.CFAPattern", N_("Color filter array pattern"), NULL }, | |
9 | 395 /* tags a4xx were added for Exif 2.2 (not just these - some above, as well) */ |
262 | 396 { 0xa401, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.CustomRendered", N_("Render process"), ExifCustRenderList }, |
397 { 0xa402, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.ExposureMode", N_("Exposure mode"), ExifExposureModeList }, | |
398 { 0xa403, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.WhiteBalance", N_("White balance"), ExifWhiteBalanceList }, | |
399 { 0xa404, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Photo.DigitalZoomRatio", N_("Digital zoom ratio"), NULL }, | |
400 { 0xa405, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.FocalLengthIn35mmFilm",N_("Focal length (35mm)"), NULL }, | |
401 { 0xa406, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.SceneCaptureType", N_("Scene capture type"), ExifSceneCaptureList }, | |
402 { 0xa407, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.GainControl", N_("Gain control"), ExifGainControlList }, | |
403 { 0xa408, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.Contrast", N_("Contrast"), ExifContrastList }, | |
404 { 0xa409, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.Saturation", N_("Saturation"), ExifSaturationList }, | |
405 { 0xa40a, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.Sharpness", N_("Sharpness"), ExifSharpnessList }, | |
406 { 0xa40b, EXIF_FORMAT_UNDEFINED, -1, "Exif.Photo.DeviceSettingDescription",N_("Device setting"), NULL }, | |
407 { 0xa40c, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Exif.Photo.SubjectDistanceRange",N_("Subject range"), ExifSubjectRangeList }, | |
408 { 0xa420, EXIF_FORMAT_STRING, -1, "Exif.Photo.ImageUniqueID", N_("Image serial number"), NULL }, | |
9 | 409 /* place known, but undocumented or lesser used tags here */ |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
410 { 0x00fe, EXIF_FORMAT_LONG_UNSIGNED, 1, "Exif.Image.NewSubfileType", NULL, NULL }, |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
411 { 0x00ff, EXIF_FORMAT_SHORT_UNSIGNED, 1, "SubfileType", NULL, NULL }, |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
412 { 0x012d, EXIF_FORMAT_SHORT_UNSIGNED, 3, "Exif.Image.TransferFunction", NULL, NULL }, |
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
413 { 0x013b, EXIF_FORMAT_STRING, -1, "Exif.Image.Artist", "Artist", NULL }, |
9 | 414 { 0x013d, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Predictor", NULL, NULL }, |
415 { 0x0142, EXIF_FORMAT_SHORT_UNSIGNED, 1, "TileWidth", NULL, NULL }, | |
416 { 0x0143, EXIF_FORMAT_SHORT_UNSIGNED, 1, "TileLength", NULL, NULL }, | |
417 { 0x0144, EXIF_FORMAT_LONG_UNSIGNED, -1, "TileOffsets", NULL, NULL }, | |
418 { 0x0145, EXIF_FORMAT_SHORT_UNSIGNED, -1, "TileByteCounts", NULL, NULL }, | |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
419 { 0x014a, EXIF_FORMAT_LONG_UNSIGNED, -1, "Exif.Image.SubIFDs", NULL, NULL }, |
9 | 420 { 0x015b, EXIF_FORMAT_UNDEFINED, -1, "JPEGTables", NULL, NULL }, |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
421 { 0x828d, EXIF_FORMAT_SHORT_UNSIGNED, 2, "Exif.Image.CFARepeatPatternDim", NULL, NULL }, |
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
422 { 0x828e, EXIF_FORMAT_BYTE_UNSIGNED, -1, "Exif.Image.CFAPattern", NULL, NULL }, |
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
423 { 0x828f, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Image.BatteryLevel", NULL, NULL }, |
9 | 424 { 0x83bb, EXIF_FORMAT_LONG_UNSIGNED, -1, "IPTC/NAA", NULL, NULL }, |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
425 { 0x8773, EXIF_FORMAT_UNDEFINED, -1, "Exif.Image.InterColorProfile", NULL, NULL }, |
9 | 426 { 0x8825, EXIF_FORMAT_LONG_UNSIGNED, 1, "GPSInfo", "SubIFD GPS offset", NULL }, |
427 { 0x8829, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Interlace", NULL, NULL }, | |
428 { 0x882a, EXIF_FORMAT_SHORT, 1, "TimeZoneOffset", NULL, NULL }, | |
429 { 0x882b, EXIF_FORMAT_SHORT_UNSIGNED, 1, "SelfTimerMode", NULL, NULL }, | |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
430 { 0x920b, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Photo.FlashEnergy", NULL, NULL }, |
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
431 { 0x920c, EXIF_FORMAT_UNDEFINED, -1, "Exif.Photo.SpatialFrequencyResponse", NULL, NULL }, |
9 | 432 { 0x920d, EXIF_FORMAT_UNDEFINED, -1, "Noise", NULL, NULL }, |
433 { 0x9211, EXIF_FORMAT_LONG_UNSIGNED, 1, "ImageNumber", NULL, NULL }, | |
434 { 0x9212, EXIF_FORMAT_STRING, 1, "SecurityClassification", NULL, NULL }, | |
435 { 0x9213, EXIF_FORMAT_STRING, -1, "ImageHistory", NULL, NULL }, | |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
177
diff
changeset
|
436 { 0x9215, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.Photo.ExposureIndex", NULL, NULL }, |
9 | 437 { 0x9216, EXIF_FORMAT_BYTE_UNSIGNED, 4, "TIFF/EPStandardID", NULL, NULL }, |
438 | |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
439 EXIF_MARKER_LIST_END |
9 | 440 }; |
441 | |
1052 | 442 ExifMarker ExifKnownGPSInfoMarkersList[] = { |
443 /* The following do not work at the moment as the tag value 0x0000 has a | |
444 * special meaning. */ | |
445 /* { 0x0000, EXIF_FORMAT_BYTE, -1, "Exif.GPSInfo.GPSVersionID", NULL, NULL }, */ | |
446 { 0x0001, EXIF_FORMAT_STRING, 2, "Exif.GPSInfo.GPSLatitudeRef", NULL, NULL }, | |
447 { 0x0002, EXIF_FORMAT_RATIONAL_UNSIGNED, 3, "Exif.GPSInfo.GPSLatitude", NULL, NULL }, | |
448 { 0x0003, EXIF_FORMAT_STRING, 2, "Exif.GPSInfo.GPSLongitudeRef", NULL, NULL }, | |
449 { 0x0004, EXIF_FORMAT_RATIONAL_UNSIGNED, 3, "Exif.GPSInfo.GPSLongitude", NULL, NULL }, | |
450 { 0x0005, EXIF_FORMAT_BYTE_UNSIGNED, 1, "Exif.GPSInfo.GPSAltitudeRef", NULL, NULL }, | |
451 { 0x0006, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Exif.GPSInfo.GPSAltitude", NULL, NULL }, | |
452 { 0x0007, EXIF_FORMAT_RATIONAL_UNSIGNED, 3, "Exif.GPSInfo.GPSTimeStamp", NULL, NULL }, | |
453 { 0x0008, EXIF_FORMAT_STRING, -1, "Exif.GPSInfo.GPSSatellites", NULL, NULL }, | |
454 { 0x0009, EXIF_FORMAT_STRING, -1, "Exif.GPSInfo.GPSStatus", NULL, NULL }, | |
455 { 0x000a, EXIF_FORMAT_STRING, -1, "Exif.GPSInfo.GPSMeasureMode", NULL, NULL }, | |
456 { 0x000b, EXIF_FORMAT_RATIONAL_UNSIGNED, -1, "Exif.GPSInfo.GPSDOP", NULL, NULL }, | |
457 { 0x000c, EXIF_FORMAT_STRING, -1, "Exif.GPSInfo.GPSSpeedRef", NULL, NULL }, | |
458 { 0x000d, EXIF_FORMAT_RATIONAL_UNSIGNED, -1, "Exif.GPSInfo.GPSSpeed", NULL, NULL }, | |
459 { 0x000e, EXIF_FORMAT_STRING, -1, "Exif.GPSInfo.GPSTrackRef", NULL, NULL }, | |
460 { 0x000f, EXIF_FORMAT_RATIONAL_UNSIGNED, -1, "Exif.GPSInfo.GPSTrack", NULL, NULL }, | |
461 { 0x0010, EXIF_FORMAT_STRING, -1, "Exif.GPSInfo.GPSImgDirectionRef", NULL, NULL }, | |
462 { 0x0011, EXIF_FORMAT_RATIONAL_UNSIGNED, -1, "Exif.GPSInfo.GPSImgDirection", NULL, NULL }, | |
463 { 0x0012, EXIF_FORMAT_STRING, -1, "Exif.GPSInfo.GPSMapDatum", NULL, NULL }, | |
464 { 0x0013, EXIF_FORMAT_STRING, -1, "Exif.GPSInfo.GPSDestLatitudeRef", NULL, NULL }, | |
465 { 0x0014, EXIF_FORMAT_RATIONAL_UNSIGNED, -1, "Exif.GPSInfo.GPSDestLatitude", NULL, NULL }, | |
466 { 0x0015, EXIF_FORMAT_STRING, -1, "Exif.GPSInfo.GPSDestLongitudeRef", NULL, NULL }, | |
467 { 0x0016, EXIF_FORMAT_RATIONAL_UNSIGNED, -1, "Exif.GPSInfo.GPSDestLongitude", NULL, NULL }, | |
468 { 0x0017, EXIF_FORMAT_STRING, -1, "Exif.GPSInfo.GPSDestBearingRef", NULL, NULL }, | |
469 { 0x0018, EXIF_FORMAT_RATIONAL_UNSIGNED, -1, "Exif.GPSInfo.GPSDestBearing", NULL, NULL }, | |
470 { 0x0019, EXIF_FORMAT_STRING, -1, "Exif.GPSInfo.GPSDestDistanceRef", NULL, NULL }, | |
471 { 0x001a, EXIF_FORMAT_RATIONAL_UNSIGNED, -1, "Exif.GPSInfo.GPSDestDistance", NULL, NULL }, | |
472 { 0x001b, EXIF_FORMAT_UNDEFINED, -1, "Exif.GPSInfo.GPSProcessingMethod", NULL, NULL }, | |
473 { 0x001c, EXIF_FORMAT_UNDEFINED, -1, "Exif.GPSInfo.GPSAreaInformation", NULL, NULL }, | |
474 { 0x001d, EXIF_FORMAT_RATIONAL_UNSIGNED, 3, "Exif.GPSInfo.GPSDateStamp", NULL, NULL }, | |
475 { 0x001e, EXIF_FORMAT_SHORT, -1, "Exif.GPSInfo.GPSDifferential", NULL, NULL }, | |
476 | |
477 EXIF_MARKER_LIST_END | |
478 }; | |
479 | |
9 | 480 ExifMarker ExifUnknownMarkersList[] = { |
481 { 0x0000, EXIF_FORMAT_UNKNOWN, 0, "unknown", NULL, NULL }, | |
482 { 0x0000, EXIF_FORMAT_BYTE_UNSIGNED, -1, "unknown", NULL, NULL }, | |
483 { 0x0000, EXIF_FORMAT_STRING, -1, "unknown", NULL, NULL }, | |
484 { 0x0000, EXIF_FORMAT_SHORT_UNSIGNED, -1, "unknown", NULL, NULL }, | |
485 { 0x0000, EXIF_FORMAT_LONG_UNSIGNED, -1, "unknown", NULL, NULL }, | |
486 { 0x0000, EXIF_FORMAT_RATIONAL_UNSIGNED, -1, "unknown", NULL, NULL }, | |
487 { 0x0000, EXIF_FORMAT_BYTE, -1, "unknown", NULL, NULL }, | |
488 { 0x0000, EXIF_FORMAT_UNDEFINED, -1, "unknown", NULL, NULL }, | |
489 { 0x0000, EXIF_FORMAT_SHORT, -1, "unknown", NULL, NULL }, | |
490 { 0x0000, EXIF_FORMAT_LONG, -1, "unknown", NULL, NULL }, | |
491 { 0x0000, EXIF_FORMAT_RATIONAL, -1, "unknown", NULL, NULL }, | |
492 { 0x0000, EXIF_FORMAT_FLOAT, -1, "unknown", NULL, NULL }, | |
493 { 0x0000, EXIF_FORMAT_DOUBLE, -1, "unknown", NULL, NULL }, | |
494 }; | |
495 | |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
496 static const ExifMarker *exif_marker_from_tag(guint16 tag, const ExifMarker *list); |
9 | 497 |
498 /* | |
499 *----------------------------------------------------------------------------- | |
500 * ExifItem | |
501 *----------------------------------------------------------------------------- | |
502 */ | |
503 | |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
504 ExifItem *exif_item_new(ExifFormatType format, guint tag, |
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
505 guint elements, const ExifMarker *marker) |
9 | 506 { |
507 ExifItem *item; | |
508 | |
509 item = g_new0(ExifItem, 1); | |
510 item->format = format; | |
511 item->tag = tag; | |
512 item->marker = marker; | |
513 item->elements = elements; | |
514 item->data = NULL; | |
515 item->data_len = 0; | |
516 | |
517 switch (format) | |
518 { | |
519 case EXIF_FORMAT_UNKNOWN: | |
520 /* unknown, data is NULL */ | |
521 return item; | |
522 break; | |
523 case EXIF_FORMAT_BYTE_UNSIGNED: | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
524 item->data_len = sizeof(gchar) * elements; |
9 | 525 break; |
526 case EXIF_FORMAT_STRING: | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
527 item->data_len = sizeof(gchar) * elements; |
9 | 528 break; |
529 case EXIF_FORMAT_SHORT_UNSIGNED: | |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
530 item->data_len = sizeof(guint16) * elements; |
9 | 531 break; |
532 case EXIF_FORMAT_LONG_UNSIGNED: | |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
533 item->data_len = sizeof(guint32) * elements; |
9 | 534 break; |
535 case EXIF_FORMAT_RATIONAL_UNSIGNED: | |
536 item->data_len = sizeof(ExifRational) * elements; | |
537 break; | |
538 case EXIF_FORMAT_BYTE: | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
539 item->data_len = sizeof(gchar) * elements; |
9 | 540 break; |
541 case EXIF_FORMAT_UNDEFINED: | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
542 item->data_len = sizeof(gchar) * elements; |
9 | 543 break; |
544 case EXIF_FORMAT_SHORT: | |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
545 item->data_len = sizeof(gint16) * elements; |
9 | 546 break; |
547 case EXIF_FORMAT_LONG: | |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
548 item->data_len = sizeof(gint32) * elements; |
9 | 549 break; |
550 case EXIF_FORMAT_RATIONAL: | |
551 item->data_len = sizeof(ExifRational) * elements; | |
552 break; | |
553 case EXIF_FORMAT_FLOAT: | |
554 item->data_len = sizeof(float) * elements; | |
555 break; | |
556 case EXIF_FORMAT_DOUBLE: | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
557 item->data_len = sizeof(gdouble) * elements; |
9 | 558 break; |
559 } | |
560 | |
561 item->data = g_malloc0(item->data_len); | |
562 | |
563 return item; | |
564 } | |
565 | |
566 static void exif_item_free(ExifItem *item) | |
567 { | |
568 if (!item) return; | |
569 | |
570 g_free(item->data); | |
571 g_free(item); | |
572 } | |
573 | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
574 gchar *exif_item_get_tag_name(ExifItem *item) |
9 | 575 { |
576 if (!item || !item->marker) return NULL; | |
185 | 577 return g_strdup(item->marker->key); |
9 | 578 } |
579 | |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
580 guint exif_item_get_tag_id(ExifItem *item) |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
581 { |
242
59eac2063093
Fix a segfault occuring when using --without-exiv2 and
zas_
parents:
222
diff
changeset
|
582 if (!item) return 0; |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
583 return item->tag; |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
584 } |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
585 |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
586 guint exif_item_get_elements(ExifItem *item) |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
587 { |
242
59eac2063093
Fix a segfault occuring when using --without-exiv2 and
zas_
parents:
222
diff
changeset
|
588 if (!item) return 0; |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
589 return item->elements; |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
590 } |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
591 |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
592 gchar *exif_item_get_data(ExifItem *item, guint *data_len) |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
593 { |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
594 if (data_len) |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
595 *data_len = item->data_len; |
414
49c1cbe058ae
partially fixed reading embedded color profiles with exiv2
nadvornik
parents:
293
diff
changeset
|
596 return g_memdup(item->data, item->data_len); |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
597 } |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
598 |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
599 guint exif_item_get_format_id(ExifItem *item) |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
600 { |
242
59eac2063093
Fix a segfault occuring when using --without-exiv2 and
zas_
parents:
222
diff
changeset
|
601 if (!item) return EXIF_FORMAT_UNKNOWN; |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
602 return item->format; |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
603 } |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
604 |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
605 |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
606 gchar *exif_item_get_description(ExifItem *item) |
9 | 607 { |
608 if (!item || !item->marker) return NULL; | |
182 | 609 return g_strdup(_(item->marker->description)); |
9 | 610 } |
611 | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
612 const gchar *exif_item_get_format_name(ExifItem *item, gint brief) |
9 | 613 { |
442 | 614 if (!item || !item->marker) return NULL; |
9 | 615 return (brief) ? ExifFormatList[item->format].short_name : ExifFormatList[item->format].description; |
616 } | |
617 | |
618 static GString *string_append_raw_bytes(GString *string, gpointer data, gint ne) | |
619 { | |
620 gint i; | |
621 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
622 for (i = 0 ; i < ne; i++) |
9 | 623 { |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
624 guchar c = ((gchar *)data)[i]; |
9 | 625 if (c < 32 || c > 127) c = '.'; |
626 g_string_append_printf(string, "%c", c); | |
627 } | |
628 string = g_string_append(string, " : "); | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
629 for (i = 0 ; i < ne; i++) |
9 | 630 { |
631 const gchar *spacer; | |
632 if (i > 0) | |
633 { | |
634 if (i%8 == 0) | |
635 { | |
636 spacer = " - "; | |
637 } | |
638 else | |
639 { | |
640 spacer = " "; | |
641 } | |
642 } | |
643 else | |
644 { | |
645 spacer = ""; | |
646 } | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
647 g_string_append_printf(string, "%s%02x", spacer, ((gchar *)data)[i]); |
9 | 648 } |
649 | |
650 return string; | |
651 } | |
652 | |
182 | 653 |
57
a8c9992320f4
Fri Jun 10 20:57:42 2005 John Ellis <johne@verizon.net>
gqview
parents:
55
diff
changeset
|
654 gchar *exif_text_list_find_value(ExifTextList *list, guint value) |
9 | 655 { |
656 gchar *result = NULL; | |
657 gint i; | |
658 | |
659 i = 0; | |
660 while (!result && list[i].value >= 0) | |
661 { | |
749
f606e8962329
Silent few warnings that appeared when using --disable-exiv2 configure option.
zas_
parents:
673
diff
changeset
|
662 if (value == (guint) list[i].value) result = g_strdup(_(list[i].description)); |
9 | 663 i++; |
664 } | |
665 if (!result) result = g_strdup_printf("%d (%s)", value, _("unknown")); | |
666 | |
667 return result; | |
668 } | |
669 | |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
670 |
9 | 671 /* |
672 *------------------------------------------------------------------- | |
107 | 673 * byte order utils |
9 | 674 *------------------------------------------------------------------- |
675 */ | |
676 | |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
677 /* note: the align_buf is used to avoid alignment issues (on sparc) */ |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
678 |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
679 guint16 exif_byte_get_int16(guchar *f, ExifByteOrder bo) |
9 | 680 { |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
681 guint16 align_buf; |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
682 |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
683 memcpy(&align_buf, f, sizeof(guint16)); |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
684 |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
685 if (bo == EXIF_BYTE_ORDER_INTEL) |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
686 return GUINT16_FROM_LE(align_buf); |
9 | 687 else |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
688 return GUINT16_FROM_BE(align_buf); |
9 | 689 } |
690 | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
691 guint32 exif_byte_get_int32(guchar *f, ExifByteOrder bo) |
9 | 692 { |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
693 guint32 align_buf; |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
694 |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
695 memcpy(&align_buf, f, sizeof(guint32)); |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
696 |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
697 if (bo == EXIF_BYTE_ORDER_INTEL) |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
698 return GUINT32_FROM_LE(align_buf); |
9 | 699 else |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
700 return GUINT32_FROM_BE(align_buf); |
9 | 701 } |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
702 |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
703 void exif_byte_put_int16(guchar *f, guint16 n, ExifByteOrder bo) |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
704 { |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
705 guint16 align_buf; |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
706 |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
707 if (bo == EXIF_BYTE_ORDER_INTEL) |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
708 { |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
709 align_buf = GUINT16_TO_LE(n); |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
710 } |
9 | 711 else |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
712 { |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
713 align_buf = GUINT16_TO_BE(n); |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
714 } |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
715 |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
716 memcpy(f, &align_buf, sizeof(guint16)); |
9 | 717 } |
718 | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
719 void exif_byte_put_int32(guchar *f, guint32 n, ExifByteOrder bo) |
9 | 720 { |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
721 guint32 align_buf; |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
722 |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
723 if (bo == EXIF_BYTE_ORDER_INTEL) |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
724 { |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
725 align_buf = GUINT32_TO_LE(n); |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
726 } |
9 | 727 else |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
728 { |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
729 align_buf = GUINT32_TO_BE(n); |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
730 } |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
731 |
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
732 memcpy(f, &align_buf, sizeof(guint32)); |
9 | 733 } |
734 | |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
735 |
9 | 736 /* |
737 *------------------------------------------------------------------- | |
738 * IFD utils | |
739 *------------------------------------------------------------------- | |
740 */ | |
741 | |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
742 static const ExifMarker *exif_marker_from_tag(guint16 tag, const ExifMarker *list) |
9 | 743 { |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
744 gint i = 0; |
9 | 745 |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
746 if (!list) return NULL; |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
747 |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
748 while (list[i].tag != 0 && list[i].tag != tag) |
9 | 749 { |
750 i++; | |
751 } | |
752 | |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
753 return (list[i].tag == 0 ? NULL : &list[i]); |
9 | 754 } |
755 | |
1002 | 756 static void rational_from_data(ExifRational *r, gpointer src, ExifByteOrder bo) |
9 | 757 { |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
758 r->num = exif_byte_get_int32(src, bo); |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
759 r->den = exif_byte_get_int32(src + sizeof(guint32), bo); |
9 | 760 } |
761 | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
762 /* src_format and item->format must be compatible |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
763 * and not overrun src or item->data. |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
764 */ |
1002 | 765 void exif_item_copy_data(ExifItem *item, gpointer src, guint len, |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
766 ExifFormatType src_format, ExifByteOrder bo) |
9 | 767 { |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
768 gint bs; |
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
769 gint ne; |
9 | 770 gpointer dest; |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
771 gint i; |
9 | 772 |
773 bs = ExifFormatList[item->format].size; | |
774 ne = item->elements; | |
775 dest = item->data; | |
776 | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
777 if (!dest || |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
778 ExifFormatList[src_format].size * ne > len) |
9 | 779 { |
185 | 780 gchar *tag = exif_item_get_tag_name(item); |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
541
diff
changeset
|
781 log_printf("exif tag %s data size mismatch\n", tag); |
185 | 782 g_free(tag); |
9 | 783 return; |
784 } | |
785 | |
786 switch (item->format) | |
787 { | |
788 case EXIF_FORMAT_UNKNOWN: | |
789 break; | |
790 case EXIF_FORMAT_BYTE_UNSIGNED: | |
791 case EXIF_FORMAT_BYTE: | |
792 case EXIF_FORMAT_UNDEFINED: | |
793 memcpy(dest, src, len); | |
794 break; | |
795 case EXIF_FORMAT_STRING: | |
796 memcpy(dest, src, len); | |
797 /* string is NULL terminated, make sure this is true */ | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
798 if (((gchar *)dest)[len - 1] != '\0') ((gchar *)dest)[len - 1] = '\0'; |
9 | 799 break; |
800 case EXIF_FORMAT_SHORT_UNSIGNED: | |
801 case EXIF_FORMAT_SHORT: | |
802 for (i = 0; i < ne; i++) | |
803 { | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
804 ((guint16 *)dest)[i] = exif_byte_get_int16(src + i * bs, bo); |
9 | 805 } |
806 break; | |
807 case EXIF_FORMAT_LONG_UNSIGNED: | |
808 case EXIF_FORMAT_LONG: | |
809 if (src_format == EXIF_FORMAT_SHORT_UNSIGNED || | |
810 src_format == EXIF_FORMAT_SHORT) | |
811 { | |
812 /* a short fits into a long, so allow it */ | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
813 gint ss; |
9 | 814 |
815 ss = ExifFormatList[src_format].size; | |
816 for (i = 0; i < ne; i++) | |
817 { | |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
818 ((gint32 *)dest)[i] = |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
819 (gint32)exif_byte_get_int16(src + i * ss, bo); |
9 | 820 } |
821 } | |
822 else | |
823 { | |
824 for (i = 0; i < ne; i++) | |
825 { | |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
826 ((gint32 *)dest)[i] = |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
827 exif_byte_get_int32(src + i * bs, bo); |
9 | 828 } |
829 } | |
830 break; | |
831 case EXIF_FORMAT_RATIONAL_UNSIGNED: | |
832 case EXIF_FORMAT_RATIONAL: | |
833 for (i = 0; i < ne; i++) | |
834 { | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
835 rational_from_data(&((ExifRational *)dest)[i], src + i * bs, bo); |
9 | 836 } |
837 break; | |
838 case EXIF_FORMAT_FLOAT: | |
839 for (i = 0; i < ne; i++) | |
840 { | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
841 ((float *)dest)[i] = exif_byte_get_int32(src + i * bs, bo); |
9 | 842 } |
843 break; | |
844 case EXIF_FORMAT_DOUBLE: | |
845 for (i = 0; i < ne; i++) | |
846 { | |
847 ExifRational r; | |
848 | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
849 rational_from_data(&r, src + i * bs, bo); |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
850 if (r.den) ((gdouble *)dest)[i] = (gdouble)r.num / r.den; |
9 | 851 } |
852 break; | |
853 } | |
854 } | |
855 | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
856 static gint exif_parse_IFD_entry(ExifData *exif, guchar *tiff, guint offset, |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
857 guint size, ExifByteOrder bo, |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
858 gint level, |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
859 const ExifMarker *list) |
9 | 860 { |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
861 guint tag; |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
862 guint format; |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
863 guint count; |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
864 guint data_val; |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
865 guint data_offset; |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
866 guint data_length; |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
867 const ExifMarker *marker; |
9 | 868 ExifItem *item; |
869 | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
870 tag = exif_byte_get_int16(tiff + offset + EXIF_TIFD_OFFSET_TAG, bo); |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
871 format = exif_byte_get_int16(tiff + offset + EXIF_TIFD_OFFSET_FORMAT, bo); |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
872 count = exif_byte_get_int32(tiff + offset + EXIF_TIFD_OFFSET_COUNT, bo); |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
873 data_val = exif_byte_get_int32(tiff + offset + EXIF_TIFD_OFFSET_DATA, bo); |
9 | 874 |
875 /* Check tag type. If it does not match, either the format is wrong, | |
876 * either it is a unknown tag; so it is not really an error. | |
877 */ | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
878 marker = exif_marker_from_tag(tag, list); |
9 | 879 if (!marker) |
880 { | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
881 if (format >= EXIF_FORMAT_COUNT) |
9 | 882 { |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
541
diff
changeset
|
883 log_printf("warning: exif tag 0x%4x has invalid format %d\n", tag, format); |
9 | 884 return 0; |
885 } | |
886 /* allow non recognized tags to be displayed */ | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
887 marker = &ExifUnknownMarkersList[format]; |
9 | 888 } |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
889 if (marker->format != format) |
9 | 890 { |
891 /* Some cameras got mixed up signed/unsigned_rational | |
892 * eg KODAK DC4800 on object_distance tag | |
893 * | |
894 * FIXME: what exactly is this test trying to do? | |
895 * ok, so this test is to allow the case of swapped signed/unsigned mismatch to leak through? | |
896 */ | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
897 if (!(marker->format == EXIF_FORMAT_RATIONAL_UNSIGNED && format == EXIF_FORMAT_RATIONAL) && |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
898 !(marker->format == EXIF_FORMAT_RATIONAL && format == EXIF_FORMAT_RATIONAL_UNSIGNED) && |
9 | 899 /* short fits into a long so allow this mismatch |
900 * as well (some tags allowed to be unsigned short _or_ unsigned long) | |
901 */ | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
902 !(marker->format == EXIF_FORMAT_LONG_UNSIGNED && format == EXIF_FORMAT_SHORT_UNSIGNED) ) |
9 | 903 { |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
904 if (format < EXIF_FORMAT_COUNT) |
9 | 905 { |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
541
diff
changeset
|
906 log_printf("warning: exif tag %s format mismatch, found %s exif spec requests %s\n", |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
907 marker->key, ExifFormatList[format].short_name, |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
908 ExifFormatList[marker->format].short_name); |
9 | 909 } |
910 else | |
911 { | |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
541
diff
changeset
|
912 log_printf("warning: exif tag %s format mismatch, found unknown id %d exif spec requests %d (%s)\n", |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
913 marker->key, format, marker->format, |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
914 ExifFormatList[marker->format].short_name); |
9 | 915 } |
916 return 0; | |
917 } | |
918 } | |
919 | |
920 /* Where is the data, is it available? | |
921 */ | |
749
f606e8962329
Silent few warnings that appeared when using --disable-exiv2 configure option.
zas_
parents:
673
diff
changeset
|
922 if (marker->components > 0 && (guint) marker->components != count) |
9 | 923 { |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
541
diff
changeset
|
924 log_printf("warning: exif tag %s has %d elements, exif spec requests %d\n", |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
925 marker->key, count, marker->components); |
9 | 926 } |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
927 |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
928 data_length = ExifFormatList[marker->format].size * count; |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
929 if (data_length > 4) |
9 | 930 { |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
931 data_offset = data_val; |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
932 if (size < data_offset + data_length) |
9 | 933 { |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
541
diff
changeset
|
934 log_printf("warning: exif tag %s data will overrun end of file, ignored.\n", marker->key); |
9 | 935 return -1; |
936 } | |
937 } | |
938 else | |
939 { | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
940 data_offset = offset + EXIF_TIFD_OFFSET_DATA; |
9 | 941 } |
942 | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
943 item = exif_item_new(marker->format, tag, count, marker); |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
944 exif_item_copy_data(item, tiff + data_offset, data_length, format, bo); |
9 | 945 exif->items = g_list_prepend(exif->items, item); |
946 | |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
947 if (list == ExifKnownMarkersList) |
9 | 948 { |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
949 switch (item->tag) |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
950 { |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
951 case TAG_EXIFOFFSET: |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
952 exif_parse_IFD_table(exif, tiff, data_val, size, bo, level + 1, list); |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
953 break; |
1052 | 954 case TAG_GPSOFFSET: |
955 exif_parse_IFD_table(exif, tiff, data_val, size, bo, level + 1, ExifKnownGPSInfoMarkersList); | |
956 break; | |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
957 case TAG_EXIFMAKERNOTE: |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
958 format_exif_makernote_parse(exif, tiff, data_val, size, bo); |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
959 break; |
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
960 } |
9 | 961 } |
962 | |
963 return 0; | |
964 } | |
965 | |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
966 gint exif_parse_IFD_table(ExifData *exif, |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
967 guchar *tiff, guint offset, |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
968 guint size, ExifByteOrder bo, |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
969 gint level, |
51
276ea4c98d33
Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents:
47
diff
changeset
|
970 const ExifMarker *list) |
9 | 971 { |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
972 guint count; |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
973 guint i; |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
974 |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
975 /* limit damage from infinite loops */ |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
976 if (level > EXIF_TIFF_MAX_LEVELS) return -1; |
9 | 977 |
978 /* We should be able to read number of entries in IFD0) */ | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
979 if (size < offset + 2) return -1; |
9 | 980 |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
981 count = exif_byte_get_int16(tiff + offset, bo); |
57
a8c9992320f4
Fri Jun 10 20:57:42 2005 John Ellis <johne@verizon.net>
gqview
parents:
55
diff
changeset
|
982 offset += 2; |
9 | 983 |
984 /* Entries and next IFD offset must be readable */ | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
985 if (size < offset + count * EXIF_TIFD_SIZE + 4) return -1; |
9 | 986 |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
987 for (i = 0; i < count; i++) |
9 | 988 { |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
989 exif_parse_IFD_entry(exif, tiff, offset + i * EXIF_TIFD_SIZE, size, bo, level, list); |
9 | 990 } |
991 | |
992 return 0; | |
993 } | |
994 | |
995 /* | |
996 *------------------------------------------------------------------- | |
997 * file formats | |
998 *------------------------------------------------------------------- | |
999 */ | |
1000 | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1001 gint exif_tiff_directory_offset(guchar *data, const guint len, |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1002 guint *offset, ExifByteOrder *bo) |
9 | 1003 { |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1004 if (len < 8) return FALSE; |
9 | 1005 |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1006 if (memcmp(data, "II", 2) == 0) |
9 | 1007 { |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1008 *bo = EXIF_BYTE_ORDER_INTEL; |
9 | 1009 } |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1010 else if (memcmp(data, "MM", 2) == 0) |
9 | 1011 { |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1012 *bo = EXIF_BYTE_ORDER_MOTOROLA; |
9 | 1013 } |
1014 else | |
1015 { | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1016 return FALSE; |
9 | 1017 } |
1018 | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1019 if (exif_byte_get_int16(data + 2, *bo) != 0x002A) |
9 | 1020 { |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1021 return FALSE; |
9 | 1022 } |
1023 | |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1024 *offset = exif_byte_get_int32(data + 4, *bo); |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1025 |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1026 return (*offset < len); |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1027 } |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1028 |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1029 gint exif_tiff_parse(ExifData *exif, guchar *tiff, guint size, ExifMarker *list) |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1030 { |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1031 ExifByteOrder bo; |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1032 guint offset; |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1033 |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1034 if (!exif_tiff_directory_offset(tiff, size, &offset, &bo)) return -1; |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1035 |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1036 return exif_parse_IFD_table(exif, tiff, offset, size, bo, 0, list); |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1037 } |
9 | 1038 |
449 | 1039 |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1040 /* |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1041 *------------------------------------------------------------------- |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1042 * jpeg marker utils |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1043 *------------------------------------------------------------------- |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1044 */ |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1045 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1046 #define JPEG_MARKER 0xFF |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1047 #define JPEG_MARKER_SOI 0xD8 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1048 #define JPEG_MARKER_EOI 0xD9 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1049 #define JPEG_MARKER_APP1 0xE1 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1050 #define JPEG_MARKER_APP2 0xE2 |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1051 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1052 /* jpeg container format: |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1053 all data markers start with 0XFF |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1054 2 byte long file start and end markers: 0xFFD8(SOI) and 0XFFD9(EOI) |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1055 4 byte long data segment markers in format: 0xFFTTSSSSNNN... |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1056 FF: 1 byte standard marker identifier |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1057 TT: 1 byte data type |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1058 SSSS: 2 bytes in Motorola byte alignment for length of the data. |
442 | 1059 This value includes these 2 bytes in the count, making actual |
1060 length of NN... == SSSS - 2. | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1061 NNN.: the data in this segment |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1062 */ |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
192
diff
changeset
|
1063 static ExifMarker jpeg_color_marker = { 0x8773, EXIF_FORMAT_UNDEFINED, -1, "Exif.Image.InterColorProfile", NULL, NULL }; |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1064 |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1065 void exif_add_jpeg_color_profile(ExifData *exif, guchar *cp_data, guint cp_length) |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1066 { |
449 | 1067 ExifItem *item = exif_item_new(jpeg_color_marker.format, jpeg_color_marker.tag, 1, |
1068 &jpeg_color_marker); | |
1069 g_free(item->data); | |
1070 item->data = cp_data; | |
1071 item->elements = cp_length; | |
1072 item->data_len = cp_length; | |
1073 exif->items = g_list_prepend(exif->items, item); | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1074 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1075 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1076 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1077 static gint exif_jpeg_parse(ExifData *exif, |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1078 guchar *data, guint size, |
449 | 1079 ExifMarker *list) |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1080 { |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1081 guint seg_offset = 0; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1082 guint seg_length = 0; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1083 gint res = -1; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1084 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1085 if (size < 4 || |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1086 memcmp(data, "\xFF\xD8", 2) != 0) |
9 | 1087 { |
1088 return -2; | |
1089 } | |
1090 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1091 if (exif_jpeg_segment_find(data, size, JPEG_MARKER_APP1, |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1092 "Exif\x00\x00", 6, |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1093 &seg_offset, &seg_length)) |
9 | 1094 { |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1095 res = exif_tiff_parse(exif, data + seg_offset + 6, seg_length - 6, list); |
9 | 1096 } |
1097 | |
449 | 1098 if (exif_jpeg_parse_color(exif, data, size)) |
9 | 1099 { |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1100 res = 0; |
9 | 1101 } |
1102 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1103 return res; |
9 | 1104 } |
1105 | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1106 guchar *exif_get_color_profile(ExifData *exif, guint *data_len) |
449 | 1107 { |
1108 ExifItem *prof_item = exif_get_item(exif, "Exif.Image.InterColorProfile"); | |
1109 if (prof_item && exif_item_get_format_id(prof_item) == EXIF_FORMAT_UNDEFINED) | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1110 return (guchar *) exif_item_get_data(prof_item, data_len); |
449 | 1111 return NULL; |
1112 } | |
1113 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1114 |
54
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1115 /* |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1116 *------------------------------------------------------------------- |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1117 * misc |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1118 *------------------------------------------------------------------- |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1119 */ |
b58cac75ad12
Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents:
51
diff
changeset
|
1120 |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1121 |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1122 ExifItem *exif_get_first_item(ExifData *exif) |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1123 { |
442 | 1124 if (exif->items) |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1125 { |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1126 ExifItem *ret = (ExifItem *)exif->items->data; |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1127 exif->current = exif->items->next; |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1128 return ret; |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1129 } |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1130 exif->current = NULL; |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1131 return NULL; |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1132 } |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1133 |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1134 ExifItem *exif_get_next_item(ExifData *exif) |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1135 { |
442 | 1136 if (exif->current) |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1137 { |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1138 ExifItem *ret = (ExifItem *)exif->current->data; |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1139 exif->current = exif->current->next; |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1140 return ret; |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1141 } |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1142 return NULL; |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1143 } |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1144 |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1145 static gint map_file(const gchar *path, void **mapping, gint *size) |
9 | 1146 { |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1147 gint fd; |
9 | 1148 struct stat fs; |
1149 | |
855 | 1150 fd = open(path, O_RDONLY); |
1151 if (fd == -1) | |
9 | 1152 { |
1153 perror(path); | |
1154 return -1; | |
1155 } | |
1156 | |
1157 if (fstat(fd, &fs) == -1) | |
1158 { | |
1159 perror(path); | |
1160 close(fd); | |
1161 return -1; | |
1162 } | |
1163 | |
1164 *size = fs.st_size; | |
1165 | |
855 | 1166 *mapping = mmap(0, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); |
1167 if (*mapping == MAP_FAILED) | |
9 | 1168 { |
1169 perror(path); | |
1170 close(fd); | |
1171 return -1; | |
1172 } | |
1173 | |
1174 close(fd); | |
1175 return 0; | |
1176 } | |
1177 | |
1002 | 1178 static gint unmap_file(gpointer mapping, gint size) |
9 | 1179 { |
1180 if (munmap(mapping, size) == -1) | |
1181 { | |
1182 perror("munmap"); | |
1183 return -1; | |
1184 } | |
1185 | |
1186 return 0; | |
1187 } | |
1188 | |
1069 | 1189 ExifData *exif_get_original(ExifData *processed) |
1190 { | |
1191 return processed; | |
1192 } | |
1193 | |
9 | 1194 void exif_free(ExifData *exif) |
1195 { | |
1196 GList *work; | |
1197 | |
1198 if (!exif) return; | |
1199 | |
1200 work = exif->items; | |
1201 while (work) | |
1202 { | |
1203 ExifItem *item = work->data; | |
1204 work = work->next; | |
1205 exif_item_free(item); | |
1206 } | |
1207 | |
1208 g_list_free(exif->items); | |
1010 | 1209 g_free(exif->path); |
9 | 1210 g_free(exif); |
1211 } | |
1212 | |
1203
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1183
diff
changeset
|
1213 ExifData *exif_read(gchar *path, gchar *sidecar_path, GHashTable *modified_xmp) |
9 | 1214 { |
1215 ExifData *exif; | |
1002 | 1216 gpointer f; |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1217 gint size, res; |
9 | 1218 gchar *pathl; |
1219 | |
182 | 1220 if (!path) return NULL; |
9 | 1221 |
177 | 1222 pathl = path_from_utf8(path); |
9 | 1223 if (map_file(pathl, &f, &size) == -1) |
1224 { | |
1225 g_free(pathl); | |
1226 return NULL; | |
1227 } | |
1228 g_free(pathl); | |
1229 | |
1230 exif = g_new0(ExifData, 1); | |
1231 exif->items = NULL; | |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
1232 exif->current = NULL; |
1010 | 1233 exif->path = g_strdup(path); |
9 | 1234 |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1235 res = exif_jpeg_parse(exif, (guchar *)f, size, ExifKnownMarkersList); |
855 | 1236 if (res == -2) |
9 | 1237 { |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1238 res = exif_tiff_parse(exif, (guchar *)f, size, ExifKnownMarkersList); |
9 | 1239 } |
1240 | |
1241 if (res != 0) | |
1242 { | |
101
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1243 FormatRawExifType exif_type; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1244 FormatRawExifParseFunc exif_parse_func; |
43
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
1245 guint32 offset = 0; |
101
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1246 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1247 exif_type = format_raw_exif_offset(f, size, &offset, &exif_parse_func); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1248 switch (exif_type) |
43
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
1249 { |
101
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1250 case FORMAT_RAW_EXIF_NONE: |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1251 default: |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1252 break; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1253 case FORMAT_RAW_EXIF_TIFF: |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1254 res = exif_tiff_parse(exif, (guchar *)f + offset, size - offset, |
101
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1255 ExifKnownMarkersList); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1256 break; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1257 case FORMAT_RAW_EXIF_JPEG: |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1258 res = exif_jpeg_parse(exif, (guchar *)f + offset, size - offset, |
449 | 1259 ExifKnownMarkersList); |
101
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1260 break; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1261 case FORMAT_RAW_EXIF_IFD_II: |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1262 case FORMAT_RAW_EXIF_IFD_MM: |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1263 res = exif_parse_IFD_table(exif, (guchar *)f, offset, size - offset, |
101
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1264 (exif_type == FORMAT_RAW_EXIF_IFD_II) ? |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1265 EXIF_BYTE_ORDER_INTEL : EXIF_BYTE_ORDER_MOTOROLA, |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1266 0, ExifKnownMarkersList); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1267 break; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1268 case FORMAT_RAW_EXIF_PROPRIETARY: |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1269 if (exif_parse_func) |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1270 { |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1271 res = exif_parse_func((guchar *)f + offset, size - offset, exif); |
101
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1272 } |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1273 break; |
43
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
1274 } |
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
1275 } |
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
1276 |
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
1277 if (res != 0) |
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
1278 { |
9 | 1279 exif_free(exif); |
1280 exif = NULL; | |
1281 } | |
1282 | |
1283 unmap_file(f, size); | |
1284 | |
1285 if (exif) exif->items = g_list_reverse(exif->items); | |
1286 | |
1287 #if 0 | |
1288 exif_write_data_list(exif, stdout, TRUE); | |
1289 exif_write_data_list(exif, stdout, FALSE); | |
1290 #endif | |
1291 | |
1292 return exif; | |
1293 } | |
1294 | |
1295 ExifItem *exif_get_item(ExifData *exif, const gchar *key) | |
1296 { | |
1297 GList *work; | |
1298 | |
1299 if (!key) return NULL; | |
1300 | |
1301 work = exif->items; | |
1302 while (work) | |
995 | 1303 { |
9 | 1304 ExifItem *item; |
1305 | |
1306 item = work->data; | |
1307 work = work->next; | |
1308 if (item->marker->key && strcmp(key, item->marker->key) == 0) return item; | |
442 | 1309 } |
9 | 1310 return NULL; |
1311 } | |
1312 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1313 #define EXIF_DATA_AS_TEXT_MAX_COUNT 16 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1314 |
192 | 1315 |
1288 | 1316 static gchar *exif_item_get_data_as_text_full(ExifItem *item, MetadataFormat format) |
9 | 1317 { |
47
aa4c0e1b54b0
Fri Jun 3 01:49:20 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
1318 const ExifMarker *marker; |
9 | 1319 gpointer data; |
1320 GString *string; | |
1321 gchar *text; | |
1322 gint ne; | |
1323 gint i; | |
1324 | |
1325 if (!item) return NULL; | |
1326 | |
1327 marker = item->marker; | |
1328 if (!marker) return NULL; | |
1329 | |
1330 data = item->data; | |
1331 ne = item->elements; | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1332 if (ne > EXIF_DATA_AS_TEXT_MAX_COUNT) ne = EXIF_DATA_AS_TEXT_MAX_COUNT; |
9 | 1333 string = g_string_new(""); |
1334 switch (item->format) | |
1335 { | |
1336 case EXIF_FORMAT_UNKNOWN: | |
1337 break; | |
1338 case EXIF_FORMAT_BYTE_UNSIGNED: | |
1339 case EXIF_FORMAT_BYTE: | |
1340 case EXIF_FORMAT_UNDEFINED: | |
1288 | 1341 if (ne == 1 && marker->list && format == METADATA_FORMATTED) |
9 | 1342 { |
1343 gchar *result; | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1344 guchar val; |
9 | 1345 |
1346 if (item->format == EXIF_FORMAT_BYTE_UNSIGNED || | |
1347 item->format == EXIF_FORMAT_UNDEFINED) | |
1348 { | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1349 val = ((guchar *)data)[0]; |
9 | 1350 } |
1351 else | |
1352 { | |
1010 | 1353 val = (guchar)(((gchar *)data)[0]); |
9 | 1354 } |
1355 | |
57
a8c9992320f4
Fri Jun 10 20:57:42 2005 John Ellis <johne@verizon.net>
gqview
parents:
55
diff
changeset
|
1356 result = exif_text_list_find_value(marker->list, (guint)val); |
9 | 1357 string = g_string_append(string, result); |
1358 g_free(result); | |
1359 } | |
1360 else | |
1361 { | |
1362 string = string_append_raw_bytes(string, data, ne); | |
1363 } | |
1364 break; | |
1365 case EXIF_FORMAT_STRING: | |
1238
947e603a52c6
simplified metadata interface, dropped metadata_read,
nadvornik
parents:
1211
diff
changeset
|
1366 if (item->data) string = g_string_append(string, (gchar *)(item->data)); |
9 | 1367 break; |
1368 case EXIF_FORMAT_SHORT_UNSIGNED: | |
1288 | 1369 if (ne == 1 && marker->list && format == METADATA_FORMATTED) |
9 | 1370 { |
1371 gchar *result; | |
1372 | |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
1373 result = exif_text_list_find_value(marker->list, ((guint16 *)data)[0]); |
9 | 1374 string = g_string_append(string, result); |
1375 g_free(result); | |
1376 } | |
1377 else for (i = 0; i < ne; i++) | |
1378 { | |
1379 g_string_append_printf(string, "%s%hd", (i > 0) ? ", " : "", | |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
1380 ((guint16 *)data)[i]); |
9 | 1381 } |
1382 break; | |
1383 case EXIF_FORMAT_LONG_UNSIGNED: | |
1384 for (i = 0; i < ne; i++) | |
1385 { | |
1386 g_string_append_printf(string, "%s%ld", (i > 0) ? ", " : "", | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1387 (gulong)((guint32 *)data)[i]); |
9 | 1388 } |
1389 break; | |
1390 case EXIF_FORMAT_RATIONAL_UNSIGNED: | |
1391 for (i = 0; i < ne; i++) | |
1392 { | |
1393 ExifRational *r; | |
1394 | |
1395 r = &((ExifRational *)data)[i]; | |
1396 g_string_append_printf(string, "%s%ld/%ld", (i > 0) ? ", " : "", | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1397 (gulong)r->num, (gulong)r->den); |
9 | 1398 } |
1399 break; | |
1400 case EXIF_FORMAT_SHORT: | |
1401 for (i = 0; i < ne; i++) | |
1402 { | |
1403 g_string_append_printf(string, "%s%hd", (i > 0) ? ", " : "", | |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
1404 ((gint16 *)data)[i]); |
9 | 1405 } |
1406 break; | |
1407 case EXIF_FORMAT_LONG: | |
1408 for (i = 0; i < ne; i++) | |
1409 { | |
1410 g_string_append_printf(string, "%s%ld", (i > 0) ? ", " : "", | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1411 (glong)((gint32 *)data)[i]); |
9 | 1412 } |
1413 break; | |
1414 case EXIF_FORMAT_RATIONAL: | |
1415 for (i = 0; i < ne; i++) | |
1416 { | |
1417 ExifRational *r; | |
1418 | |
1419 r = &((ExifRational *)data)[i]; | |
1420 g_string_append_printf(string, "%s%ld/%ld", (i > 0) ? ", " : "", | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1421 (glong)r->num, (glong)r->den); |
9 | 1422 } |
1423 break; | |
1424 case EXIF_FORMAT_FLOAT: | |
1425 for (i = 0; i < ne; i++) | |
1426 { | |
1427 g_string_append_printf(string, "%s%f", (i > 0) ? ", " : "", | |
1428 ((float *)data)[i]); | |
1429 } | |
1430 break; | |
1431 case EXIF_FORMAT_DOUBLE: | |
1432 for (i = 0; i < ne; i++) | |
1433 { | |
1434 g_string_append_printf(string, "%s%f", (i > 0) ? ", " : "", | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
1435 ((gdouble *)data)[i]); |
9 | 1436 } |
1437 break; | |
1438 } | |
1439 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1440 if (item->elements > EXIF_DATA_AS_TEXT_MAX_COUNT && |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1441 item->format != EXIF_FORMAT_STRING) |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1442 { |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1443 g_string_append(string, " ..."); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1444 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1445 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1446 text = string->str; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
110
diff
changeset
|
1447 g_string_free(string, FALSE); |
9 | 1448 |
1449 return text; | |
1450 } | |
1451 | |
1288 | 1452 gchar *exif_item_get_string(ExifItem *item, gint idx) |
1453 { | |
1454 return exif_item_get_data_as_text_full(item, METADATA_PLAIN); | |
1455 } | |
1456 | |
1457 gchar *exif_item_get_data_as_text(ExifItem *item) | |
1458 { | |
1459 return exif_item_get_data_as_text_full(item, METADATA_FORMATTED); | |
1460 } | |
1461 | |
9 | 1462 gint exif_item_get_integer(ExifItem *item, gint *value) |
1463 { | |
1464 if (!item) return FALSE; | |
1465 | |
1466 switch (item->format) | |
1467 { | |
1468 case EXIF_FORMAT_SHORT: | |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
1469 *value = (gint)(((gint16 *)(item->data))[0]); |
9 | 1470 return TRUE; |
1471 break; | |
1472 case EXIF_FORMAT_SHORT_UNSIGNED: | |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
1473 *value = (gint)(((guint16 *)(item->data))[0]); |
9 | 1474 return TRUE; |
1475 break; | |
1476 case EXIF_FORMAT_LONG: | |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
1477 *value = (gint)(((gint32 *)(item->data))[0]); |
9 | 1478 return TRUE; |
1479 break; | |
1480 case EXIF_FORMAT_LONG_UNSIGNED: | |
1481 /* FIXME: overflow possible */ | |
110
9fbf210edc6f
Tue Nov 14 15:36:14 2006 John Ellis <johne@verizon.net>
gqview
parents:
107
diff
changeset
|
1482 *value = (gint)(((guint32 *)(item->data))[0]); |
9 | 1483 return TRUE; |
1484 default: | |
1485 /* all other type return FALSE */ | |
1486 break; | |
1487 } | |
1488 return FALSE; | |
1489 } | |
1490 | |
1491 | |
1058
b600689a677e
Fix up few signed vs unsigned warnings: exif_item_get_rational() last parameter is now of guint type.
zas_
parents:
1055
diff
changeset
|
1492 ExifRational *exif_item_get_rational(ExifItem *item, gint *sign, guint n) |
9 | 1493 { |
1494 if (!item) return NULL; | |
1058
b600689a677e
Fix up few signed vs unsigned warnings: exif_item_get_rational() last parameter is now of guint type.
zas_
parents:
1055
diff
changeset
|
1495 if (n >= item->elements) return NULL; |
9 | 1496 |
1497 if (item->format == EXIF_FORMAT_RATIONAL || | |
1498 item->format == EXIF_FORMAT_RATIONAL_UNSIGNED) | |
1499 { | |
1500 if (sign) *sign = (item->format == EXIF_FORMAT_RATIONAL); | |
1052 | 1501 return &((ExifRational *)(item->data))[n]; |
9 | 1502 } |
1503 | |
1504 return NULL; | |
1505 } | |
1506 | |
1053
77ca9a5d42be
fixed charset of exiv2 strings in non-utf8 locales
nadvornik
parents:
1052
diff
changeset
|
1507 gchar *exif_get_tag_description_by_key(const gchar *key) |
9 | 1508 { |
1509 gint i; | |
1510 | |
1511 if (!key) return NULL; | |
1512 | |
1513 i = 0; | |
1514 while (ExifKnownMarkersList[i].tag > 0) | |
1515 { | |
1053
77ca9a5d42be
fixed charset of exiv2 strings in non-utf8 locales
nadvornik
parents:
1052
diff
changeset
|
1516 if (strcmp(key, ExifKnownMarkersList[i].key) == 0) return g_strdup(_(ExifKnownMarkersList[i].description)); |
9 | 1517 i++; |
1518 } | |
1519 | |
1052 | 1520 i = 0; |
1521 while (ExifKnownGPSInfoMarkersList[i].tag > 0) | |
1522 { | |
1523 if (strcmp(key, ExifKnownGPSInfoMarkersList[i].key) == 0) return _(ExifKnownGPSInfoMarkersList[i].description); | |
1524 i++; | |
1525 } | |
1526 | |
9 | 1527 return NULL; |
1528 } | |
1529 | |
1530 static void exif_write_item(FILE *f, ExifItem *item) | |
1531 { | |
1532 gchar *text; | |
1533 | |
1534 text = exif_item_get_data_as_text(item); | |
1535 if (text) | |
1536 { | |
185 | 1537 gchar *tag = exif_item_get_tag_name(item); |
1305 | 1538 g_fprintf(f, "%4x %9s %30s %s\n", item->tag, ExifFormatList[item->format].short_name, |
185 | 1539 tag, text); |
1540 g_free(tag); | |
9 | 1541 } |
1542 g_free(text); | |
1543 } | |
1544 | |
1545 void exif_write_data_list(ExifData *exif, FILE *f, gint human_readable_list) | |
1546 { | |
1547 if (!f || !exif) return; | |
1548 | |
1305 | 1549 g_fprintf(f, " tag format key value\n"); |
1550 g_fprintf(f, "----------------------------------------------------\n"); | |
9 | 1551 |
1552 if (human_readable_list) | |
1553 { | |
1554 gint i; | |
1555 | |
1556 i = 0; | |
1557 while (ExifFormattedList[i].key) | |
1558 { | |
1559 gchar *text; | |
1560 | |
1561 text = exif_get_formatted_by_key(exif, ExifFormattedList[i].key, NULL); | |
1562 if (text) | |
1563 { | |
1305 | 1564 g_fprintf(f, " %9s %30s %s\n", "string", ExifFormattedList[i].key, text); |
9 | 1565 } |
1566 i++; | |
1567 } | |
1568 } | |
1569 else | |
1570 { | |
1571 GList *work; | |
1572 | |
1573 work = exif->items; | |
1574 while (work) | |
1575 { | |
1576 ExifItem *item; | |
1577 | |
1578 item = work->data; | |
1579 work = work->next; | |
1580 | |
1581 exif_write_item(f, item); | |
1582 } | |
1583 } | |
1305 | 1584 g_fprintf(f, "----------------------------------------------------\n"); |
9 | 1585 } |
1586 | |
1211 | 1587 gboolean exif_write(ExifData *exif) |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
185
diff
changeset
|
1588 { |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
541
diff
changeset
|
1589 log_printf("Not compiled with EXIF write support"); |
1211 | 1590 return FALSE; |
1591 } | |
1592 | |
1593 gboolean exif_write_sidecar(ExifData *exif, gchar *path) | |
1594 { | |
1595 log_printf("Not compiled with EXIF write support"); | |
1596 return FALSE; | |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
185
diff
changeset
|
1597 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
185
diff
changeset
|
1598 |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
185
diff
changeset
|
1599 |
1203
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1183
diff
changeset
|
1600 gint exif_update_metadata(ExifData *exif, const gchar *key, const GList *values) |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
185
diff
changeset
|
1601 { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
185
diff
changeset
|
1602 return 0; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
185
diff
changeset
|
1603 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
185
diff
changeset
|
1604 |
1288 | 1605 GList *exif_get_metadata(ExifData *exif, const gchar *key, MetadataFormat format) |
1238
947e603a52c6
simplified metadata interface, dropped metadata_read,
nadvornik
parents:
1211
diff
changeset
|
1606 { |
947e603a52c6
simplified metadata interface, dropped metadata_read,
nadvornik
parents:
1211
diff
changeset
|
1607 gchar *str; |
1288 | 1608 ExifItem *item; |
1609 | |
1610 if (!key) return NULL; | |
1611 | |
1612 if (format == METADATA_FORMATTED) | |
1613 { | |
1614 gchar *text; | |
1615 gint key_valid; | |
1616 text = exif_get_formatted_by_key(exif, key, &key_valid); | |
1617 if (key_valid) return g_list_append(NULL, text); | |
1618 } | |
1619 | |
1620 item = exif_get_item(exif, key); | |
1238
947e603a52c6
simplified metadata interface, dropped metadata_read,
nadvornik
parents:
1211
diff
changeset
|
1621 if (!item) return NULL; |
947e603a52c6
simplified metadata interface, dropped metadata_read,
nadvornik
parents:
1211
diff
changeset
|
1622 |
1288 | 1623 str = exif_item_get_data_as_text_full(item, format); |
1238
947e603a52c6
simplified metadata interface, dropped metadata_read,
nadvornik
parents:
1211
diff
changeset
|
1624 |
947e603a52c6
simplified metadata interface, dropped metadata_read,
nadvornik
parents:
1211
diff
changeset
|
1625 if (!str) return NULL; |
947e603a52c6
simplified metadata interface, dropped metadata_read,
nadvornik
parents:
1211
diff
changeset
|
1626 |
947e603a52c6
simplified metadata interface, dropped metadata_read,
nadvornik
parents:
1211
diff
changeset
|
1627 return g_list_append(NULL, str); |
947e603a52c6
simplified metadata interface, dropped metadata_read,
nadvornik
parents:
1211
diff
changeset
|
1628 } |
947e603a52c6
simplified metadata interface, dropped metadata_read,
nadvornik
parents:
1211
diff
changeset
|
1629 |
1010 | 1630 typedef struct _UnmapData UnmapData; |
1631 struct _UnmapData | |
1632 { | |
1633 guchar *ptr; | |
1634 guchar *map_data; | |
1635 size_t map_len; | |
1636 }; | |
1637 | |
1638 static GList *exif_unmap_list = 0; | |
1639 | |
1060 | 1640 guchar *exif_get_preview(ExifData *exif, guint *data_len, gint requested_width, gint requested_height) |
1010 | 1641 { |
1642 guint offset; | |
1643 const gchar* path; | |
1644 struct stat st; | |
1645 guchar *map_data; | |
1646 size_t map_len; | |
1647 int fd; | |
1648 | |
1649 if (!exif) return NULL; | |
1650 path = exif->path; | |
1651 | |
1652 fd = open(path, O_RDONLY); | |
1653 | |
1654 | |
1655 if (fd == -1) | |
1656 { | |
1657 return 0; | |
1658 } | |
1659 | |
1660 if (fstat(fd, &st) == -1) | |
1661 { | |
1662 close(fd); | |
1663 return 0; | |
1664 } | |
1665 map_len = st.st_size; | |
1666 map_data = (guchar *) mmap(0, map_len, PROT_READ, MAP_PRIVATE, fd, 0); | |
1667 close(fd); | |
1668 | |
1669 if (map_data == MAP_FAILED) | |
1670 { | |
1671 return 0; | |
1672 } | |
1673 | |
1674 if (format_raw_img_exif_offsets(map_data, map_len, &offset, NULL) && offset) | |
1675 { | |
1676 UnmapData *ud; | |
1677 | |
1179 | 1678 DEBUG_1("%s: offset %u", path, offset); |
1010 | 1679 |
1680 *data_len = map_len - offset; | |
1681 ud = g_new(UnmapData, 1); | |
1682 ud->ptr = map_data + offset; | |
1683 ud->map_data = map_data; | |
1684 ud->map_len = map_len; | |
1685 | |
1686 exif_unmap_list = g_list_prepend(exif_unmap_list, ud); | |
1687 return ud->ptr; | |
1688 } | |
1689 | |
1690 munmap(map_data, map_len); | |
1691 return NULL; | |
1692 | |
1693 } | |
1694 | |
1695 void exif_free_preview(guchar *buf) | |
1696 { | |
1697 GList *work = exif_unmap_list; | |
1698 | |
1699 while (work) | |
1700 { | |
1701 UnmapData *ud = (UnmapData *)work->data; | |
1702 if (ud->ptr == buf) | |
1703 { | |
1704 exif_unmap_list = g_list_remove_link(exif_unmap_list, work); | |
1705 g_free(ud); | |
1706 return; | |
1707 } | |
1025 | 1708 work = work->next; |
1010 | 1709 } |
1710 g_assert_not_reached(); | |
1711 } | |
1712 | |
1288 | 1713 void exif_init(void) |
1714 { | |
1715 } | |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
185
diff
changeset
|
1716 |
442 | 1717 #endif |
177 | 1718 /* not HAVE_EXIV2 */ |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1053
diff
changeset
|
1719 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |