[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:35:57 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=310ab78

The following commit has been merged in the master branch:
commit 310ab78eb4118ebce387f1251fb2b023635ecf6a
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Tue Jan 27 04:26:25 2004 +0000

    Added example1 program
---
 src/Makefile     |   4 +-
 src/example1.cpp | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 159 insertions(+), 2 deletions(-)

diff --git a/src/Makefile b/src/Makefile
index e75a746..2a4f019 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -23,7 +23,7 @@
 #
 # RCS information
 #  $Name:  $
-#  $Revision: 1.5 $
+#  $Revision: 1.6 $
 #
 # Description:
 #  Do NOT change this file! All system specific settings and configs
@@ -58,7 +58,7 @@ CCHDR =
 CCSRC = exif.cpp tags.cpp utils.cpp
 
 # Add source files of applications to this list
-BINSRC = exiftest.cpp exifprint.cpp
+BINSRC = exiftest.cpp exifprint.cpp example1.cpp
 
 # **********************************************************************
 # Library
diff --git a/src/example1.cpp b/src/example1.cpp
new file mode 100644
index 0000000..ca179ce
--- /dev/null
+++ b/src/example1.cpp
@@ -0,0 +1,157 @@
+// ***************************************************************** -*- C++ -*-
+/*
+ * Copyright (C) 2004 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+/*
+  Abstract:  Sample code to add, modify and delete Exif metadata
+
+  File:      example1.cpp
+  Version:   $Name:  $ $Revision: 1.1 $
+  Author(s): Andreas Huggel (ahu) <ahuggel at gmx.net>
+  History:   26-Jan-04, ahu: created
+ */
+// *****************************************************************************
+// included header files
+#include "exif.hpp"
+#include <iostream>
+#include <iomanip>
+
+// *****************************************************************************
+// local declarations
+
+using namespace Exif;
+
+void exifPrint(const ExifData& exifData);
+
+// *****************************************************************************
+// Main
+int main()
+try {
+    // Container for all metadata
+    ExifData exifData;
+
+    // *************************************************************************
+    // Add to the Exif data
+
+    // Create a value of the required type
+    Value* v = Value::create(asciiString);
+    // Set the value to a string
+    v->read("1999:12:31 23:59:59");
+    // Add the value together with its key to the Exif data container
+    std::string key = "Image.DateTime.DateTimeOriginal";
+    exifData.add(key, v);
+
+    std::cout << "Added key \"" << key << "\", value \"" << *v << "\"
";
+    // Delete the memory allocated by Value::create
+    delete v;
+
+    // Now create a more interesting value
+    v = Value::create(unsignedRational);
+    // Set two rational components from a string
+    v->read("1/2 1/3");
+    // Downcast the Value to its actual type
+    URationalValue* rv = dynamic_cast<URationalValue*>(v);
+    if (rv == 0) throw Error("Downcast failed");
+    // Add more elements through the extended interface of the actual type
+    rv->value_.push_back(std::make_pair(2,3));
+    rv->value_.push_back(std::make_pair(3,4));
+    // Add the key and value pair to the Exif data
+    key = "Image.ImageCharacteristics.PrimaryChromaticities";
+    exifData.add(key, rv);
+
+    std::cout << "Added key \"" << key << "\", value \"" << *v << "\"
";
+    // Delete the memory allocated by Value::create
+    delete v;
+
+    // *************************************************************************
+    // Modify Exif data
+
+    // Find the timestamp metadatum by its key
+    key = "Image.DateTime.DateTimeOriginal";
+    ExifData::iterator pos = exifData.findKey(key);
+    if (pos == exifData.end()) throw Error("Key not found");
+    // Modify the value
+    std::string date = pos->toString();
+    date.replace(0,4,"2000");
+    pos->setValue(date); 
+
+    // Find the other key
+    key = "Image.ImageCharacteristics.PrimaryChromaticities";
+    pos = exifData.findKey(key);
+    if (pos == exifData.end()) throw Error("Key not found");
+    // Get a pointer to a copy of the value
+    v = pos->getValue();
+    // Downcast the Value pointer to its actual type
+    rv = dynamic_cast<URationalValue*>(v);
+    if (rv == 0) throw Error("Downcast failed");
+    // Modify elements through the extended interface of the actual type
+    rv->value_[2] = std::make_pair(88,77);
+    // Copy the modified value back to the metadatum
+    pos->setValue(rv);
+    // Delete the memory allocated by getValue
+    delete v;
+
+    std::cout << "---
";
+    exifPrint(exifData);
+
+    // *************************************************************************
+    // Delete metadata from the Exif data container
+
+    // Delete a metadatum by its key
+    key = "Image.DateTime.DateTimeOriginal";
+    exifData.erase(key);
+
+    // Delete the metadatum at iterator position pos
+    key = "Image.ImageCharacteristics.PrimaryChromaticities";
+    pos = exifData.findKey(key);
+    if (pos == exifData.end()) throw Error("Key not found");
+    exifData.erase(pos);
+
+    std::cout << "---
";
+    exifPrint(exifData);
+
+    return 0;
+}
+catch (Error& e) {
+    std::cout << "Caught Exif exception '" << e << "'
";
+    return 1;
+}
+
+// *****************************************************************************
+// local definitions
+
+void exifPrint(const ExifData& exifData)
+{
+    ExifData::const_iterator beg = exifData.begin();
+    ExifData::const_iterator end = exifData.end();
+    ExifData::const_iterator i = beg;
+    for (; i != end; ++i) {
+        std::cout << "0x" 
+                  << std::hex << std::setw(4) << std::setfill('0') << std::right
+                  << i->tag() << " " 
+                  << std::setw(27) << std::setfill(' ') << std::left
+                  << i->tagName() << " "
+                  << std::setw(17) << std::setfill(' ') << std::left
+                  << i->typeName() << " "
+                  << std::dec << std::setw(3) 
+                  << std::setfill(' ') << std::right
+                  << i->count() << "   " 
+                  << std::dec << i->value() << "
";
+    }
+}

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list