Mercurial > geeqie
annotate src/exiv2.cc @ 180:e6c8cf017d68
more exiv2 fixes
author | nadvornik |
---|---|
date | Wed, 13 Feb 2008 17:47:55 +0000 |
parents | 37004d5a584a |
children | 8a417f10ba09 |
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 { | |
180 | 55 Exiv2::ExifKey ekey(key); |
56 Exiv2::ExifData::iterator pos = exif->exifData.findKey(ekey); | |
57 if (pos == exif->exifData.end()) return 0; | |
58 *value = pos->getValue()->toLong(); | |
59 | |
60 return 1; | |
178 | 61 } |
62 | |
63 ExifRational *exif_get_rational(ExifData *exif, const gchar *key, gint *sign) | |
64 { | |
65 /* Exiv2::Rational v = exif->exifData[key]; | |
66 ExifRational *ret = | |
67 return exif->exifData[key]; | |
68 */ | |
69 } | |
70 | |
71 double exif_rational_to_double(ExifRational *r, gint sign) | |
72 { | |
73 if (!r || r->den == 0.0) return 0.0; | |
74 | |
75 if (sign) return (double)((int)r->num) / (double)((int)r->den); | |
76 return (double)r->num / r->den; | |
77 } | |
78 | |
79 ExifItem *exif_get_item(ExifData *exif, const gchar *key) | |
80 { | |
81 Exiv2::Exifdatum *item = &exif->exifData[key]; | |
82 return (ExifItem *)item; | |
83 } | |
84 | |
85 ExifItem *exif_get_first_item(ExifData *exif) | |
86 { | |
87 exif->iter = exif->exifData.begin(); | |
88 if (exif->iter == exif->exifData.end()) return NULL; | |
89 const Exiv2::Exifdatum *item = &*exif->iter; | |
90 return (ExifItem *)item; | |
91 } | |
92 | |
93 ExifItem *exif_get_next_item(ExifData *exif) | |
94 { | |
95 exif->iter++; | |
96 if (exif->iter == exif->exifData.end()) return NULL; | |
97 const Exiv2::Exifdatum *item = &*exif->iter; | |
98 return (ExifItem *)item; | |
99 } | |
100 | |
101 const char *exif_item_get_tag_name(ExifItem *item) | |
102 { | |
180 | 103 return ((Exiv2::Exifdatum *)item)->key().c_str(); |
178 | 104 } |
105 | |
106 guint exif_item_get_tag_id(ExifItem *item) | |
107 { | |
180 | 108 return ((Exiv2::Exifdatum *)item)->tag(); |
178 | 109 } |
110 | |
111 guint exif_item_get_elements(ExifItem *item) | |
112 { | |
113 return ((Exiv2::Exifdatum *)item)->count(); | |
114 } | |
115 | |
116 char *exif_item_get_data(ExifItem *item, guint *data_len) | |
117 { | |
118 } | |
119 | |
120 const char *exif_item_get_description(ExifItem *item) | |
121 { | |
122 return ((Exiv2::Exifdatum *)item)->tagLabel().c_str(); | |
123 } | |
124 | |
125 /* | |
126 invalidTypeId, unsignedByte, asciiString, unsignedShort, | |
127 unsignedLong, unsignedRational, signedByte, undefined, | |
128 signedShort, signedLong, signedRational, string, | |
129 date, time, comment, directory, | |
130 xmpText, xmpAlt, xmpBag, xmpSeq, | |
131 langAlt, lastTypeId | |
132 | |
133 EXIF_FORMAT_UNKNOWN = 0, | |
134 EXIF_FORMAT_BYTE_UNSIGNED = 1, | |
135 EXIF_FORMAT_STRING = 2, | |
136 EXIF_FORMAT_SHORT_UNSIGNED = 3, | |
137 EXIF_FORMAT_LONG_UNSIGNED = 4, | |
138 EXIF_FORMAT_RATIONAL_UNSIGNED = 5, | |
139 EXIF_FORMAT_BYTE = 6, | |
140 EXIF_FORMAT_UNDEFINED = 7, | |
141 EXIF_FORMAT_SHORT = 8, | |
142 EXIF_FORMAT_LONG = 9, | |
143 EXIF_FORMAT_RATIONAL = 10, | |
144 EXIF_FORMAT_FLOAT = 11, | |
145 EXIF_FORMAT_DOUBLE = 12 | |
146 */ | |
147 | |
148 | |
149 guint exif_item_get_format_id(ExifItem *item) | |
150 { | |
151 return ((Exiv2::Exifdatum *)item)->typeId(); | |
152 } | |
153 const char *exif_item_get_format_name(ExifItem *item, gint brief) | |
154 { | |
180 | 155 return ((Exiv2::Exifdatum *)item)->typeName(); |
178 | 156 } |
157 | |
158 | |
159 gchar *exif_item_get_data_as_text(ExifItem *item) | |
160 { | |
161 return g_strdup(((Exiv2::Exifdatum *)item)->toString().c_str()); | |
162 } | |
163 | |
164 | |
165 gint exif_item_get_integer(ExifItem *item, gint *value) | |
166 { | |
167 } | |
168 | |
169 ExifRational *exif_item_get_rational(ExifItem *item, gint *sign) | |
170 { | |
171 } | |
172 | |
173 const gchar *exif_get_description_by_key(const gchar *key) | |
174 { | |
175 } | |
176 | |
177 gint format_raw_img_exif_offsets_fd(int fd, const gchar *path, | |
178 unsigned char *header_data, const guint header_len, | |
179 guint *image_offset, guint *exif_offset) | |
180 { | |
181 return 0; | |
182 } | |
183 | |
184 } | |
185 | |
186 #endif | |
187 /* HAVE_EXIV2 */ |