diff -Nru py3exiv2-0.6.1/debian/changelog py3exiv2-0.7.0/debian/changelog --- py3exiv2-0.6.1/debian/changelog 2019-04-14 10:21:14.000000000 +0000 +++ py3exiv2-0.7.0/debian/changelog 2019-04-14 10:21:14.000000000 +0000 @@ -1,3 +1,33 @@ +py3exiv2 (0.7.0-0ubuntu3) bionic; urgency=low + + * Update from upstream. + + -- Vincent Vande Vyvre Sun, 14 Apr 2019 12:18:35 +0200 + +py3exiv2 (0.7.0-0ubuntu2) xenial; urgency=low + + * Update from upstream. + + -- Vincent Vande Vyvre Sun, 14 Apr 2019 12:15:35 +0200 + +py3exiv2 (0.7.0-0ubuntu1) trusty; urgency=low + + * Update from upstream. + + -- Vincent Vande Vyvre Sat, 13 Apr 2019 11:09:22 +0200 + +py3exiv2 (0.6.1-0ubuntu6) disco; urgency=low + + * Update from upstream. + + -- Vincent Vande Vyvre Thu, 07 Feb 2019 15:56:57 +0100 + +py3exiv2 (0.6.1-0ubuntu5) cosmic; urgency=low + + * Update from upstream. + + -- Vincent Vande Vyvre Thu, 07 Feb 2019 14:56:57 +0100 + py3exiv2 (0.6.1-0ubuntu4) bionic; urgency=low * Update from upstream. diff -Nru py3exiv2-0.6.1/debian/control py3exiv2-0.7.0/debian/control --- py3exiv2-0.6.1/debian/control 2019-04-14 10:21:14.000000000 +0000 +++ py3exiv2-0.7.0/debian/control 2019-04-14 10:21:14.000000000 +0000 @@ -4,8 +4,8 @@ Maintainer: Vincent Vande Vyvre Uploaders: Vincent Vande Vyvre Build-Depends: debhelper (>= 7.0.50), - python3-all-dev (>= 3.2), - python3-all-dbg (>= 3.2), + python3-all-dev (>= 3.3), + python3-all-dbg (>= 3.3), libexiv2-dev (>= 0.20), libboost-python-dev (>= 1.54), g++ (>= 4.6) diff -Nru py3exiv2-0.6.1/NEWS py3exiv2-0.7.0/NEWS --- py3exiv2-0.6.1/NEWS 2019-02-07 06:49:08.000000000 +0000 +++ py3exiv2-0.7.0/NEWS 2019-04-13 09:04:07.000000000 +0000 @@ -1,3 +1,12 @@ +py3exiv2 0.7.0 - 2019-04-13 +--------------------------------------- + +- Add the initialiseXmpParser and closeXmpParser functions + +Contributors: + +- Vincent Vande Vyvre + py3exiv2 0.6.0 - 2019-02-07 --------------------------------------- diff -Nru py3exiv2-0.6.1/src/exiv2wrapper.cpp py3exiv2-0.7.0/src/exiv2wrapper.cpp --- py3exiv2-0.6.1/src/exiv2wrapper.cpp 2019-01-29 11:31:06.000000000 +0000 +++ py3exiv2-0.7.0/src/exiv2wrapper.cpp 2019-04-13 07:28:07.000000000 +0000 @@ -82,18 +82,11 @@ } } -#ifdef HAVE_EXIV2_ERROR_CODE catch (Exiv2::Error& err) { + //std::cout << " Caught Exiv2 exception '" << err.code() << "'\n"; error = err; } -#else - catch (Exiv2::Error& err) - { - std::cout << "Caught Exiv2 exception '" << err << "'\n"; - error = err; - } -#endif // Re-acquire the GIL Py_END_ALLOW_THREADS @@ -171,17 +164,12 @@ _xmpData = &_image->xmpData(); _dataRead = true; } -#ifdef HAVE_EXIV2_ERROR_CODE + catch (Exiv2::Error& err) { + //std::cout << " Caught Exiv2 exception '" << err.code() << "'\n"; error = err; } -#else - catch (Exiv2::Error& err) - { - error = err; - } -#endif // Re-acquire the GIL Py_END_ALLOW_THREADS @@ -212,17 +200,12 @@ { _image->writeMetadata(); } -#ifdef HAVE_EXIV2_ERROR_CODE + catch (Exiv2::Error& err) { + //std::cout << "Caught Exiv2 exception '" << err.code() << "'\n"; error = err; } -#else - catch (Exiv2::Error& err) - { - error = err; - } -#endif // Re-acquire the GIL Py_END_ALLOW_THREADS @@ -515,7 +498,7 @@ // Copy the data buffer in a string. Since the data buffer can contain null // characters ('\x00'), the string cannot be simply constructed like that: - // _data = std::string((char*) previewImage.pData()); + // buffer = std::string((char*) previewImage.pData()); // because it would be truncated after the first occurence of a null // character. Therefore, it has to be copied character by character. // First allocate the memory for the whole string... @@ -589,7 +572,6 @@ return data; } - void Image::eraseExifThumbnail() { _getExifThumbnail()->erase(); @@ -1191,6 +1173,7 @@ _size = previewImage.size(); _dimensions = boost::python::make_tuple(previewImage.width(), previewImage.height()); + // Copy the data buffer in a string. Since the data buffer can contain null // characters ('\x00'), the string cannot be simply constructed like that: // _data = std::string((char*) previewImage.pData()); @@ -1206,6 +1189,13 @@ } } +boost::python::object Preview::getData() const +{ + return boost::python::object(boost::python::handle<>( + PyBytes_FromStringAndSize(_data.c_str(), _size) + )); +} + void Preview::writeToFile(const std::string& path) const { std::string filename = path + _extension; @@ -1219,10 +1209,7 @@ { // Use the Python 'C' API to set up an exception object const char* message = error.what(); - int code = error.code(); - printf("%s: %d\n", message, code); - //int code = error.code(); - //message += (char *) code; + // The type of the Python exception depends on the error code // Warning: this piece of code should be updated in case the error codes // defined by Exiv2 (file 'src/error.cpp') are changed @@ -1848,6 +1835,42 @@ } #endif +bool initialiseXmpParser() +{ + if (!Exiv2::XmpParser::initialize()) + return false; + + std::string prefix("py3exiv2"); + std::string name("www.py3exiv2.tuxfamily.org/"); + + try + { + const std::string& ns = Exiv2::XmpProperties::ns(prefix); + } + + catch (Exiv2::Error& error) + { + // No namespace exists with the requested prefix, it is safe to + // register a new one. + Exiv2::XmpProperties::registerNs(name, prefix); + } + + return true; +} + +bool closeXmpParser() +{ + std::string name("www.py3exiv2.tuxfamily.org/"); + const std::string& prefix = Exiv2::XmpProperties::prefix(name); + if (prefix != "") + { + Exiv2::XmpProperties::unregisterNs(name); + } + + Exiv2::XmpParser::terminate(); + + return true; +} void registerXmpNs(const std::string& name, const std::string& prefix) { diff -Nru py3exiv2-0.6.1/src/exiv2wrapper.hpp py3exiv2-0.7.0/src/exiv2wrapper.hpp --- py3exiv2-0.6.1/src/exiv2wrapper.hpp 2019-02-05 08:40:42.000000000 +0000 +++ py3exiv2-0.7.0/src/exiv2wrapper.hpp 2019-04-12 06:38:56.000000000 +0000 @@ -285,6 +285,8 @@ // Functions to manipulate custom XMP namespaces +bool initialiseXmpParser(); +bool closeXmpParser(); void registerXmpNs(const std::string& name, const std::string& prefix); void unregisterXmpNs(const std::string& name); void unregisterAllXmpNs(); diff -Nru py3exiv2-0.6.1/src/exiv2wrapper_python.cpp py3exiv2-0.7.0/src/exiv2wrapper_python.cpp --- py3exiv2-0.6.1/src/exiv2wrapper_python.cpp 2019-02-05 08:42:27.000000000 +0000 +++ py3exiv2-0.7.0/src/exiv2wrapper_python.cpp 2019-04-12 06:39:47.000000000 +0000 @@ -157,6 +157,8 @@ .def("_getIptcCharset", &Image::getIptcCharset) ; + def("_initialiseXmpParser", initialiseXmpParser); + def("_closeXmpParser", closeXmpParser); def("_registerXmpNs", registerXmpNs, args("name", "prefix")); def("_unregisterXmpNs", unregisterXmpNs, args("name")); def("_unregisterAllXmpNs", unregisterAllXmpNs); diff -Nru py3exiv2-0.6.1/src/pyexiv2/__init__.py py3exiv2-0.7.0/src/pyexiv2/__init__.py --- py3exiv2-0.6.1/src/pyexiv2/__init__.py 2019-01-30 07:40:24.000000000 +0000 +++ py3exiv2-0.7.0/src/pyexiv2/__init__.py 2019-04-13 07:23:31.000000000 +0000 @@ -75,7 +75,7 @@ #: A tuple containing the three components of the version number: major, minor, micro. -version_info = (0, 5, 0) +version_info = (0, 7, 0) #: The version of the module as a string (major.minor.micro). __version__ = _make_version(version_info) diff -Nru py3exiv2-0.6.1/src/pyexiv2/xmp.py py3exiv2-0.7.0/src/pyexiv2/xmp.py --- py3exiv2-0.6.1/src/pyexiv2/xmp.py 2019-01-30 07:43:19.000000000 +0000 +++ py3exiv2-0.7.0/src/pyexiv2/xmp.py 2019-04-12 17:24:18.000000000 +0000 @@ -522,6 +522,33 @@ self._tag = libexiv2python._XmpTag(key) self.raw_value = raw_value +def initialiseXmpParser(): + """Initialise the xmp parser. + + Calling this method is usually not needed, as encode() and decode() will + initialize the XMP Toolkit if necessary. + + The function takes optional pointers to a callback function xmpLockFct and + related data pLockData that the parser uses when XMP namespaces are + subsequently registered. + + This function itself still is not thread-safe and needs to be + called in a thread-safe manner (e.g., on program startup), but if used with + suitable additional locking parameters, any subsequent registration of + namespaces will be thread-safe. + """ + libexiv2python._initialiseXmpParser() + +def closeXmpParser(): + """Close the xmp parser. + + Terminate the XMP Toolkit and unregister custom namespaces. + + Call this method when the XmpParser is no longer needed to allow the XMP + Toolkit to cleanly shutdown. + """ + libexiv2python._closeXmpParser() + def register_namespace(name, prefix): """Register a custom XMP namespace.