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

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:38:15 UTC 2017


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

The following commit has been merged in the master branch:
commit 45595a77663a5479f1248577a424d448237dc39e
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Tue Jan 30 14:01:47 2007 +0000

    Added ability to modify metadata on-the-fly, together with the extract and insert actions. Implements feature #504.
---
 src/actions.cpp | 92 ++++++++++++++++++++++++++++++++-------------------------
 src/actions.hpp | 18 ++++++-----
 src/exiv2.1     | 21 ++++++++-----
 src/exiv2.cpp   | 16 +++++++---
 4 files changed, 88 insertions(+), 59 deletions(-)

diff --git a/src/actions.cpp b/src/actions.cpp
index 273db48..72c5143 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -221,7 +221,7 @@ namespace Action {
         Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path_);
         assert(image.get() != 0);
         image->readMetadata();
-        Exiv2::ExifData &exifData = image->exifData();
+        Exiv2::ExifData& exifData = image->exifData();
         if (exifData.empty()) {
             std::cerr << path_ << ": "
                       << _("No Exif data found in the file
");
@@ -577,7 +577,7 @@ namespace Action {
         Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path_);
         assert(image.get() != 0);
         image->readMetadata();
-        Exiv2::ExifData &exifData = image->exifData();
+        Exiv2::ExifData& exifData = image->exifData();
         if (exifData.empty()) {
             std::cerr << path_
                       << ": " << _("No Exif data found in the file
");
@@ -697,7 +697,7 @@ namespace Action {
         Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path_);
         assert(image.get() != 0);
         image->readMetadata();
-        Exiv2::IptcData &iptcData = image->iptcData();
+        Exiv2::IptcData& iptcData = image->iptcData();
         if (iptcData.empty()) {
             std::cerr << path_
                       << ": " << _("No Iptc data found in the file
");
@@ -766,7 +766,7 @@ namespace Action {
         Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path);
         assert(image.get() != 0);
         image->readMetadata();
-        Exiv2::ExifData &exifData = image->exifData();
+        Exiv2::ExifData& exifData = image->exifData();
         if (exifData.empty()) {
             std::cerr << path
                       << ": " << _("No Exif data found in the file
");
@@ -879,7 +879,7 @@ namespace Action {
 
     int Erase::eraseThumbnail(Exiv2::Image* image) const
     {
-        Exiv2::ExifData &exifData = image->exifData();
+        Exiv2::ExifData& exifData = image->exifData();
         std::string thumbExt = exifData.thumbnailExtension();
         if (thumbExt.empty()) {
             return 0;
@@ -969,7 +969,7 @@ namespace Action {
         Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path_);
         assert(image.get() != 0);
         image->readMetadata();
-        Exiv2::ExifData &exifData = image->exifData();
+        Exiv2::ExifData& exifData = image->exifData();
         if (exifData.empty()) {
             std::cerr << path_
                       << ": " << _("No Exif data found in the file
");
@@ -1076,7 +1076,7 @@ namespace Action {
         Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path);
         assert(image.get() != 0);
         image->readMetadata();
-        Exiv2::ExifData &exifData = image->exifData();
+        Exiv2::ExifData& exifData = image->exifData();
         exifData.setJpegThumbnail(thumbPath);
         image->writeMetadata();
 
@@ -1105,10 +1105,30 @@ namespace Action {
         if (Params::instance().preserve_) {
             ts.read(path);
         }
-        image_ = Exiv2::ImageFactory::open(path);
-        assert(image_.get() != 0);
-        image_->readMetadata();
+        Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path);
+        assert(image.get() != 0);
+        image->readMetadata();
+
+        applyCommands(image.get());
+
+        // Save both exif and iptc metadata
+        image->writeMetadata();
 
+        if (Params::instance().preserve_) {
+            ts.touch(path);
+        }
+        return 0;
+    }
+    catch(const Exiv2::AnyError& e)
+    {
+        std::cerr << "Exiv2 exception in modify action for file " << path
+                  << ":
" << e << "
";
+        return 1;
+    }
+    } // Modify::run
+
+    void Modify::applyCommands(Exiv2::Image* pImage)
+    {
         if (!Params::instance().jpegComment_.empty()) {
             if (Params::instance().verbose_) {
                 std::cout << _("Setting Jpeg comment") << " '"
@@ -1116,7 +1136,7 @@ namespace Action {
                           << "'"
                           << std::endl;
             }
-            image_->setComment(Params::instance().jpegComment_);
+            pImage->setComment(Params::instance().jpegComment_);
         }
 
         // loop through command table and apply each command
@@ -1126,37 +1146,22 @@ namespace Action {
         for (; i != end; ++i) {
             switch (i->cmdId_) {
             case add:
-                addMetadatum(*i);
+                addMetadatum(pImage, *i);
                 break;
             case set:
-                setMetadatum(*i);
+                setMetadatum(pImage, *i);
                 break;
             case del:
-                delMetadatum(*i);
+                delMetadatum(pImage, *i);
                 break;
             default:
                 // Todo: complain
                 break;
             }
         }
+    } // Modify::applyCommands
 
-        // Save both exif and iptc metadata
-        image_->writeMetadata();
-
-        if (Params::instance().preserve_) {
-            ts.touch(path);
-        }
-        return 0;
-    }
-    catch(const Exiv2::AnyError& e)
-    {
-        std::cerr << "Exiv2 exception in modify action for file " << path
-                  << ":
" << e << "
";
-        return 1;
-    }
-    } // Modify::run
-
-    void Modify::addMetadatum(const ModifyCmd& modifyCmd)
+    void Modify::addMetadatum(Exiv2::Image* pImage, const ModifyCmd& modifyCmd)
     {
         if (Params::instance().verbose_) {
             std::cout << _("Add") << " " << modifyCmd.key_ << " \""
@@ -1164,20 +1169,22 @@ namespace Action {
                       << Exiv2::TypeInfo::typeName(modifyCmd.typeId_)
                       << ")" << std::endl;
         }
+        Exiv2::ExifData& exifData = pImage->exifData();
+        Exiv2::IptcData& iptcData = pImage->iptcData();
         Exiv2::Value::AutoPtr value = Exiv2::Value::create(modifyCmd.typeId_);
         if (0 == value->read(modifyCmd.value_)) {
             if (modifyCmd.metadataId_ == exif) {
-                image_->exifData().add(Exiv2::ExifKey(modifyCmd.key_), value.get());
+                exifData.add(Exiv2::ExifKey(modifyCmd.key_), value.get());
             }
             if (modifyCmd.metadataId_ == iptc) {
-                image_->iptcData().add(Exiv2::IptcKey(modifyCmd.key_), value.get());
+                iptcData.add(Exiv2::IptcKey(modifyCmd.key_), value.get());
             }
         }
     }
 
     // This function looks rather complex because we try to avoid adding an
     // empty metadatum if reading the value fails
-    void Modify::setMetadatum(const ModifyCmd& modifyCmd)
+    void Modify::setMetadatum(Exiv2::Image* pImage, const ModifyCmd& modifyCmd)
     {
         if (Params::instance().verbose_) {
             std::cout << _("Set") << " " << modifyCmd.key_ << " \""
@@ -1185,8 +1192,8 @@ namespace Action {
                       << Exiv2::TypeInfo::typeName(modifyCmd.typeId_)
                       << ")" << std::endl;
         }
-        Exiv2::ExifData &exifData = image_->exifData();
-        Exiv2::IptcData &iptcData = image_->iptcData();
+        Exiv2::ExifData& exifData = pImage->exifData();
+        Exiv2::IptcData& iptcData = pImage->iptcData();
         Exiv2::Metadatum* metadatum = 0;
         if (modifyCmd.metadataId_ == exif) {
             Exiv2::ExifData::iterator pos =
@@ -1227,14 +1234,14 @@ namespace Action {
         }
     }
 
-    void Modify::delMetadatum(const ModifyCmd& modifyCmd)
+    void Modify::delMetadatum(Exiv2::Image* pImage, const ModifyCmd& modifyCmd)
     {
         if (Params::instance().verbose_) {
             std::cout << _("Del") << " " << modifyCmd.key_ << std::endl;
         }
 
-        Exiv2::ExifData &exifData = image_->exifData();
-        Exiv2::IptcData &iptcData = image_->iptcData();
+        Exiv2::ExifData& exifData = pImage->exifData();
+        Exiv2::IptcData& iptcData = pImage->iptcData();
         if (modifyCmd.metadataId_ == exif) {
             Exiv2::ExifData::iterator pos;
             Exiv2::ExifKey exifKey = Exiv2::ExifKey(modifyCmd.key_);
@@ -1277,7 +1284,7 @@ namespace Action {
         Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path);
         assert(image.get() != 0);
         image->readMetadata();
-        Exiv2::ExifData &exifData = image->exifData();
+        Exiv2::ExifData& exifData = image->exifData();
         if (exifData.empty()) {
             std::cerr << path
                       << ": " << _("No Exif data found in the file
");
@@ -1361,7 +1368,7 @@ namespace Action {
         Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path);
         assert(image.get() != 0);
         image->readMetadata();
-        Exiv2::ExifData &exifData = image->exifData();
+        Exiv2::ExifData& exifData = image->exifData();
         if (exifData.empty()) {
             std::cerr << path
                       << ": " << _("No Exif data found in the file
");
@@ -1512,6 +1519,9 @@ namespace {
         assert(sourceImage.get() != 0);
         sourceImage->readMetadata();
 
+        // Apply any modification commands to the source image on-the-fly
+        Action::Modify::applyCommands(sourceImage.get());
+
         Exiv2::Image::AutoPtr targetImage;
         if (Exiv2::fileExists(target)) {
             targetImage = Exiv2::ImageFactory::open(target);
diff --git a/src/actions.hpp b/src/actions.hpp
index 3b295ec..f566e07 100644
--- a/src/actions.hpp
+++ b/src/actions.hpp
@@ -308,20 +308,24 @@ namespace Action {
         typedef std::auto_ptr<Modify> AutoPtr;
         AutoPtr clone() const;
         Modify() {}
+        //! Apply modification commands to the \em pImage
+        static void applyCommands(Exiv2::Image* pImage);
 
     private:
         virtual Modify* clone_() const;
         //! Copy contructor needed because of AutoPtr member
         Modify(const Modify& /*src*/) : Task() {}
 
-        //! Add a metadatum according to \em modifyCmd
-        void addMetadatum(const ModifyCmd& modifyCmd);
-        //! Set a metadatum according to \em modifyCmd
-        void setMetadatum(const ModifyCmd& modifyCmd);
-        //! Delete a metadatum according to \em modifyCmd
-        void delMetadatum(const ModifyCmd& modifyCmd);
+        //! Add a metadatum to \em pImage according to \em modifyCmd
+        static void addMetadatum(Exiv2::Image* pImage, 
+                                 const ModifyCmd& modifyCmd);
+        //! Set a metadatum in \em pImage according to \em modifyCmd
+        static void setMetadatum(Exiv2::Image* pImage, 
+                                 const ModifyCmd& modifyCmd);
+        //! Delete a metadatum from \em pImage according to \em modifyCmd
+        static void delMetadatum(Exiv2::Image* pImage, 
+                                 const ModifyCmd& modifyCmd);
 
-        Exiv2::Image::AutoPtr image_;        //!< Image to modify
     }; // class Modify
 
     /*!
diff --git a/src/exiv2.1 b/src/exiv2.1
index 893c617..dab1549 100644
--- a/src/exiv2.1
+++ b/src/exiv2.1
@@ -3,7 +3,7 @@
 .\" First parameter, NAME, should be all caps
 .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
 .\" other parameters are allowed: see man(7), man(1)
-.TH EXIV2 1 "November 16th, 2006"
+.TH EXIV2 1 "January 30th, 2007"
 .\" Please adjust this date whenever revising the manpage.
 .\"
 .\" Some roff macros, for reference:
@@ -42,13 +42,15 @@ Print image metadata. This is the default action, i.e., the command
 
Iexiv2 image.jpg
P will print a summary of the image Exif metadata.
 .TP
 .B ex | extract
-Extract metadata to *.exv and thumbnail image files.
+Extract metadata to *.exv and thumbnail image files. Modification
+commands can be applied on-the-fly.
 .TP
 .B in | insert
 Insert metadata from corresponding *.exv files.  Use option 
B\-S
P
 
I.suf
P to change the suffix of the input files. Since files of any
 supported format can be used as input files, this command can be used
-to copy the metadata between files of different formats.
+to copy the metadata between files of different formats. Modification
+commands can be applied on-the-fly.
 .TP
 .B rm | delete
 Delete image metadata from the files.
@@ -192,14 +194,19 @@ Filename format for the 'rename' action. The format string follows
 Default filename format is %Y%m%d_%H%M%S.
 .TP
 .B \-c 
Itxt
P
-JPEG comment string to set in the image ('modify' action).
+JPEG comment string to set in the image ('modify' action). This option
+can also be used with the 'extract' and 'insert' actions to modify
+metadata on-the-fly.
 .TP
 .B \-m 
Ifile
P
-Command file for the 'modify' action.
+Command file for the 'modify' action. This option can also be used
+with the 'extract' and 'insert' actions to modify metadata on-the-fly.
 .TP
 .B \-M 
Icmd
P
-Command line for the 'modify' action. The format for the commands is the same
-as that of the lines of a command file.
+Command line for the 'modify' action. This option can also be used
+with the 'extract' and 'insert' actions to modify metadata on-the-fly.
+The format for the commands is the same as that of the lines of a
+command file.
 .TP
 .B \-l 
Idir
P
 Location (directory) for files to be inserted or extracted.
diff --git a/src/exiv2.cpp b/src/exiv2.cpp
index 3a29ba3..b215b77 100644
--- a/src/exiv2.cpp
+++ b/src/exiv2.cpp
@@ -486,6 +486,7 @@ int Params::evalExtract(const std::string& optarg)
     int rc = 0;
     switch (action_) {
     case Action::none:
+    case Action::modify:
         action_ = Action::extract;
         target_ = 0;
         // fallthrough
@@ -513,6 +514,7 @@ int Params::evalInsert(const std::string& optarg)
     int rc = 0;
     switch (action_) {
     case Action::none:
+    case Action::modify:
         action_ = Action::insert;
         target_ = 0;
         // fallthrough
@@ -543,6 +545,8 @@ int Params::evalModify(int opt, const std::string& optarg)
         action_ = Action::modify;
         // fallthrough
     case Action::modify:
+    case Action::extract:
+    case Action::insert:
         if (opt == 'c') jpegComment_ = optarg;
         if (opt == 'm') cmdFiles_.push_back(optarg);  // parse the files later
         if (opt == 'M') cmdLines_.push_back(optarg);  // parse the commands later
@@ -592,7 +596,9 @@ int Params::nonoption(const std::string& argv)
             action_ = Action::erase;
         }
         if (argv == "ex" || argv == "extract") {
-            if (action_ != Action::none && action_ != Action::extract) {
+            if (   action_ != Action::none
+                && action_ != Action::extract
+                && action_ != Action::modify) {
                 std::cerr << progname() << ": "
                           << _("Action extract is not compatible with the given options
");
                 rc = 1;
@@ -601,7 +607,9 @@ int Params::nonoption(const std::string& argv)
             action_ = Action::extract;
         }
         if (argv == "in" || argv == "insert") {
-            if (action_ != Action::none && action_ != Action::insert) {
+            if (   action_ != Action::none
+                && action_ != Action::insert
+                && action_ != Action::modify) {
                 std::cerr << progname() << ": "
                           << _("Action insert is not compatible with the given options
");
                 rc = 1;
@@ -672,14 +680,14 @@ int Params::getopt(int argc, char* const argv[])
         std::cerr << progname() << ": " << _("At least one file is required
");
         rc = 1;
     }
-    if (rc == 0 && action_ == Action::modify) {
+    if (rc == 0 && !cmdFiles_.empty()) {
         // Parse command files
         if (!parseCmdFiles(modifyCmds_, cmdFiles_)) {
             std::cerr << progname() << ": " << _("Error parsing -m option arguments
");
             rc = 1;
         }
     }
-    if (rc ==0 && action_ == Action::modify) {
+    if (rc == 0 && !cmdLines_.empty()) {
         // Parse command lines
         if (!parseCmdLines(modifyCmds_, cmdLines_)) {
             std::cerr << progname() << ": " << _("Error parsing -M option arguments
");

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list