Mercurial > geeqie
annotate src/exiv2.cc @ 179:37004d5a584a
and first version that actually shows some exif data (see advanced view)
author | nadvornik |
---|---|
date | Wed, 13 Feb 2008 17:08:04 +0000 |
parents | 9dc8bc9b2bb9 |
children | e6c8cf017d68 |
rev | line source |
---|---|
178 | 1 |
2 #ifdef HAVE_CONFIG_H | |
3 # include "config.h" | |
4 #endif | |
5 | |
6 #ifdef HAVE_EXIV2 | |
7 | |
8 #include <exiv2/image.hpp> | |
9 #include <exiv2/exif.hpp> | |
10 #include <iostream> | |
11 | |
12 extern "C" { | |
13 | |
14 #include <glib.h> | |
15 #include "exif.h" | |
16 | |
17 | |
18 struct _ExifData | |
19 { | |
20 Exiv2::ExifData exifData; | |
21 Exiv2::ExifData::const_iterator iter; | |
22 }; | |
23 | |
24 | |
25 ExifData *exif_read(gchar *path, gint parse_color_profile) | |
26 { | |
27 try { | |
28 ExifData *exif = g_new0(ExifData, 1); | |
29 | |
30 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path); | |
31 g_assert (image.get() != 0); | |
32 image->readMetadata(); | |
33 exif->exifData = image->exifData(); | |
179
37004d5a584a
and first version that actually shows some exif data (see advanced view)
nadvornik
parents:
178
diff
changeset
|
34 return exif; |
178 | 35 } |
36 catch (Exiv2::AnyError& e) { | |
37 std::cout << "Caught Exiv2 exception '" << e << "'\n"; | |
179
37004d5a584a
and first version that actually shows some exif data (see advanced view)
nadvornik
parents:
178
diff
changeset
|
38 return 0; |
178 | 39 } |
179
37004d5a584a
and first version that actually shows some exif data (see advanced view)
nadvornik
parents:
178
diff
changeset
|
40 |
178 | 41 } |
42 | |
43 void exif_free(ExifData *exif) | |
44 { | |
45 } | |
46 | |
47 | |
48 gchar *exif_get_data_as_text(ExifData *exif, const gchar *key) | |
49 { | |
50 return g_strdup(exif->exifData[key].toString().c_str()); | |
51 } | |
52 | |
53 gint exif_get_integer(ExifData *exif, const gchar *key, gint *value) | |
54 { | |
55 return exif->exifData[key].toLong(); | |
56 } | |
57 | |
58 ExifRational *exif_get_rational(ExifData *exif, const gchar *key, gint *sign) | |
59 { | |
60 /* Exiv2::Rational v = exif->exifData[key]; | |
61 ExifRational *ret = | |
62 return exif->exifData[key]; | |
63 */ | |
64 } | |
65 | |
66 double exif_rational_to_double(ExifRational *r, gint sign) | |
67 { | |
68 if (!r || r->den == 0.0) return 0.0; | |
69 | |
70 if (sign) return (double)((int)r->num) / (double)((int)r->den); | |
71 return (double)r->num / r->den; | |
72 } | |
73 | |
74 ExifItem *exif_get_item(ExifData *exif, const gchar *key) | |
75 { | |
76 Exiv2::Exifdatum *item = &exif->exifData[key]; | |
77 return (ExifItem *)item; | |
78 } | |
79 | |
80 ExifItem *exif_get_first_item(ExifData *exif) | |
81 { | |
82 exif->iter = exif->exifData.begin(); | |
83 if (exif->iter == exif->exifData.end()) return NULL; | |
84 const Exiv2::Exifdatum *item = &*exif->iter; | |
85 return (ExifItem *)item; | |
86 } | |
87 | |
88 ExifItem *exif_get_next_item(ExifData *exif) | |
89 { | |
90 exif->iter++; | |
91 if (exif->iter == exif->exifData.end()) return NULL; | |
92 const Exiv2::Exifdatum *item = &*exif->iter; | |
93 return (ExifItem *)item; | |
94 } | |
95 | |
96 const char *exif_item_get_tag_name(ExifItem *item) | |
97 { | |
98 return ((Exiv2::Exifdatum *)item)->tagName().c_str(); | |
99 } | |
100 | |
101 guint exif_item_get_tag_id(ExifItem *item) | |
102 { | |
103 return ((Exiv2::Exifdatum *)item)->idx(); | |
104 } | |
105 | |
106 guint exif_item_get_elements(ExifItem *item) | |
107 { | |
108 return ((Exiv2::Exifdatum *)item)->count(); | |
109 } | |
110 | |
111 char *exif_item_get_data(ExifItem *item, guint *data_len) | |
112 { | |
113 } | |
114 | |
115 const char *exif_item_get_description(ExifItem *item) | |
116 { | |
117 return ((Exiv2::Exifdatum *)item)->tagLabel().c_str(); | |
118 } | |
119 | |
120 /* | |
121 invalidTypeId, unsignedByte, asciiString, unsignedShort, | |
122 unsignedLong, unsignedRational, signedByte, undefined, | |
123 signedShort, signedLong, signedRational, string, | |
124 date, time, comment, directory, | |
125 xmpText, xmpAlt, xmpBag, xmpSeq, | |
126 langAlt, lastTypeId | |
127 | |
128 EXIF_FORMAT_UNKNOWN = 0, | |
129 EXIF_FORMAT_BYTE_UNSIGNED = 1, | |
130 EXIF_FORMAT_STRING = 2, | |
131 EXIF_FORMAT_SHORT_UNSIGNED = 3, | |
132 EXIF_FORMAT_LONG_UNSIGNED = 4, | |
133 EXIF_FORMAT_RATIONAL_UNSIGNED = 5, | |
134 EXIF_FORMAT_BYTE = 6, | |
135 EXIF_FORMAT_UNDEFINED = 7, | |
136 EXIF_FORMAT_SHORT = 8, | |
137 EXIF_FORMAT_LONG = 9, | |
138 EXIF_FORMAT_RATIONAL = 10, | |
139 EXIF_FORMAT_FLOAT = 11, | |
140 EXIF_FORMAT_DOUBLE = 12 | |
141 */ | |
142 | |
143 | |
144 guint exif_item_get_format_id(ExifItem *item) | |
145 { | |
146 return ((Exiv2::Exifdatum *)item)->typeId(); | |
147 } | |
148 const char *exif_item_get_format_name(ExifItem *item, gint brief) | |
149 { | |
150 /* | |
151 return exif_item_get_tag_name(item); | |
152 */ | |
153 } | |
154 | |
155 | |
156 gchar *exif_item_get_data_as_text(ExifItem *item) | |
157 { | |
158 return g_strdup(((Exiv2::Exifdatum *)item)->toString().c_str()); | |
159 } | |
160 | |
161 | |
162 gint exif_item_get_integer(ExifItem *item, gint *value) | |
163 { | |
164 } | |
165 | |
166 ExifRational *exif_item_get_rational(ExifItem *item, gint *sign) | |
167 { | |
168 } | |
169 | |
170 const gchar *exif_get_description_by_key(const gchar *key) | |
171 { | |
172 } | |
173 | |
174 gint format_raw_img_exif_offsets_fd(int fd, const gchar *path, | |
175 unsigned char *header_data, const guint header_len, | |
176 guint *image_offset, guint *exif_offset) | |
177 { | |
178 return 0; | |
179 } | |
180 | |
181 } | |
182 | |
183 #endif | |
184 /* HAVE_EXIV2 */ |