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

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:40:23 UTC 2017


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

The following commit has been merged in the master branch:
commit cde2a54cc5d6849017547277fc1a4a1a63ddfe93
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Sat Mar 7 10:11:04 2009 +0000

    #602: Added specialized insert and delete code for TIFF-like target images.
---
 src/actions.cpp          | 99 +++++++++++++++++++++++++++++++++++++++++++++++-
 src/exiv2.cpp            |  2 +-
 src/tags.cpp             |  2 +-
 test/data/exiv2-test.out |  2 +-
 4 files changed, 100 insertions(+), 5 deletions(-)

diff --git a/src/actions.cpp b/src/actions.cpp
index aa71e88..7b0feba 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -128,6 +128,12 @@ namespace {
                  bool preserve);
 
     /*!
+      @brief Test to distinguish between Exif and other tags in TIFF-like files.
+             Only Exif tags are copyed, deleted, added.
+     */
+    bool isExifTag(const Exiv2::Exifdatum& ed);
+
+    /*!
       @brief Rename a file according to a timestamp value.
 
       @param path The original file path. Contains the new path on exit.
@@ -1008,7 +1014,13 @@ namespace Action {
         if (Params::instance().verbose_ && image->exifData().count() > 0) {
             std::cout << _("Erasing Exif data from the file") << std::endl;
         }
-        image->clearExifData();
+        if (0 == strcmp(image->mimeType().c_str(), "image/tiff")) {
+            Exiv2::ExifData& ed = image->exifData();
+            ed.erase(std::remove_if(ed.begin(), ed.end(), isExifTag), ed.end());
+        }
+        else {
+            image->clearExifData();
+        }
         return 0;
     }
 
@@ -1863,7 +1875,22 @@ namespace {
                 std::cout << _("Writing Exif data from") << " " << source
                           << " " << _("to") << " " << target << std::endl;
             }
-            targetImage->setExifData(sourceImage->exifData());
+            if (0 == strcmp(targetImage->mimeType().c_str(), "image/tiff")) {
+                Exiv2::ExifData& ted = targetImage->exifData();
+                if (!preserve) {
+                    targetImage->readMetadata();
+                    ted.erase(std::remove_if(ted.begin(), ted.end(), isExifTag), ted.end());
+                }
+                const Exiv2::ExifData& sed = sourceImage->exifData();
+                for (Exiv2::ExifData::const_iterator pos = sed.begin(); pos != sed.end(); ++pos) {
+                    if (isExifTag(*pos)) {
+                        ted[pos->key()] = pos->value();
+                    }
+                }
+            }
+            else {
+                targetImage->setExifData(sourceImage->exifData());
+            }
         }
         if (   Params::instance().target_ & Params::ctIptc
             && !sourceImage->iptcData().empty()) {
@@ -1901,6 +1928,74 @@ namespace {
         return 0;
     } // metacopy
 
+    // Defined outside of the function so that Exiv2::find() can see it
+    struct String {
+        const char* s_;
+        bool operator==(const char* s) const {
+            return 0 == strcmp(s_, s);
+        }
+    };
+
+    bool isExifTag(const Exiv2::Exifdatum& ed)
+    {
+        // A somewhat random list of IFD0 tags which are considered as "Exif tags"
+        static const String exifTags[] = {
+            { "Exif.Image.ProcessingSoftware"      },
+            { "Exif.Image.DocumentName"            },
+            { "Exif.Image.ImageDescription"        },
+            { "Exif.Image.Make"                    },
+            { "Exif.Image.Model"                   },
+            { "Exif.Image.Software"                },
+            { "Exif.Image.DateTime"                },
+            { "Exif.Image.HostComputer"            },
+            { "Exif.Image.Artist"                  },
+            { "Exif.Image.XMLPacket"               },
+            { "Exif.Image.Rating"                  },
+            { "Exif.Image.RatingPercent"           },
+            { "Exif.Image.CFARepeatPatternDim"     },
+            { "Exif.Image.CFAPattern"              },
+            { "Exif.Image.BatteryLevel"            },
+            { "Exif.Image.IPTCNAA"                 },
+            { "Exif.Image.Copyright"               },
+            { "Exif.Image.ImageResources"          },
+            { "Exif.Image.ExifTag"                 },
+            { "Exif.Image.InterColorProfile"       },
+            { "Exif.Image.GPSTag"                  },
+            { "Exif.Image.XPTitle"                 },
+            { "Exif.Image.XPComment"               },
+            { "Exif.Image.XPAuthor"                },
+            { "Exif.Image.XPKeywords"              },
+            { "Exif.Image.XPSubject"               },
+            { "Exif.Image.PrintImageMatching"      },
+            { "Exif.Image.UniqueCameraModel"       },
+            { "Exif.Image.LocalizedCameraModel"    },
+            { "Exif.Image.CFAPlaneColor"           },
+            { "Exif.Image.CFALayout"               },
+            { "Exif.Image.CameraSerialNumber"      },
+            { "Exif.Image.LensInfo"                },
+            { "Exif.Image.OriginalRawFileName"     },
+            { "Exif.Image.ActiveArea"              },
+            { "Exif.Image.MaskedAreas"             },
+            { "Exif.Image.AsShotICCProfile"        },
+            { "Exif.Image.AsShotPreProfileMatrix"  },
+            { "Exif.Image.CurrentICCProfile"       },
+            { "Exif.Image.CurrentPreProfileMatrix" }
+        };
+
+        static const Exiv2::IfdId exifIfds[] = {
+            Exiv2::exifIfdId,
+            Exiv2::gpsIfdId,
+            Exiv2::iopIfdId
+        };
+
+        if (   0 != Exiv2::find(exifIfds, ed.ifdId())
+            || Exiv2::ExifTags::isMakerIfd(ed.ifdId())
+            || 0 != Exiv2::find(exifTags, ed.key().c_str())) {
+            return true;
+        }
+        return false;
+    } // isExifTag
+
     int renameFile(std::string& newPath, const struct tm* tm)
     {
         std::string path = newPath;
diff --git a/src/exiv2.cpp b/src/exiv2.cpp
index 13e7b86..76d6205 100644
--- a/src/exiv2.cpp
+++ b/src/exiv2.cpp
@@ -275,7 +275,7 @@ void Params::help(std::ostream& os) const
        << _("             E : include Exif tags in the list
")
        << _("             I : IPTC datasets
")
        << _("             X : XMP properties
")
-       << _("             x : print a column with the tag value
")
+       << _("             x : print a column with the tag number
")
        << _("             g : group name
")
        << _("             k : key
")
        << _("             l : tag label
")
diff --git a/src/tags.cpp b/src/tags.cpp
index ac6aa11..ac01b14 100644
--- a/src/tags.cpp
+++ b/src/tags.cpp
@@ -1673,7 +1673,7 @@ namespace Exiv2 {
     {
         bool rc = false;
         const IfdInfo* ii = find(ifdInfo_, ifdId);
-        if (ii != 0 && std::string(ii->name_) == "Makernote") {
+        if (ii != 0 && 0 == strcmp(ii->name_, "Makernote")) {
             rc = true;
         }
         return rc;
diff --git a/test/data/exiv2-test.out b/test/data/exiv2-test.out
index 3d9576e..23236e6 100644
--- a/test/data/exiv2-test.out
+++ b/test/data/exiv2-test.out
@@ -74,7 +74,7 @@ Options:
              E : include Exif tags in the list
              I : IPTC datasets
              X : XMP properties
-             x : print a column with the tag value
+             x : print a column with the tag number
              g : group name
              k : key
              l : tag label

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list