Mercurial > geeqie
annotate src/exiv2.cc @ 188:0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
author | nadvornik |
---|---|
date | Sun, 16 Mar 2008 10:32:52 +0000 |
parents | 9eafc4957f1a |
children | 19df9953a5d1 |
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 | |
186
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
12 #include <sys/types.h> |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
13 #include <sys/stat.h> |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
14 #include <unistd.h> |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
15 #include <fcntl.h> |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
16 #include <sys/mman.h> |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
17 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
18 #include <exiv2/tiffparser.hpp> |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
19 #include <exiv2/tiffcomposite.hpp> |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
20 #include <exiv2/tiffvisitor.hpp> |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
21 #include <exiv2/tiffimage.hpp> |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
22 #include <exiv2/cr2image.hpp> |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
23 #include <exiv2/orfimage.hpp> |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
24 #include <exiv2/rafimage.hpp> |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
25 #include <exiv2/futils.hpp> |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
26 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
27 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
28 |
178 | 29 extern "C" { |
30 #include <glib.h> | |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
31 #include "gqview.h" |
178 | 32 #include "exif.h" |
33 | |
184 | 34 } |
178 | 35 |
36 struct _ExifData | |
37 { | |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
38 Exiv2::Image::AutoPtr image; |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
39 Exiv2::Image::AutoPtr sidecar; |
185 | 40 Exiv2::ExifData::const_iterator exifIter; /* for exif_get_next_item */ |
41 Exiv2::IptcData::const_iterator iptcIter; /* for exif_get_next_item */ | |
42 Exiv2::XmpData::const_iterator xmpIter; /* for exif_get_next_item */ | |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
43 bool have_sidecar; |
184 | 44 |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
45 |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
46 _ExifData(gchar *path, gchar *sidecar_path, gint parse_color_profile) |
184 | 47 { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
48 have_sidecar = false; |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
49 image = Exiv2::ImageFactory::open(path); |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
50 // g_assert (image.get() != 0); |
184 | 51 image->readMetadata(); |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
52 |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
53 printf("xmp count %d\n", image->xmpData().count()); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
54 if (sidecar_path && image->xmpData().empty()) |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
55 { |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
56 sidecar = Exiv2::ImageFactory::open(sidecar_path); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
57 sidecar->readMetadata(); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
58 have_sidecar = sidecar->good(); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
59 printf("sidecar xmp count %d\n", sidecar->xmpData().count()); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
60 } |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
61 |
184 | 62 } |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
63 |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
64 void writeMetadata() |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
65 { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
66 if (have_sidecar) sidecar->writeMetadata(); |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
67 image->writeMetadata(); |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
68 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
69 |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
70 Exiv2::ExifData &exifData () |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
71 { |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
72 return image->exifData(); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
73 } |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
74 |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
75 Exiv2::IptcData &iptcData () |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
76 { |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
77 return image->iptcData(); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
78 } |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
79 |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
80 Exiv2::XmpData &xmpData () |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
81 { |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
82 return have_sidecar ? sidecar->xmpData() : image->xmpData(); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
83 } |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
84 |
184 | 85 |
178 | 86 }; |
87 | |
184 | 88 extern "C" { |
178 | 89 |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
90 ExifData *exif_read(gchar *path, gchar *sidecar_path, gint parse_color_profile) |
178 | 91 { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
92 printf("exif %s %s\n", path, sidecar_path ? sidecar_path : "-"); |
178 | 93 try { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
94 return new ExifData(path, sidecar_path, parse_color_profile); |
178 | 95 } |
96 catch (Exiv2::AnyError& e) { | |
97 std::cout << "Caught Exiv2 exception '" << e << "'\n"; | |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
98 return NULL; |
178 | 99 } |
179
37004d5a584a
and first version that actually shows some exif data (see advanced view)
nadvornik
parents:
178
diff
changeset
|
100 |
178 | 101 } |
102 | |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
103 int exif_write(ExifData *exif) |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
104 { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
105 try { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
106 exif->writeMetadata(); |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
107 return 1; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
108 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
109 catch (Exiv2::AnyError& e) { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
110 std::cout << "Caught Exiv2 exception '" << e << "'\n"; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
111 return 0; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
112 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
113 |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
114 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
115 |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
116 |
178 | 117 void exif_free(ExifData *exif) |
118 { | |
182 | 119 |
120 delete exif; | |
178 | 121 } |
122 | |
184 | 123 ExifItem *exif_get_item(ExifData *exif, const gchar *key) |
178 | 124 { |
183 | 125 try { |
185 | 126 Exiv2::Metadatum *item; |
127 try { | |
128 Exiv2::ExifKey ekey(key); | |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
129 Exiv2::ExifData::iterator pos = exif->exifData().findKey(ekey); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
130 if (pos == exif->exifData().end()) return NULL; |
185 | 131 item = &*pos; |
132 } | |
133 catch (Exiv2::AnyError& e) { | |
134 try { | |
135 Exiv2::IptcKey ekey(key); | |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
136 Exiv2::IptcData::iterator pos = exif->iptcData().findKey(ekey); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
137 if (pos == exif->iptcData().end()) return NULL; |
185 | 138 item = &*pos; |
139 } | |
140 catch (Exiv2::AnyError& e) { | |
141 Exiv2::XmpKey ekey(key); | |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
142 Exiv2::XmpData::iterator pos = exif->xmpData().findKey(ekey); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
143 if (pos == exif->xmpData().end()) return NULL; |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
144 item = &*pos; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
145 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
146 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
147 return (ExifItem *)item; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
148 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
149 catch (Exiv2::AnyError& e) { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
150 std::cout << "Caught Exiv2 exception '" << e << "'\n"; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
151 return NULL; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
152 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
153 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
154 |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
155 ExifItem *exif_add_item(ExifData *exif, const gchar *key) |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
156 { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
157 try { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
158 Exiv2::Metadatum *item; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
159 try { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
160 Exiv2::ExifKey ekey(key); |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
161 exif->exifData().add(ekey, NULL); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
162 Exiv2::ExifData::iterator pos = exif->exifData().end(); // a hack, there should be a better way to get the currently added item |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
163 pos--; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
164 item = &*pos; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
165 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
166 catch (Exiv2::AnyError& e) { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
167 try { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
168 Exiv2::IptcKey ekey(key); |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
169 exif->iptcData().add(ekey, NULL); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
170 Exiv2::IptcData::iterator pos = exif->iptcData().end(); |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
171 pos--; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
172 item = &*pos; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
173 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
174 catch (Exiv2::AnyError& e) { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
175 Exiv2::XmpKey ekey(key); |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
176 exif->xmpData().add(ekey, NULL); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
177 Exiv2::XmpData::iterator pos = exif->xmpData().end(); |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
178 pos--; |
185 | 179 item = &*pos; |
180 } | |
181 } | |
184 | 182 return (ExifItem *)item; |
183 | 183 } |
184 catch (Exiv2::AnyError& e) { | |
184 | 185 std::cout << "Caught Exiv2 exception '" << e << "'\n"; |
186 return NULL; | |
187 } | |
188 } | |
189 | |
190 | |
191 ExifItem *exif_get_first_item(ExifData *exif) | |
192 { | |
193 try { | |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
194 exif->exifIter = exif->exifData().begin(); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
195 exif->iptcIter = exif->iptcData().begin(); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
196 exif->xmpIter = exif->xmpData().begin(); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
197 if (exif->exifIter != exif->exifData().end()) |
185 | 198 { |
199 const Exiv2::Metadatum *item = &*exif->exifIter; | |
200 exif->exifIter++; | |
201 return (ExifItem *)item; | |
202 } | |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
203 if (exif->iptcIter != exif->iptcData().end()) |
185 | 204 { |
205 const Exiv2::Metadatum *item = &*exif->iptcIter; | |
206 exif->iptcIter++; | |
207 return (ExifItem *)item; | |
208 } | |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
209 if (exif->xmpIter != exif->xmpData().end()) |
185 | 210 { |
211 const Exiv2::Metadatum *item = &*exif->xmpIter; | |
212 exif->xmpIter++; | |
213 return (ExifItem *)item; | |
214 } | |
215 return NULL; | |
216 | |
184 | 217 } |
218 catch (Exiv2::AnyError& e) { | |
219 std::cout << "Caught Exiv2 exception '" << e << "'\n"; | |
183 | 220 return NULL; |
221 } | |
178 | 222 } |
223 | |
224 ExifItem *exif_get_next_item(ExifData *exif) | |
225 { | |
184 | 226 try { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
227 if (exif->exifIter != exif->exifData().end()) |
185 | 228 { |
229 const Exiv2::Metadatum *item = &*exif->exifIter; | |
230 exif->exifIter++; | |
231 return (ExifItem *)item; | |
232 } | |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
233 if (exif->iptcIter != exif->iptcData().end()) |
185 | 234 { |
235 const Exiv2::Metadatum *item = &*exif->iptcIter; | |
236 exif->iptcIter++; | |
237 return (ExifItem *)item; | |
238 } | |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
239 if (exif->xmpIter != exif->xmpData().end()) |
185 | 240 { |
241 const Exiv2::Metadatum *item = &*exif->xmpIter; | |
242 exif->xmpIter++; | |
243 return (ExifItem *)item; | |
244 } | |
245 return NULL; | |
184 | 246 } |
247 catch (Exiv2::AnyError& e) { | |
248 std::cout << "Caught Exiv2 exception '" << e << "'\n"; | |
249 return NULL; | |
250 } | |
178 | 251 } |
252 | |
185 | 253 char *exif_item_get_tag_name(ExifItem *item) |
178 | 254 { |
184 | 255 try { |
256 if (!item) return NULL; | |
185 | 257 return g_strdup(((Exiv2::Metadatum *)item)->key().c_str()); |
184 | 258 } |
259 catch (Exiv2::AnyError& e) { | |
260 std::cout << "Caught Exiv2 exception '" << e << "'\n"; | |
261 return NULL; | |
262 } | |
178 | 263 } |
264 | |
265 guint exif_item_get_tag_id(ExifItem *item) | |
266 { | |
184 | 267 try { |
268 if (!item) return 0; | |
185 | 269 return ((Exiv2::Metadatum *)item)->tag(); |
184 | 270 } |
271 catch (Exiv2::AnyError& e) { | |
272 std::cout << "Caught Exiv2 exception '" << e << "'\n"; | |
273 return 0; | |
274 } | |
178 | 275 } |
276 | |
277 guint exif_item_get_elements(ExifItem *item) | |
278 { | |
184 | 279 try { |
280 if (!item) return 0; | |
185 | 281 return ((Exiv2::Metadatum *)item)->count(); |
184 | 282 } |
283 catch (Exiv2::AnyError& e) { | |
284 std::cout << "Caught Exiv2 exception '" << e << "'\n"; | |
185 | 285 return 0; |
184 | 286 } |
178 | 287 } |
288 | |
289 char *exif_item_get_data(ExifItem *item, guint *data_len) | |
290 { | |
291 } | |
292 | |
182 | 293 char *exif_item_get_description(ExifItem *item) |
178 | 294 { |
184 | 295 try { |
296 if (!item) return NULL; | |
185 | 297 return g_strdup(((Exiv2::Metadatum *)item)->tagLabel().c_str()); |
184 | 298 } |
185 | 299 catch (std::exception& e) { |
300 // std::cout << "Caught Exiv2 exception '" << e << "'\n"; | |
184 | 301 return NULL; |
302 } | |
178 | 303 } |
304 | |
305 /* | |
306 invalidTypeId, unsignedByte, asciiString, unsignedShort, | |
307 unsignedLong, unsignedRational, signedByte, undefined, | |
308 signedShort, signedLong, signedRational, string, | |
309 date, time, comment, directory, | |
310 xmpText, xmpAlt, xmpBag, xmpSeq, | |
311 langAlt, lastTypeId | |
312 */ | |
313 | |
184 | 314 static guint format_id_trans_tbl [] = { |
315 EXIF_FORMAT_UNKNOWN, | |
316 EXIF_FORMAT_BYTE_UNSIGNED, | |
317 EXIF_FORMAT_STRING, | |
318 EXIF_FORMAT_SHORT_UNSIGNED, | |
319 EXIF_FORMAT_LONG_UNSIGNED, | |
320 EXIF_FORMAT_RATIONAL_UNSIGNED, | |
321 EXIF_FORMAT_BYTE, | |
322 EXIF_FORMAT_UNDEFINED, | |
323 EXIF_FORMAT_SHORT, | |
324 EXIF_FORMAT_LONG, | |
325 EXIF_FORMAT_RATIONAL, | |
326 EXIF_FORMAT_STRING, | |
327 EXIF_FORMAT_STRING, | |
328 EXIF_FORMAT_STRING, | |
329 EXIF_FORMAT_UNDEFINED, | |
330 EXIF_FORMAT_STRING, | |
331 EXIF_FORMAT_STRING, | |
332 EXIF_FORMAT_STRING, | |
333 EXIF_FORMAT_STRING | |
334 }; | |
335 | |
336 | |
178 | 337 |
338 guint exif_item_get_format_id(ExifItem *item) | |
339 { | |
184 | 340 try { |
341 if (!item) return EXIF_FORMAT_UNKNOWN; | |
185 | 342 guint id = ((Exiv2::Metadatum *)item)->typeId(); |
184 | 343 if (id >= (sizeof(format_id_trans_tbl) / sizeof(format_id_trans_tbl[0])) ) return EXIF_FORMAT_UNKNOWN; |
344 return format_id_trans_tbl[id]; | |
345 } | |
346 catch (Exiv2::AnyError& e) { | |
347 std::cout << "Caught Exiv2 exception '" << e << "'\n"; | |
348 return EXIF_FORMAT_UNKNOWN; | |
349 } | |
178 | 350 } |
184 | 351 |
178 | 352 const char *exif_item_get_format_name(ExifItem *item, gint brief) |
353 { | |
184 | 354 try { |
355 if (!item) return NULL; | |
185 | 356 return ((Exiv2::Metadatum *)item)->typeName(); |
184 | 357 } |
358 catch (Exiv2::AnyError& e) { | |
359 std::cout << "Caught Exiv2 exception '" << e << "'\n"; | |
360 return NULL; | |
361 } | |
178 | 362 } |
363 | |
364 | |
365 gchar *exif_item_get_data_as_text(ExifItem *item) | |
366 { | |
183 | 367 try { |
184 | 368 if (!item) return NULL; |
185 | 369 // std::stringstream str; // does not work with Exiv2::Metadatum because operator<< is not virtual |
370 // str << *((Exiv2::Metadatum *)item); | |
371 // return g_strdup(str.str().c_str()); | |
372 return g_strdup(((Exiv2::Metadatum *)item)->toString().c_str()); | |
183 | 373 } |
374 catch (Exiv2::AnyError& e) { | |
375 return NULL; | |
376 } | |
178 | 377 } |
378 | |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
379 gchar *exif_item_get_string(ExifItem *item, int idx) |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
380 { |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
381 try { |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
382 if (!item) return NULL; |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
383 Exiv2::Metadatum *em = (Exiv2::Metadatum *)item; |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
384 std::string str = em->toString(idx); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
385 if (idx == 0 && str == "") str = em->toString(); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
386 if (str.length() > 5 && str.substr(0, 5) == "lang=") |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
387 { |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
388 std::string::size_type pos = str.find_first_of(' '); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
389 if (pos != std::string::npos) str = str.substr(pos+1); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
390 } |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
391 |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
392 return g_strdup(str.c_str()); |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
393 } |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
394 catch (Exiv2::AnyError& e) { |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
395 return NULL; |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
396 } |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
397 } |
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
398 |
178 | 399 |
400 gint exif_item_get_integer(ExifItem *item, gint *value) | |
401 { | |
184 | 402 try { |
403 if (!item) return 0; | |
186
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
404 *value = ((Exiv2::Metadatum *)item)->toLong(); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
405 return 1; |
184 | 406 } |
407 catch (Exiv2::AnyError& e) { | |
408 std::cout << "Caught Exiv2 exception '" << e << "'\n"; | |
409 return 0; | |
410 } | |
178 | 411 } |
412 | |
413 ExifRational *exif_item_get_rational(ExifItem *item, gint *sign) | |
414 { | |
184 | 415 try { |
416 if (!item) return NULL; | |
185 | 417 Exiv2::Rational v = ((Exiv2::Metadatum *)item)->toRational(); |
184 | 418 static ExifRational ret; |
419 ret.num = v.first; | |
420 ret.den = v.second; | |
421 return &ret; | |
422 } | |
423 catch (Exiv2::AnyError& e) { | |
424 std::cout << "Caught Exiv2 exception '" << e << "'\n"; | |
425 return NULL; | |
426 } | |
178 | 427 } |
428 | |
182 | 429 const gchar *exif_get_tag_description_by_key(const gchar *key) |
178 | 430 { |
184 | 431 try { |
432 Exiv2::ExifKey ekey(key); | |
433 return Exiv2::ExifTags::tagLabel(ekey.tag(), ekey.ifdId ()); | |
434 } | |
435 catch (Exiv2::AnyError& e) { | |
436 std::cout << "Caught Exiv2 exception '" << e << "'\n"; | |
437 return NULL; | |
438 } | |
178 | 439 } |
440 | |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
441 int exif_item_set_string(ExifItem *item, const char *str) |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
442 { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
443 try { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
444 if (!item) return 0; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
445 ((Exiv2::Metadatum *)item)->setValue(std::string(str)); |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
446 return 1; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
447 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
448 catch (Exiv2::AnyError& e) { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
449 return 0; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
450 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
451 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
452 |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
453 int exif_item_delete(ExifData *exif, ExifItem *item) |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
454 { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
455 try { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
456 if (!item) return 0; |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
457 for (Exiv2::ExifData::iterator i = exif->exifData().begin(); i != exif->exifData().end(); ++i) { |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
458 if (((Exiv2::Metadatum *)item) == &*i) { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
459 i = exif->exifData().erase(i); |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
460 return 1; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
461 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
462 } |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
463 for (Exiv2::IptcData::iterator i = exif->iptcData().begin(); i != exif->iptcData().end(); ++i) { |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
464 if (((Exiv2::Metadatum *)item) == &*i) { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
465 i = exif->iptcData().erase(i); |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
466 return 1; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
467 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
468 } |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
469 for (Exiv2::XmpData::iterator i = exif->xmpData().begin(); i != exif->xmpData().end(); ++i) { |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
470 if (((Exiv2::Metadatum *)item) == &*i) { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
187
diff
changeset
|
471 i = exif->xmpData().erase(i); |
187
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
472 return 1; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
473 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
474 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
475 |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
476 return 0; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
477 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
478 catch (Exiv2::AnyError& e) { |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
479 return 0; |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
480 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
481 } |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
482 |
9eafc4957f1a
write support in Exiv2 wrapper; for now only string values
nadvornik
parents:
186
diff
changeset
|
483 |
186
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
484 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
485 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
486 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
487 /* This is a dirty hack to support raw file preview, bassed on |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
488 tiffparse.cpp from Exiv2 examples */ |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
489 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
490 class RawFile { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
491 public: |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
492 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
493 RawFile(int fd); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
494 ~RawFile(); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
495 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
496 const Exiv2::Value *find(uint16_t tag, uint16_t group); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
497 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
498 unsigned long preview_offset(); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
499 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
500 private: |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
501 int type; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
502 Exiv2::TiffComponent::AutoPtr rootDir; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
503 Exiv2::byte *map_data; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
504 size_t map_len; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
505 unsigned long offset; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
506 }; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
507 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
508 using namespace Exiv2; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
509 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
510 RawFile::RawFile(int fd) : map_data(NULL), map_len(0), offset(0) |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
511 { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
512 struct stat st; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
513 if (fstat(fd, &st) == -1) |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
514 { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
515 throw Error(14); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
516 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
517 map_len = st.st_size; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
518 map_data = (Exiv2::byte *) mmap(0, map_len, PROT_READ, MAP_PRIVATE, fd, 0); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
519 if (map_data == MAP_FAILED) |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
520 { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
521 throw Error(14); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
522 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
523 type = Exiv2::ImageFactory::getType(map_data, map_len); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
524 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
525 TiffHeaderBase *tiffHeader; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
526 switch (type) { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
527 case Exiv2::ImageType::tiff: |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
528 tiffHeader = new TiffHeade2(); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
529 break; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
530 case Exiv2::ImageType::cr2: |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
531 tiffHeader = new Cr2Header(); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
532 break; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
533 case Exiv2::ImageType::orf: |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
534 tiffHeader = new OrfHeader(); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
535 break; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
536 case Exiv2::ImageType::raf: |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
537 if (map_len < 84 + 4) throw Error(14); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
538 offset = getULong(map_data + 84, bigEndian); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
539 return; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
540 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
541 default: |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
542 throw Error(3, "RAW"); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
543 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
544 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
545 // process tiff-like formats |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
546 if (!tiffHeader->read(map_data, map_len)) throw Error(3, "TIFF"); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
547 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
548 TiffCompFactoryFct createFct = TiffCreator::create; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
549 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
550 rootDir = createFct(Tag::root, Group::none); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
551 if (0 == rootDir.get()) { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
552 throw Error(1, "No root element defined in TIFF structure"); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
553 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
554 rootDir->setStart(map_data + tiffHeader->offset()); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
555 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
556 TiffRwState::AutoPtr state( |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
557 new TiffRwState(tiffHeader->byteOrder(), 0, createFct)); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
558 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
559 TiffReader reader(map_data, |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
560 map_len, |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
561 rootDir.get(), |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
562 state); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
563 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
564 rootDir->accept(reader); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
565 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
566 delete tiffHeader; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
567 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
568 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
569 RawFile::~RawFile() |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
570 { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
571 if (map_data && munmap(map_data, map_len) == -1) |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
572 { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
573 printf("Failed to unmap file \n"); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
574 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
575 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
576 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
577 const Value * RawFile::find(uint16_t tag, uint16_t group) |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
578 { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
579 printf("%04x %04x\n", tag, group); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
580 TiffFinder finder(tag, group); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
581 rootDir->accept(finder); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
582 TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result()); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
583 if (te) |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
584 return te->pValue(); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
585 else |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
586 return NULL; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
587 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
588 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
589 unsigned long RawFile::preview_offset() |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
590 { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
591 const Value *val; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
592 if (offset) return offset; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
593 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
594 if (type == Exiv2::ImageType::cr2) |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
595 { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
596 val = find(0x111, Group::ifd0); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
597 if (val) return val->toLong(); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
598 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
599 return 0; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
600 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
601 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
602 val = find(0x201, Group::sub0_0); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
603 if (val) return val->toLong(); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
604 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
605 val = find(0x201, Group::ifd0); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
606 if (val) return val->toLong(); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
607 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
608 val = find(0x201, Group::ignr); // for PEF files, originally it was probably ifd2 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
609 if (val) return val->toLong(); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
610 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
611 val = find(0x111, Group::sub0_1); // dng |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
612 if (val) return val->toLong(); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
613 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
614 return 0; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
615 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
616 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
617 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
618 const static char *raw_ext_list[] = { ".cr2", ".nef", ".pef", ".arw", NULL }; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
619 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
620 extern "C" gint format_raw_img_exif_offsets_fd(int fd, const gchar *path, |
178 | 621 unsigned char *header_data, const guint header_len, |
622 guint *image_offset, guint *exif_offset) | |
623 { | |
186
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
624 int success; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
625 unsigned long offset; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
626 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
627 /* given image pathname, first do simple (and fast) file extension test */ |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
628 /* if (path) |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
629 { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
630 const gchar *ext; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
631 gint match = FALSE; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
632 gint i; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
633 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
634 ext = strrchr(path, '.'); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
635 if (!ext) return FALSE; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
636 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
637 for (i = 0; raw_ext_list[i]; i++) |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
638 { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
639 if (strcasecmp(raw_ext_list[i], ext) == 0) |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
640 { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
641 match = TRUE; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
642 break; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
643 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
644 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
645 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
646 if (!match) return FALSE; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
647 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
648 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
649 */ |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
650 try { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
651 RawFile rf(fd); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
652 offset = rf.preview_offset(); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
653 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
654 catch (Exiv2::AnyError& e) { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
655 std::cout << "Caught Exiv2 exception '" << e << "'\n"; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
656 return 0; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
657 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
658 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
659 if (image_offset) |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
660 { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
661 *image_offset = offset; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
662 if (lseek(fd, *image_offset, SEEK_SET) != *image_offset) |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
663 { |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
664 printf("Failed to seek to embedded image\n"); |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
665 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
666 *image_offset = 0; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
667 if (*exif_offset) *exif_offset = 0; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
668 success = FALSE; |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
669 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
670 } |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
671 |
bd3fc1aa7fe9
a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents:
185
diff
changeset
|
672 return offset > 0; |
178 | 673 } |
674 | |
675 | |
676 #endif | |
677 /* HAVE_EXIV2 */ |