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

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:46:27 UTC 2017


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

The following commit has been merged in the master branch:
commit b296460702b9820d50a9d8bf2545807a10a1771c
Author: Robin Mills <robin at clanmills.com>
Date:   Fri Apr 29 19:24:52 2016 +0000

    #1034 Correction to r4293.  Adding forgotton files!
---
 samples/toexv.cpp                   | 190 ++++++++++++++++++++++++++++++++++++
 samples/{metacopy.hpp => toexv.hpp} |  30 ++----
 2 files changed, 200 insertions(+), 20 deletions(-)

diff --git a/samples/toexv.cpp b/samples/toexv.cpp
new file mode 100644
index 0000000..44881f7
--- /dev/null
+++ b/samples/toexv.cpp
@@ -0,0 +1,190 @@
+// ***************************************************************** -*- C++ -*-
+/*
+ * Copyright (C) 2004-2015 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.
+ */
+/*
+  Abstract : Test application to extract metadata from image to exv file
+  Version  : $Rev: 3777 $
+ */
+// *****************************************************************************
+// included header files
+#include <exiv2/exiv2.hpp>
+
+#include <iostream>
+#include <fstream>
+#include <cassert>
+
+#include "utils.hpp"
+#include "toexv.hpp"
+
+// *****************************************************************************
+// Main
+int main(int argc, char* const argv[])
+{
+	try {
+		// Handle command line arguments
+		Params params(":iecCahsx");
+		if (params.getopt(argc, argv)) return params.usage();
+		if (params.help_             ) return params.help();
+
+		Exiv2::Image::AutoPtr readImage = Exiv2::ImageFactory::open(params.read_);
+		assert(readImage.get() != 0);
+		readImage->readMetadata();
+
+		Exiv2::Image::AutoPtr writeImage = Exiv2::ImageFactory::create(Exiv2::ImageType::exv,params.write_);
+		assert(writeImage.get() != 0);
+
+		if (params.all_    ) writeImage->setMetadata  (*readImage);
+		if (params.iptc_   ) writeImage->setIptcData  (readImage->iptcData());
+		if (params.exif_   ) writeImage->setExifData  (readImage->exifData());
+		if (params.ICC_    ) writeImage->setIccProfile(*readImage->iccProfile());
+		if (params.comment_) writeImage->setComment   (readImage->comment());
+		if (params.xmp_    ) writeImage->setXmpData   (readImage->xmpData());
+
+		writeImage->writeMetadata();
+
+		if ( params.size_ ) std::cout << params.write_ << " " << writeImage->io().size() << std::endl;
+		return 0;
+
+#if 0
+		// This is prototype code for working on writing metadata to memory
+		// This has been discussed with Andrea Ferrora (PhotoFlow)
+		// And useful for sending the exv to a webservice.
+		uint32_t     size = 54321;
+		Exiv2::byte  data[size];
+		Exiv2::BasicIo::AutoPtr memIo   (new Exiv2::MemIo(data,size));
+		Exiv2::Image::AutoPtr   memImage(new Exiv2::ExvImage(memIo,true));
+		memImage->setMetadata(*image);
+		std::cout << "wrote " << memImage->writeMetadata() << std::endl;
+
+		for ( size_t i = 0 ; i < 20 ; i++ ) {
+			char c = (char) data[i] ;
+			if ( c < 32 || c > 127 ) c = '.' ;
+			std::cout <<  c;
+		}
+		std::cout << std::endl;
+#endif
+
+	} catch (Exiv2::AnyError& e) {
+		std::cerr << "Caught Exiv2 exception '" << e << "'
";
+		return 3;
+	}
+}
+
+Params::Params( const char* opts)
+: optstring_(opts)
+, first_(true)
+, help_(false)
+, iptc_(false)
+, exif_(false)
+, ICC_(false)
+, all_(false)
+, comment_(false)
+, xmp_(false)
+, size_(false)
+{}
+
+
+int Params::option(int opt, const std::string& /*optarg*/, int optopt)
+{
+    int rc = 0;
+    switch (opt) {
+    case 'h': help_     = true ; break;
+    case 'i': iptc_     = true ; break;
+    case 'e': exif_     = true ; break;
+    case 'c': comment_  = true ; break;
+    case 'C': ICC_      = true ; break;
+    case 'x': xmp_      = true ; break;
+    case 'a': all_      = true ; break;
+    case 's': size_     = true ; break;
+    case 'p': /* ignore for backwards compatibility */ ; break;
+    case ':':
+        std::cerr << progname() << ": Option -" << static_cast<char>(optopt)
+                  << " requires an argument
";
+        rc = 1;
+        break;
+    case '?':
+        std::cerr << progname() << ": Unrecognized option -"
+                  << static_cast<char>(optopt) << "
";
+        rc = 1;
+        break;
+    default:
+        std::cerr << progname()
+                  << ": getopt returned unexpected character code " << (char) opt
+                  << " 0x" << std::hex << opt << "
";
+        rc = 1;
+        break;
+    }
+
+    return rc;
+}
+
+int Params::nonoption(const std::string& argv)
+{
+    if (!write_.empty()) {
+        std::cerr << progname() << ": Unexpected extra argument (" << argv << ")
";
+        return 1;
+    }
+    if (first_) read_ = argv;
+    else        write_ = argv;
+    first_ = false;
+    return 0;
+}
+
+int Params::getopt(int argc, char* const argv[])
+{
+    int rc = Util::Getopt::getopt(argc, argv, optstring_);
+    // Further consistency checks
+    if (help_==false) {
+        if (rc==0 && read_.empty() ) {
+            std::cerr << progname() << ": Read and write files must be specified
";
+            rc = 1;
+        }
+        if (rc==0 && write_.empty() ) {
+            std::cerr << progname() << ": Write file must be specified
";
+            rc = 1;
+        }
+    }
+    if ( argc == 3 ) { all_ = true; size_ = true; }
+    return rc;
+}
+
+int Params::usage(std::ostream& os) const
+{
+    os << "
Reads and writes raw metadata. Use -h option for help.
"
+       << "Usage: " << progname()
+       << " [-" << optstring_ << "]"
+       << " readfile writefile
";
+    return 2;
+}
+
+int Params::help(std::ostream& os) const
+{
+    usage(os);
+    os << "
Options:
"
+          "   -i      Read Iptc data from readfile and write to writefile.
"
+          "   -e      Read Exif data from readfile and write to writefile.
"
+          "   -c      Read Jpeg comment from readfile and write to writefile.
"
+          "   -C      Read ICC profile from readfile and write to writefile.
"
+          "   -x      Read XMP data from readfile and write to writefile.
"
+          "   -a      Read all metadata from readfile and write to writefile.
"
+          "   -s      Print size of writefile.
"
+          "   -h      Display this help and exit.
";
+    return 1;
+}
diff --git a/samples/metacopy.hpp b/samples/toexv.hpp
similarity index 76%
copy from samples/metacopy.hpp
copy to samples/toexv.hpp
index b767a77..1178c82 100644
--- a/samples/metacopy.hpp
+++ b/samples/toexv.hpp
@@ -19,14 +19,10 @@
  * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
  */
 /*!
-  @file    metacopy.hpp
-  @brief   Defines class Params, used for the command line handling
-  @version $Rev$
-  @author  Brad Schick (brad) <brad at robotbattle.com>
-  @date    13-Jul-04, brad: created
+  @version $Rev: 3777 $
  */
-#ifndef METACOPY_HPP_
-#define METACOPY_HPP_
+#ifndef _TOEXC_HPP_
+#define _TOEXC_HPP_
 
 class Params : public Util::Getopt {
 private:
@@ -37,9 +33,11 @@ public:
     bool help_;                    //!< Help option flag.
     bool iptc_;                    //!< Iptc option flag.
     bool exif_;                    //!< Exif option flag.
+    bool ICC_ ;                    //!< ICC option flag.
+    bool all_ ;                    //!< All option flag
     bool comment_;                 //!< JPEG comment option flag.
     bool xmp_;                     //!< XMP option flag.
-    bool preserve_;                //!< Preserve existing metadata option flag.
+    bool size_    ;                //!< Size option flag.
     std::string read_;             //!< Source file
     std::string write_;            //!< Destination file
 
@@ -47,15 +45,7 @@ public:
     /*!
       @brief Default constructor. Note that optstring_ is initialized here.
      */
-    Params() : optstring_(":iecaph"),
-               first_(true),
-               help_(false),
-               iptc_(false),
-               exif_(false),
-               comment_(false),
-               xmp_(false),
-               preserve_(false)
-        {}
+    Params( const char* opts);
 
     /*!
       @brief Call Getopt::getopt() with optstring, to initiate command line
@@ -76,11 +66,11 @@ public:
     virtual int nonoption(const std::string& argv);
 
     //! Print a minimal usage note to an output stream.
-    void usage(std::ostream& os =std::cout) const;
+    int usage(std::ostream& os =std::cout) const;
 
     //! Print further usage explanations to an output stream.
-    void help(std::ostream& os =std::cout) const;
+    int help(std::ostream& os =std::cout) const;
 
 }; // class Params
 
-#endif // METACOPY_HPP_
+#endif // _TOEXV_HPP_

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list