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