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