]> git.pld-linux.org Git - packages/gthumb.git/blame - exiv2-0.28.patch
upstream support for exiv2 >= 0.28; rel 5
[packages/gthumb.git] / exiv2-0.28.patch
CommitLineData
6b47f402
JP
1From 3376550ae109286de09ce5f89e05060eb80230a7 Mon Sep 17 00:00:00 2001
2From: Paolo Bacchilega <paobac@src.gnome.org>
3Date: Tue, 27 Jun 2023 18:56:48 +0200
4Subject: [PATCH] exiv2: added support for version 0.28
5
6Patch by Alex and Antonio Rojas from the discussion of the issue 282.
7
8Fixes #282
9---
10 extensions/exiv2_tools/exiv2-utils.cpp | 141 +++++++++++++++++++++++++
11 1 file changed, 141 insertions(+)
12
13diff --git a/extensions/exiv2_tools/exiv2-utils.cpp b/extensions/exiv2_tools/exiv2-utils.cpp
14index 56dadb4eb..20f049c2a 100644
15--- a/extensions/exiv2_tools/exiv2-utils.cpp
16+++ b/extensions/exiv2_tools/exiv2-utils.cpp
17@@ -740,7 +740,11 @@ get_exif_default_category (const Exiv2::Exifdatum &md)
18
19
20 static void
21+#if EXIV2_TEST_VERSION(0,28,0)
22+exiv2_read_metadata (Exiv2::Image::UniquePtr image,
23+#else
24 exiv2_read_metadata (Exiv2::Image::AutoPtr image,
25+#endif
26 GFileInfo *info,
27 gboolean update_general_attributes)
28 {
29@@ -875,7 +879,11 @@ exiv2_read_metadata_from_file (GFile *file,
30 return FALSE;
31 }
32
33+#if EXIV2_TEST_VERSION(0,28,0)
34+ Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path);
35+#else
36 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path);
37+#endif
38 g_free (path);
39
40 if (image.get() == 0) {
41@@ -885,9 +893,17 @@ exiv2_read_metadata_from_file (GFile *file,
42 }
43 // Set the log level to only show errors (and suppress warnings, informational and debug messages)
44 Exiv2::LogMsg::setLevel(Exiv2::LogMsg::error);
45+#if EXIV2_TEST_VERSION(0,28,0)
46+ exiv2_read_metadata (std::move(image), info, update_general_attributes);
47+#else
48 exiv2_read_metadata (image, info, update_general_attributes);
49+#endif
50 }
51+#if EXIV2_TEST_VERSION(0,28,0)
52+ catch (Exiv2::Error& e) {
53+#else
54 catch (Exiv2::AnyError& e) {
55+#endif
56 if (error != NULL)
57 *error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, e.what());
58 return FALSE;
59@@ -906,7 +922,11 @@ exiv2_read_metadata_from_buffer (void *buffer,
60 GError **error)
61 {
62 try {
63+#if EXIV2_TEST_VERSION(0,28,0)
64+ Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) buffer, buffer_size);
65+#else
66 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) buffer, buffer_size);
67+#endif
68
69 if (image.get() == 0) {
70 if (error != NULL)
71@@ -914,9 +934,17 @@ exiv2_read_metadata_from_buffer (void *buffer,
72 return FALSE;
73 }
74
75+#if EXIV2_TEST_VERSION(0,28,0)
76+ exiv2_read_metadata (std::move(image), info, update_general_attributes);
77+#else
78 exiv2_read_metadata (image, info, update_general_attributes);
79+#endif
80 }
81+#if EXIV2_TEST_VERSION(0,28,0)
82+ catch (Exiv2::Error& e) {
83+#else
84 catch (Exiv2::AnyError& e) {
85+#endif
86 if (error != NULL)
87 *error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, e.what());
88 return FALSE;
89@@ -965,7 +993,11 @@ exiv2_read_sidecar (GFile *file,
90 g_free (path);
91
92 std::string xmpPacket;
93+#if EXIV2_TEST_VERSION(0,28,0)
94+ xmpPacket.assign(reinterpret_cast<char*>(buf.data()), buf.size());
95+#else
96 xmpPacket.assign(reinterpret_cast<char*>(buf.pData_), buf.size_);
97+#endif
98 Exiv2::XmpData xmpData;
99
100 if (0 != Exiv2::XmpParser::decode(xmpData, xmpPacket))
101@@ -1011,7 +1043,11 @@ exiv2_read_sidecar (GFile *file,
102
103 set_attributes_from_tagsets (info, update_general_attributes);
104 }
105+#if EXIV2_TEST_VERSION(0,28,0)
106+ catch (Exiv2::Error& e) {
107+#else
108 catch (Exiv2::AnyError& e) {
109+#endif
110 std::cerr << "Caught Exiv2 exception '" << e << "'\n";
111 return FALSE;
112 }
113@@ -1111,7 +1147,11 @@ dump_exif_data (Exiv2::ExifData &exifData,
114
115
116 static Exiv2::DataBuf
117+#if EXIV2_TEST_VERSION(0,28,0)
118+exiv2_write_metadata_private (Exiv2::Image::UniquePtr image,
119+#else
120 exiv2_write_metadata_private (Exiv2::Image::AutoPtr image,
121+#endif
122 GFileInfo *info,
123 GthImage *image_data)
124 {
125@@ -1148,13 +1188,21 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr image,
126 const char *value_type = gth_main_get_metadata_type (metadatum, attributes[i]);
127
128 if ((raw_value != NULL) && (strcmp (raw_value, "") != 0) && (value_type != NULL)) {
129+#if EXIV2_TEST_VERSION(0,28,0)
130+ Exiv2::Value::UniquePtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
131+#else
132 Exiv2::Value::AutoPtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
133+#endif
134 value->read (raw_value);
135 Exiv2::ExifKey exif_key(key);
136 ed.add (exif_key, value.get());
137 }
138 }
139+#if EXIV2_TEST_VERSION(0,28,0)
140+ catch (Exiv2::Error& e) {
141+#else
142 catch (Exiv2::AnyError& e) {
143+#endif
144 /* we don't care about invalid key errors */
145 g_warning ("%s", e.what());
146 }
147@@ -1270,7 +1318,11 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr image,
148 value_type = gth_main_get_metadata_type (metadatum, attributes[i]);
149 if (value_type != NULL) {
150 /* See the exif data code above for an explanation. */
151+#if EXIV2_TEST_VERSION(0,28,0)
152+ Exiv2::Value::UniquePtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
153+#else
154 Exiv2::Value::AutoPtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
155+#endif
156 Exiv2::IptcKey iptc_key(key);
157
158 const char *raw_value;
159@@ -1296,7 +1348,11 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr image,
160 }
161 }
162 }
163+#if EXIV2_TEST_VERSION(0,28,0)
164+ catch (Exiv2::Error& e) {
165+#else
166 catch (Exiv2::AnyError& e) {
167+#endif
168 /* we don't care about invalid key errors */
169 g_warning ("%s", e.what());
170 }
171@@ -1320,7 +1376,11 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr image,
172 value_type = gth_main_get_metadata_type (metadatum, attributes[i]);
173 if (value_type != NULL) {
174 /* See the exif data code above for an explanation. */
175+#if EXIV2_TEST_VERSION(0,28,0)
176+ Exiv2::Value::UniquePtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
177+#else
178 Exiv2::Value::AutoPtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
179+#endif
180 Exiv2::XmpKey xmp_key(key);
181
182 const char *raw_value;
183@@ -1346,7 +1406,11 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr image,
184 }
185 }
186 }
187+#if EXIV2_TEST_VERSION(0,28,0)
188+ catch (Exiv2::Error& e) {
189+#else
190 catch (Exiv2::AnyError& e) {
191+#endif
192 /* we don't care about invalid key errors */
193 g_warning ("%s", e.what());
194 }
195@@ -1362,7 +1426,11 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr image,
196 image->setXmpData(xd);
197 image->writeMetadata();
198 }
199+#if EXIV2_TEST_VERSION(0,28,0)
200+ catch (Exiv2::Error& e) {
201+#else
202 catch (Exiv2::AnyError& e) {
203+#endif
204 g_warning ("%s", e.what());
205 }
206
207@@ -1389,16 +1457,33 @@ exiv2_write_metadata (GthImageSaveData *data)
208 {
209 if (exiv2_supports_writes (data->mime_type) && (data->file_data != NULL)) {
210 try {
211+#if EXIV2_TEST_VERSION(0,28,0)
212+ Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) data->buffer, data->buffer_size);
213+#else
214 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) data->buffer, data->buffer_size);
215+#endif
216 g_assert (image.get() != 0);
217
218+#if EXIV2_TEST_VERSION(0,28,0)
219+ Exiv2::DataBuf buf = exiv2_write_metadata_private (std::move(image), data->file_data->info, data->image);
220+#else
221 Exiv2::DataBuf buf = exiv2_write_metadata_private (image, data->file_data->info, data->image);
222+#endif
223
224 g_free (data->buffer);
225+#if EXIV2_TEST_VERSION(0,28,0)
226+ data->buffer = g_memdup (buf.data(), buf.size());
227+ data->buffer_size = buf.size();
228+#else
229 data->buffer = g_memdup (buf.pData_, buf.size_);
230 data->buffer_size = buf.size_;
231+#endif
232 }
233+#if EXIV2_TEST_VERSION(0,28,0)
234+ catch (Exiv2::Error& e) {
235+#else
236 catch (Exiv2::AnyError& e) {
237+#endif
238 if (data->error != NULL)
239 *data->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, e.what());
240 g_warning ("%s\n", e.what());
241@@ -1419,16 +1504,33 @@ exiv2_write_metadata_to_buffer (void **buffer,
242 GError **error)
243 {
244 try {
245+#if EXIV2_TEST_VERSION(0,28,0)
246+ Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) *buffer, *buffer_size);
247+#else
248 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) *buffer, *buffer_size);
249+#endif
250 g_assert (image.get() != 0);
251
252+#if EXIV2_TEST_VERSION(0,28,0)
253+ Exiv2::DataBuf buf = exiv2_write_metadata_private (std::move(image), info, image_data);
254+#else
255 Exiv2::DataBuf buf = exiv2_write_metadata_private (image, info, image_data);
256+#endif
257
258 g_free (*buffer);
259+#if EXIV2_TEST_VERSION(0,28,0)
260+ *buffer = g_memdup (buf.data(), buf.size());
261+ *buffer_size = buf.size();
262+#else
263 *buffer = g_memdup (buf.pData_, buf.size_);
264 *buffer_size = buf.size_;
265+#endif
266 }
267+#if EXIV2_TEST_VERSION(0,28,0)
268+ catch (Exiv2::Error& e) {
269+#else
270 catch (Exiv2::AnyError& e) {
271+#endif
272 if (error != NULL)
273 *error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, e.what());
274 return FALSE;
275@@ -1445,7 +1547,11 @@ exiv2_clear_metadata (void **buffer,
276 GError **error)
277 {
278 try {
279+#if EXIV2_TEST_VERSION(0,28,0)
280+ Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) *buffer, *buffer_size);
281+#else
282 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) *buffer, *buffer_size);
283+#endif
284
285 if (image.get() == 0) {
286 if (error != NULL)
287@@ -1457,7 +1563,11 @@ exiv2_clear_metadata (void **buffer,
288 image->clearMetadata();
289 image->writeMetadata();
290 }
291+#if EXIV2_TEST_VERSION(0,28,0)
292+ catch (Exiv2::Error& e) {
293+#else
294 catch (Exiv2::AnyError& e) {
295+#endif
296 g_warning ("%s", e.what());
297 }
298
299@@ -1466,10 +1576,19 @@ exiv2_clear_metadata (void **buffer,
300 Exiv2::DataBuf buf = io.read(io.size());
301
302 g_free (*buffer);
303+#if EXIV2_TEST_VERSION(0,28,0)
304+ *buffer = g_memdup (buf.data(), buf.size());
305+ *buffer_size = buf.size();
306+#else
307 *buffer = g_memdup (buf.pData_, buf.size_);
308 *buffer_size = buf.size_;
309+#endif
310 }
311+#if EXIV2_TEST_VERSION(0,28,0)
312+ catch (Exiv2::Error& e) {
313+#else
314 catch (Exiv2::AnyError& e) {
315+#endif
316 if (error != NULL)
317 *error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, e.what());
318 return FALSE;
319@@ -1502,26 +1621,44 @@ exiv2_generate_thumbnail (const char *uri,
320 if (path == NULL)
321 return NULL;
322
323+#if EXIV2_TEST_VERSION(0,28,0)
324+ Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open (path);
325+#else
326 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open (path);
327+#endif
328 image->readMetadata ();
329 Exiv2::ExifThumbC exifThumb (image->exifData ());
330 Exiv2::DataBuf thumb = exifThumb.copy ();
331
332 g_free (path);
333
334+#if EXIV2_TEST_VERSION(0,28,0)
335+ if (thumb.data() == NULL)
336+#else
337 if (thumb.pData_ == NULL)
338+#endif
339 return NULL;
340
341 Exiv2::ExifData &ed = image->exifData();
342
343+#if EXIV2_TEST_VERSION(0,28,0)
344+ long orientation = (ed["Exif.Image.Orientation"].count() > 0) ? ed["Exif.Image.Orientation"].toUint32() : 1;
345+ long image_width = (ed["Exif.Photo.PixelXDimension"].count() > 0) ? ed["Exif.Photo.PixelXDimension"].toUint32() : -1;
346+ long image_height = (ed["Exif.Photo.PixelYDimension"].count() > 0) ? ed["Exif.Photo.PixelYDimension"].toUint32() : -1;
347+#else
348 long orientation = (ed["Exif.Image.Orientation"].count() > 0) ? ed["Exif.Image.Orientation"].toLong() : 1;
349 long image_width = (ed["Exif.Photo.PixelXDimension"].count() > 0) ? ed["Exif.Photo.PixelXDimension"].toLong() : -1;
350 long image_height = (ed["Exif.Photo.PixelYDimension"].count() > 0) ? ed["Exif.Photo.PixelYDimension"].toLong() : -1;
351+#endif
352
353 if ((orientation != 1) || (image_width <= 0) || (image_height <= 0))
354 return NULL;
355
356+#if EXIV2_TEST_VERSION(0,28,0)
357+ GInputStream *stream = g_memory_input_stream_new_from_data (thumb.data(), thumb.size(), NULL);
358+#else
359 GInputStream *stream = g_memory_input_stream_new_from_data (thumb.pData_, thumb.size_, NULL);
360+#endif
361 pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
362 g_object_unref (stream);
363
364@@ -1575,7 +1712,11 @@ exiv2_generate_thumbnail (const char *uri,
365 gdk_pixbuf_set_option (pixbuf, "orientation", orientation_s);
366 g_free (orientation_s);
367 }
368+#if EXIV2_TEST_VERSION(0,28,0)
369+ catch (Exiv2::Error& e) {
370+#else
371 catch (Exiv2::AnyError& e) {
372+#endif
373 }
374
375 return pixbuf;
376--
377GitLab
378
This page took 0.12982 seconds and 4 git commands to generate.