annotate src/exif.c @ 64:04ff0df3ad2f

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