annotate src/exiv2.cc @ 186:bd3fc1aa7fe9

a hack to read raw previews with exiv2 0.16, however it should be fixed in the library
author nadvornik
date Sun, 24 Feb 2008 18:55:19 +0000
parents 354da67a7ca2
children 9eafc4957f1a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
1
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
2 #ifdef HAVE_CONFIG_H
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
3 # include "config.h"
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
4 #endif
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
5
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
6 #ifdef HAVE_EXIV2
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
7
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
8 #include <exiv2/image.hpp>
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
9 #include <exiv2/exif.hpp>
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
10 #include <iostream>
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
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
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
29 extern "C" {
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
30 #include <glib.h>
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
31 #include "exif.h"
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
32
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
33 }
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
34
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
35 struct _ExifData
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
36 {
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
37 Exiv2::ExifData exifData;
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
38 Exiv2::ExifData::const_iterator exifIter; /* for exif_get_next_item */
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
39 Exiv2::IptcData iptcData;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
40 Exiv2::IptcData::const_iterator iptcIter; /* for exif_get_next_item */
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
41 Exiv2::XmpData xmpData;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
42 Exiv2::XmpData::const_iterator xmpIter; /* for exif_get_next_item */
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
43
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
44 _ExifData(gchar *path, gint parse_color_profile)
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
45 {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
46 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path);
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
47 g_assert (image.get() != 0);
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
48 image->readMetadata();
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
49 exifData = image->exifData();
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
50 iptcData = image->iptcData();
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
51 xmpData = image->xmpData();
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
52 }
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
53
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
54 };
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
55
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
56 extern "C" {
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
57
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
58 ExifData *exif_read(gchar *path, gint parse_color_profile)
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
59 {
182
8a417f10ba09 more exiv2 fixes
nadvornik
parents: 180
diff changeset
60 printf("exif %s\n", path);
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
61 try {
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
62 return new ExifData(path, parse_color_profile);
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
63 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
64 catch (Exiv2::AnyError& e) {
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
65 std::cout << "Caught Exiv2 exception '" << e << "'\n";
179
37004d5a584a and first version that actually shows some exif data (see advanced view)
nadvornik
parents: 178
diff changeset
66 return 0;
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
67 }
179
37004d5a584a and first version that actually shows some exif data (see advanced view)
nadvornik
parents: 178
diff changeset
68
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
69 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
70
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
71 void exif_free(ExifData *exif)
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
72 {
182
8a417f10ba09 more exiv2 fixes
nadvornik
parents: 180
diff changeset
73
8a417f10ba09 more exiv2 fixes
nadvornik
parents: 180
diff changeset
74 delete exif;
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
75 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
76
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
77 ExifItem *exif_get_item(ExifData *exif, const gchar *key)
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
78 {
183
3962c9d3d6fd more exiv2 fixes
nadvornik
parents: 182
diff changeset
79 try {
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
80 Exiv2::Metadatum *item;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
81 try {
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
82 Exiv2::ExifKey ekey(key);
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
83 Exiv2::ExifData::iterator pos = exif->exifData.findKey(ekey);
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
84 if (pos == exif->exifData.end()) return NULL;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
85 item = &*pos;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
86 }
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
87 catch (Exiv2::AnyError& e) {
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
88 try {
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
89 Exiv2::IptcKey ekey(key);
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
90 Exiv2::IptcData::iterator pos = exif->iptcData.findKey(ekey);
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
91 if (pos == exif->iptcData.end()) return NULL;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
92 item = &*pos;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
93 }
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
94 catch (Exiv2::AnyError& e) {
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
95 Exiv2::XmpKey ekey(key);
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
96 Exiv2::XmpData::iterator pos = exif->xmpData.findKey(ekey);
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
97 if (pos == exif->xmpData.end()) return NULL;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
98 item = &*pos;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
99 }
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
100 }
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
101 return (ExifItem *)item;
183
3962c9d3d6fd more exiv2 fixes
nadvornik
parents: 182
diff changeset
102 }
3962c9d3d6fd more exiv2 fixes
nadvornik
parents: 182
diff changeset
103 catch (Exiv2::AnyError& e) {
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
104 std::cout << "Caught Exiv2 exception '" << e << "'\n";
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
105 return NULL;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
106 }
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
107 }
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
108
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
109
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
110 ExifItem *exif_get_first_item(ExifData *exif)
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
111 {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
112 try {
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
113 exif->exifIter = exif->exifData.begin();
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
114 exif->iptcIter = exif->iptcData.begin();
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
115 exif->xmpIter = exif->xmpData.begin();
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
116 if (exif->exifIter != exif->exifData.end())
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
117 {
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
118 const Exiv2::Metadatum *item = &*exif->exifIter;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
119 exif->exifIter++;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
120 return (ExifItem *)item;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
121 }
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
122 if (exif->iptcIter != exif->iptcData.end())
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
123 {
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
124 const Exiv2::Metadatum *item = &*exif->iptcIter;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
125 exif->iptcIter++;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
126 return (ExifItem *)item;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
127 }
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
128 if (exif->xmpIter != exif->xmpData.end())
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
129 {
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
130 const Exiv2::Metadatum *item = &*exif->xmpIter;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
131 exif->xmpIter++;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
132 return (ExifItem *)item;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
133 }
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
134 return NULL;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
135
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
136 }
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
137 catch (Exiv2::AnyError& e) {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
138 std::cout << "Caught Exiv2 exception '" << e << "'\n";
183
3962c9d3d6fd more exiv2 fixes
nadvornik
parents: 182
diff changeset
139 return NULL;
3962c9d3d6fd more exiv2 fixes
nadvornik
parents: 182
diff changeset
140 }
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
141 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
142
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
143 ExifItem *exif_get_next_item(ExifData *exif)
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
144 {
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
145 try {
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
146 if (exif->exifIter != exif->exifData.end())
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
147 {
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
148 const Exiv2::Metadatum *item = &*exif->exifIter;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
149 exif->exifIter++;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
150 return (ExifItem *)item;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
151 }
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
152 if (exif->iptcIter != exif->iptcData.end())
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
153 {
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
154 const Exiv2::Metadatum *item = &*exif->iptcIter;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
155 exif->iptcIter++;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
156 return (ExifItem *)item;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
157 }
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
158 if (exif->xmpIter != exif->xmpData.end())
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
159 {
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
160 const Exiv2::Metadatum *item = &*exif->xmpIter;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
161 exif->xmpIter++;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
162 return (ExifItem *)item;
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
163 }
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
164 return NULL;
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
165 }
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
166 catch (Exiv2::AnyError& e) {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
167 std::cout << "Caught Exiv2 exception '" << e << "'\n";
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
168 return NULL;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
169 }
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
170 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
171
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
172 char *exif_item_get_tag_name(ExifItem *item)
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
173 {
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
174 try {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
175 if (!item) return NULL;
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
176 return g_strdup(((Exiv2::Metadatum *)item)->key().c_str());
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
177 }
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
178 catch (Exiv2::AnyError& e) {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
179 std::cout << "Caught Exiv2 exception '" << e << "'\n";
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
180 return NULL;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
181 }
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
182 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
183
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
184 guint exif_item_get_tag_id(ExifItem *item)
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
185 {
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
186 try {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
187 if (!item) return 0;
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
188 return ((Exiv2::Metadatum *)item)->tag();
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
189 }
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
190 catch (Exiv2::AnyError& e) {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
191 std::cout << "Caught Exiv2 exception '" << e << "'\n";
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
192 return 0;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
193 }
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
194 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
195
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
196 guint exif_item_get_elements(ExifItem *item)
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
197 {
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
198 try {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
199 if (!item) return 0;
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
200 return ((Exiv2::Metadatum *)item)->count();
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
201 }
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
202 catch (Exiv2::AnyError& e) {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
203 std::cout << "Caught Exiv2 exception '" << e << "'\n";
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
204 return 0;
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
205 }
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
206 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
207
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
208 char *exif_item_get_data(ExifItem *item, guint *data_len)
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
209 {
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
210 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
211
182
8a417f10ba09 more exiv2 fixes
nadvornik
parents: 180
diff changeset
212 char *exif_item_get_description(ExifItem *item)
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
213 {
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
214 try {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
215 if (!item) return NULL;
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
216 return g_strdup(((Exiv2::Metadatum *)item)->tagLabel().c_str());
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
217 }
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
218 catch (std::exception& e) {
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
219 // std::cout << "Caught Exiv2 exception '" << e << "'\n";
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
220 return NULL;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
221 }
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
222 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
223
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
224 /*
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
225 invalidTypeId, unsignedByte, asciiString, unsignedShort,
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
226 unsignedLong, unsignedRational, signedByte, undefined,
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
227 signedShort, signedLong, signedRational, string,
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
228 date, time, comment, directory,
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
229 xmpText, xmpAlt, xmpBag, xmpSeq,
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
230 langAlt, lastTypeId
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
231 */
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
232
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
233 static guint format_id_trans_tbl [] = {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
234 EXIF_FORMAT_UNKNOWN,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
235 EXIF_FORMAT_BYTE_UNSIGNED,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
236 EXIF_FORMAT_STRING,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
237 EXIF_FORMAT_SHORT_UNSIGNED,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
238 EXIF_FORMAT_LONG_UNSIGNED,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
239 EXIF_FORMAT_RATIONAL_UNSIGNED,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
240 EXIF_FORMAT_BYTE,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
241 EXIF_FORMAT_UNDEFINED,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
242 EXIF_FORMAT_SHORT,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
243 EXIF_FORMAT_LONG,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
244 EXIF_FORMAT_RATIONAL,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
245 EXIF_FORMAT_STRING,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
246 EXIF_FORMAT_STRING,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
247 EXIF_FORMAT_STRING,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
248 EXIF_FORMAT_UNDEFINED,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
249 EXIF_FORMAT_STRING,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
250 EXIF_FORMAT_STRING,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
251 EXIF_FORMAT_STRING,
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
252 EXIF_FORMAT_STRING
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
253 };
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
254
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
255
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
256
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
257 guint exif_item_get_format_id(ExifItem *item)
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
258 {
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
259 try {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
260 if (!item) return EXIF_FORMAT_UNKNOWN;
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
261 guint id = ((Exiv2::Metadatum *)item)->typeId();
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
262 if (id >= (sizeof(format_id_trans_tbl) / sizeof(format_id_trans_tbl[0])) ) return EXIF_FORMAT_UNKNOWN;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
263 return format_id_trans_tbl[id];
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
264 }
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
265 catch (Exiv2::AnyError& e) {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
266 std::cout << "Caught Exiv2 exception '" << e << "'\n";
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
267 return EXIF_FORMAT_UNKNOWN;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
268 }
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
269 }
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
270
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
271 const char *exif_item_get_format_name(ExifItem *item, gint brief)
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
272 {
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
273 try {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
274 if (!item) return NULL;
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
275 return ((Exiv2::Metadatum *)item)->typeName();
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
276 }
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
277 catch (Exiv2::AnyError& e) {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
278 std::cout << "Caught Exiv2 exception '" << e << "'\n";
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
279 return NULL;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
280 }
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
281 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
282
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
283
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
284 gchar *exif_item_get_data_as_text(ExifItem *item)
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
285 {
183
3962c9d3d6fd more exiv2 fixes
nadvornik
parents: 182
diff changeset
286 try {
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
287 if (!item) return NULL;
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
288 // std::stringstream str; // does not work with Exiv2::Metadatum because operator<< is not virtual
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
289 // str << *((Exiv2::Metadatum *)item);
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
290 // return g_strdup(str.str().c_str());
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
291 return g_strdup(((Exiv2::Metadatum *)item)->toString().c_str());
183
3962c9d3d6fd more exiv2 fixes
nadvornik
parents: 182
diff changeset
292 }
3962c9d3d6fd more exiv2 fixes
nadvornik
parents: 182
diff changeset
293 catch (Exiv2::AnyError& e) {
3962c9d3d6fd more exiv2 fixes
nadvornik
parents: 182
diff changeset
294 return NULL;
3962c9d3d6fd more exiv2 fixes
nadvornik
parents: 182
diff changeset
295 }
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
296 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
297
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
298
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
299 gint exif_item_get_integer(ExifItem *item, gint *value)
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
300 {
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
301 try {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
302 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
303 *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
304 return 1;
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
305 }
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
306 catch (Exiv2::AnyError& e) {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
307 std::cout << "Caught Exiv2 exception '" << e << "'\n";
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
308 return 0;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
309 }
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
310 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
311
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
312 ExifRational *exif_item_get_rational(ExifItem *item, gint *sign)
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
313 {
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
314 try {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
315 if (!item) return NULL;
185
354da67a7ca2 read also iptc and xmp
nadvornik
parents: 184
diff changeset
316 Exiv2::Rational v = ((Exiv2::Metadatum *)item)->toRational();
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
317 static ExifRational ret;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
318 ret.num = v.first;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
319 ret.den = v.second;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
320 return &ret;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
321 }
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
322 catch (Exiv2::AnyError& e) {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
323 std::cout << "Caught Exiv2 exception '" << e << "'\n";
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
324 return NULL;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
325 }
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
326 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
327
182
8a417f10ba09 more exiv2 fixes
nadvornik
parents: 180
diff changeset
328 const gchar *exif_get_tag_description_by_key(const gchar *key)
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
329 {
184
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
330 try {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
331 Exiv2::ExifKey ekey(key);
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
332 return Exiv2::ExifTags::tagLabel(ekey.tag(), ekey.ifdId ());
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
333 }
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
334 catch (Exiv2::AnyError& e) {
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
335 std::cout << "Caught Exiv2 exception '" << e << "'\n";
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
336 return NULL;
2507418ab7a2 more exiv2 fixes
nadvornik
parents: 183
diff changeset
337 }
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
338 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
339
186
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
340
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
341 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
342
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
343 /* 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
344 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
345
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
346 class RawFile {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
347 public:
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
348
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
349 RawFile(int fd);
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
350 ~RawFile();
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
351
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
352 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
353
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
354 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
355
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
356 private:
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
357 int type;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
358 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
359 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
360 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
361 unsigned long offset;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
362 };
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
363
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
364 using namespace Exiv2;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
365
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
366 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
367 {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
368 struct stat st;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
369 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
370 {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
371 throw Error(14);
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
372 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
373 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
374 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
375 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
376 {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
377 throw Error(14);
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
378 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
379 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
380
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
381 TiffHeaderBase *tiffHeader;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
382 switch (type) {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
383 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
384 tiffHeader = new TiffHeade2();
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
385 break;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
386 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
387 tiffHeader = new Cr2Header();
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
388 break;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
389 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
390 tiffHeader = new OrfHeader();
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
391 break;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
392 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
393 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
394 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
395 return;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
396
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
397 default:
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
398 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
399 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
400
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
401 // 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
402 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
403
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
404 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
405
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
406 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
407 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
408 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
409 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
410 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
411
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
412 TiffRwState::AutoPtr state(
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
413 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
414
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
415 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
416 map_len,
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
417 rootDir.get(),
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
418 state);
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
419
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
420 rootDir->accept(reader);
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
421
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
422 delete tiffHeader;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
423 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
424
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
425 RawFile::~RawFile()
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
426 {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
427 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
428 {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
429 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
430 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
431 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
432
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
433 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
434 {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
435 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
436 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
437 rootDir->accept(finder);
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
438 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
439 if (te)
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
440 return te->pValue();
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
441 else
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
442 return NULL;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
443 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
444
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
445 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
446 {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
447 const Value *val;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
448 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
449
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
450 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
451 {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
452 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
453 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
454
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
455 return 0;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
456 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
457
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
458 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
459 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
460
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
461 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
462 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
463
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
464 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
465 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
466
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
467 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
468 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
469
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
470 return 0;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
471 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
472
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
473
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
474 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
475
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
476 extern "C" gint format_raw_img_exif_offsets_fd(int fd, const gchar *path,
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
477 unsigned char *header_data, const guint header_len,
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
478 guint *image_offset, guint *exif_offset)
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
479 {
186
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
480 int success;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
481 unsigned long offset;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
482
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
483 /* 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
484 /* if (path)
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 const gchar *ext;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
487 gint match = FALSE;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
488 gint i;
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 ext = strrchr(path, '.');
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
491 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
492
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
493 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
494 {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
495 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
496 {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
497 match = TRUE;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
498 break;
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 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
501
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
502 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
503
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
504 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
505 */
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
506 try {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
507 RawFile rf(fd);
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
508 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
509 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
510 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
511 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
512 return 0;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
513 }
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 if (image_offset)
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 *image_offset = offset;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
518 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
519 {
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
520 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
521
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
522 *image_offset = 0;
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
523 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
524 success = FALSE;
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 }
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
527
bd3fc1aa7fe9 a hack to read raw previews with exiv2 0.16, however it should be fixed
nadvornik
parents: 185
diff changeset
528 return offset > 0;
178
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
529 }
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
530
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
531
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
532 #endif
9dc8bc9b2bb9 first exiv2 support that does not crash immediately
nadvornik
parents:
diff changeset
533 /* HAVE_EXIV2 */