[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:39:16 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=1503192
The following commit has been merged in the master branch:
commit 1503192f131af51ca3591fee02fcc47ef54f52bf
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Mon Mar 17 15:45:27 2008 +0000
First draft conversion code.
---
samples/Makefile | 1 +
samples/convert-test.cpp | 37 ++++++++
src/Makefile | 1 +
src/convert.cpp | 235 +++++++++++++++++++++++++++++++++++++++++++++++
src/convert.hpp | 72 +++++++++++++++
5 files changed, 346 insertions(+)
diff --git a/samples/Makefile b/samples/Makefile
index b36b2c1..58c6a49 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -55,6 +55,7 @@ include $(top_srcdir)/config/config.mk
# Add source files of sample programs to this list
BINSRC = addmoddel.cpp \
+ convert-test.cpp \
crwedit.cpp \
crwparse.cpp \
dataarea-test.cpp \
diff --git a/samples/convert-test.cpp b/samples/convert-test.cpp
new file mode 100644
index 0000000..7514306
--- /dev/null
+++ b/samples/convert-test.cpp
@@ -0,0 +1,37 @@
+// ***************************************************************** -*- C++ -*-
+// convert-test.cpp, $Rev$
+// Conversion test driver - make sure you have a copy of the input file around!
+
+#include <exiv2/image.hpp>
+#include <exiv2/convert.hpp>
+#include <iostream>
+#include <iomanip>
+#include <cassert>
+
+int main(int argc, char* const argv[])
+try {
+ if (argc != 2) {
+ std::cout << "Usage: " << argv[0] << " file
";
+ return 1;
+ }
+
+ Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(argv[1]);
+ assert(image.get() != 0);
+ image->readMetadata();
+
+ Exiv2::XmpData xmpData;
+ Exiv2::copyExifToXmp(image->exifData(), xmpData);
+
+ Exiv2::ExifData exifData;
+ Exiv2::copyXmpToExif(xmpData, exifData);
+
+ image->setXmpData(xmpData);
+ image->setExifData(exifData);
+ image->writeMetadata();
+
+ return 0;
+}
+catch (Exiv2::AnyError& e) {
+ std::cout << "Caught Exiv2 exception '" << e << "'
";
+ return -1;
+}
diff --git a/src/Makefile b/src/Makefile
index 68370e6..fa6d928 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -69,6 +69,7 @@ CCHDR = exv_conf.h \
# Add library C++ source files to this list
CCSRC = basicio.cpp \
canonmn.cpp \
+ convert.cpp \
cr2image.cpp \
crwimage.cpp \
datasets.cpp \
diff --git a/src/convert.cpp b/src/convert.cpp
new file mode 100644
index 0000000..1d6ab50
--- /dev/null
+++ b/src/convert.cpp
@@ -0,0 +1,235 @@
+// ***************************************************************** -*- C++ -*-
+/*
+ * Copyright (C) 2004-2008 Andreas Huggel <ahuggel at gmx.net>
+ *
+ * This program is part of the Exiv2 distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
+ */
+/*
+ File: convert.cpp
+ Version: $Rev$
+ Author(s): Andreas Huggel (ahu) <ahuggel at gmx.net>
+ History: 17-Mar-07, ahu: created
+ */
+// *****************************************************************************
+#include "rcsid.hpp"
+EXIV2_RCSID("@(#) $Id$")
+
+// *****************************************************************************
+// included header files
+#include "types.hpp"
+#include "exif.hpp"
+#include "iptc.hpp"
+#include "xmp.hpp"
+#include "convert.hpp"
+
+// + standard includes
+
+// *****************************************************************************
+namespace {
+
+}
+
+// *****************************************************************************
+// class member definitions
+namespace Exiv2 {
+
+ //! Metadata conversions.
+ class Converter {
+ public:
+ /*!
+ @brief Type for metadata converter functions, taking two key strings,
+ \em from and \em to.
+
+ These functions have access to both the source and destination metadata
+ containers and store the result directly in the destination container.
+ */
+ typedef void (Converter::*ConvertFct)(const char* from, const char* to);
+ //! Structure to define conversions between two keys.
+ struct Conversion {
+ MetadataId metadataId; //!< Type of metadata for the first key.
+ const char* key1; //!< First metadata key.
+ const char* key2; //!< Second metadata key (always an XMP key for now).
+ ConvertFct key1ToKey2; //!< Conversion from first to second key.
+ ConvertFct key2ToKey1; //!< Conversion from second to first key.
+ };
+ public:
+ //! @name Creators
+ //@{
+ //! Constructor for Exif tags and XMP properties.
+ Converter(ExifData& exifData, XmpData& xmpData);
+ //@}
+ //! @name Manipulators
+ //@{
+ //! Convert Exif tags to XMP properties according to the conversion table.
+ void cnvExifToXmp();
+ //! Convert XMP properties to Exif tags according to the conversion table.
+ void cnvXmpToExif();
+ /*!
+ @brief Set the erase flag.
+
+ This flag indicates whether successfully converted source records are erased.
+ */
+ void setErase(bool onoff =true) { erase_ = onoff; }
+ //@}
+ //! @name Conversion functions (manipulators)
+ //@{
+ /*!
+ @brief Simple Exif to XMP conversion function.
+
+ Sets the XMP property to an XmpText value containing the Exif value string.
+ */
+ void cnvExifValue(const char* from, const char* to);
+ /*!
+ @brief Simple XMP to Exif conversion function.
+
+ Sets the Exif tag according to the XMP property.
+ */
+ void cnvXmpValue(const char* from, const char* to);
+ //@}
+ //! @name Accessors
+ //@{
+ //! Get the value of the erase flag, see also setErase(bool on).
+ bool erase() const { return erase_; }
+ //@}
+ private:
+ // DATA
+ static const Conversion conversion_[]; //<! Conversion rules
+ bool erase_;
+ ExifData& exifData_; // use pointers?
+ XmpData& xmpData_;
+
+ }; // class Converter
+
+ const Converter::Conversion Converter::conversion_[] = {
+ { mdExif, "Exif.Image.ImageWidth", "Xmp.tiff.ImageWidth", &Converter::cnvExifValue, &Converter::cnvXmpValue },
+ { mdExif, "Exif.Image.ImageLength", "Xmp.tiff.ImageLength", &Converter::cnvExifValue, &Converter::cnvXmpValue },
+ { mdExif, "Exif.Image.BitsPerSample", "Xmp.tiff.BitsPerSample", &Converter::cnvExifValue, &Converter::cnvXmpValue },
+ { mdExif, "Exif.Image.Compression", "Xmp.tiff.Compression", &Converter::cnvExifValue, &Converter::cnvXmpValue }
+ // ...
+ };
+
+ Converter::Converter(ExifData& exifData, XmpData& xmpData)
+ : erase_(false), exifData_(exifData), xmpData_(xmpData)
+ {
+ }
+
+ void Converter::cnvExifToXmp()
+ {
+ for (unsigned int i = 0; i < EXV_COUNTOF(conversion_); ++i) {
+ const Conversion& c = conversion_[i];
+ if (c.metadataId == mdExif) {
+ EXV_CALL_MEMBER_FN(*this, c.key1ToKey2)(c.key1, c.key2);
+ }
+ }
+ }
+
+ void Converter::cnvXmpToExif()
+ {
+ for (unsigned int i = 0; i < EXV_COUNTOF(conversion_); ++i) {
+ const Conversion& c = conversion_[i];
+ if (c.metadataId == mdExif) {
+ EXV_CALL_MEMBER_FN(*this, c.key2ToKey1)(c.key2, c.key1);
+ }
+ }
+ }
+
+ void Converter::cnvExifValue(const char* from, const char* to)
+ {
+ Exiv2::ExifData::iterator pos = exifData_.findKey(ExifKey(from));
+ if (pos == exifData_.end()) return;
+ std::string value = pos->value().toString();
+ if (!pos->value().ok()) {
+#ifndef SUPPRESS_WARNINGS
+ std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+#endif
+ return;
+ }
+ xmpData_[to] = value;
+ if (erase_) exifData_.erase(pos);
+ }
+
+ void Converter::cnvXmpValue(const char* from, const char* to)
+ {
+ Exiv2::XmpData::iterator pos = xmpData_.findKey(XmpKey(from));
+ if (pos == xmpData_.end()) return;
+ std::string value = pos->value().toString();
+ if (!pos->value().ok()) {
+#ifndef SUPPRESS_WARNINGS
+ std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+#endif
+ return;
+ }
+ exifData_[to] = value;
+ if (erase_) xmpData_.erase(pos);
+ }
+
+ // *************************************************************************
+ // free functions
+ void copyExifToXmp(const ExifData& exifData, XmpData& xmpData)
+ {
+ Converter converter(const_cast<ExifData&>(exifData), xmpData);
+ converter.cnvExifToXmp();
+ }
+
+ void moveExifToXmp(ExifData& exifData, XmpData& xmpData)
+ {
+ Converter converter(const_cast<ExifData&>(exifData), xmpData);
+ converter.setErase();
+ converter.cnvExifToXmp();
+ }
+
+ void copyXmpToExif(const XmpData& xmpData, ExifData& exifData)
+ {
+ Converter converter(exifData, const_cast<XmpData&>(xmpData));
+ converter.cnvXmpToExif();
+ }
+
+ void moveXmpToExif(XmpData& xmpData, ExifData& exifData)
+ {
+ Converter converter(exifData, const_cast<XmpData&>(xmpData));
+ converter.setErase();
+ converter.cnvXmpToExif();
+ }
+
+ void copyIptcToXmp(const IptcData& iptcData, XmpData& xmpData)
+ {
+ // Todo: implement me!
+ }
+
+ void moveIptcToXmp(IptcData& iptcData, XmpData& xmpData)
+ {
+ // Todo: implement me!
+ }
+
+ void copyXmpToIptc(const XmpData& xmpData, IptcData& iptcData)
+ {
+ // Todo: implement me!
+ }
+
+ void moveXmpToIptc(XmpData& xmpData, IptcData& iptcData)
+ {
+ // Todo: implement me!
+ }
+
+} // namespace Exiv2
+
+// *****************************************************************************
+// local definitions
+namespace {
+
+
+}
diff --git a/src/convert.hpp b/src/convert.hpp
new file mode 100644
index 0000000..b026419
--- /dev/null
+++ b/src/convert.hpp
@@ -0,0 +1,72 @@
+// ***************************************************************** -*- C++ -*-
+/*
+ * Copyright (C) 2004-2008 Andreas Huggel <ahuggel at gmx.net>
+ *
+ * This program is part of the Exiv2 distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
+ */
+/*!
+ @file convert.hpp
+ @brief Exif and IPTC conversions to and from XMP
+ @version $Rev$
+ @author Andreas Huggel (ahu)
+ <a href="mailto:ahuggel at gmx.net">ahuggel at gmx.net</a>
+ @date 17-Mar-08, ahu: created
+ */
+#ifndef CONVERT_HPP_
+#define CONVERT_HPP_
+
+// *****************************************************************************
+// included header files
+
+// + standard includes
+
+// *****************************************************************************
+// namespace extensions
+namespace Exiv2 {
+
+// *****************************************************************************
+// class declarations
+ class ExifData;
+ class IptcData;
+ class XmpData;
+
+// *****************************************************************************
+// free functions, template and inline definitions
+
+ //! Convert (copy) Exif tags to XMP properties.
+ void copyExifToXmp(const ExifData& exifData, XmpData& xmpData);
+ //! Convert (move) Exif tags to XMP properties, remove converted properties.
+ void moveExifToXmp(ExifData& exifData, XmpData& xmpData);
+
+ //! Convert (copy) XMP properties to Exif tags.
+ void copyXmpToExif(const XmpData& xmpData, ExifData& exifData);
+ //! Convert (move) XMP properties to Exif tags, remove converted properties.
+ void moveXmpToExif(XmpData& xmpData, ExifData& exifData);
+
+ //! Convert (copy) IPTC datasets to XMP properties.
+ void copyIptcToXmp(const IptcData& iptcData, XmpData& xmpData);
+ //! Convert (move) IPTC datasets to XMP properties, remove converted properties.
+ void moveIptcToXmp(IptcData& iptcData, XmpData& xmpData);
+
+ //! Convert (copy) XMP properties to IPTC datasets.
+ void copyXmpToIptc(const XmpData& xmpData, IptcData& iptcData);
+ //! Convert (move) XMP properties to IPTC tags, remove converted properties.
+ void moveXmpToIptc(XmpData& xmpData, IptcData& iptcData);
+
+} // namespace Exiv2
+
+#endif // #ifndef CONVERT_HPP_
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list