[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:13 UTC 2017


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

The following commit has been merged in the master branch:
commit cf1e91953dbdb547b5e54edece3ce94cb6566776
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Tue Dec 19 15:09:03 2006 +0000

    New TIFF parser: decode IPTC from IPTCNAA or ImageResources tag. Fixes bug #502
---
 src/cr2image.cpp    |  3 +-
 src/tiffparser.cpp  |  3 +-
 src/tiffvisitor.cpp | 86 ++++++++++++++++++++++++++++++++++++++++-------------
 src/tiffvisitor.hpp |  5 ++--
 4 files changed, 72 insertions(+), 25 deletions(-)

diff --git a/src/cr2image.cpp b/src/cr2image.cpp
index 9e8f8f1..b849b80 100644
--- a/src/cr2image.cpp
+++ b/src/cr2image.cpp
@@ -69,7 +69,8 @@ namespace Exiv2 {
         { "*",         0x011a, Group::ifd0,    0 },
         { "*",         0x011b, Group::ifd0,    0 },
         { "*",         0x0128, Group::ifd0,    0 },
-        { "*",         0x8649, Group::ifd0,    &TiffMetadataDecoder::decodeIrbIptc    }
+        { "*",         0x83bb, Group::ifd0,    &TiffMetadataDecoder::decodeIptc },
+        { "*",         0x8649, Group::ifd0,    &TiffMetadataDecoder::decodeIptc }
     };
 
     const DecoderFct Cr2Decoder::findDecoder(const std::string& make,
diff --git a/src/tiffparser.cpp b/src/tiffparser.cpp
index cf33c53..52f9f82 100644
--- a/src/tiffparser.cpp
+++ b/src/tiffparser.cpp
@@ -142,7 +142,8 @@ namespace Exiv2 {
         { "*",         0x014a, Group::ifd0,    0 }, // Todo: Controversial, causes problems with Exiftool
         { "*",       Tag::all, Group::sub0_0,  &TiffMetadataDecoder::decodeSubIfd       },
         { "*",       Tag::all, Group::sub0_1,  &TiffMetadataDecoder::decodeSubIfd       },
-        { "*",         0x8649, Group::ifd0,    &TiffMetadataDecoder::decodeIrbIptc      }
+        { "*",         0x83bb, Group::ifd0,    &TiffMetadataDecoder::decodeIptc         },
+        { "*",         0x8649, Group::ifd0,    &TiffMetadataDecoder::decodeIptc         }
     };
 
     const DecoderFct TiffDecoder::findDecoder(const std::string& make,
diff --git a/src/tiffvisitor.cpp b/src/tiffvisitor.cpp
index 856493f..d53e237 100644
--- a/src/tiffvisitor.cpp
+++ b/src/tiffvisitor.cpp
@@ -124,7 +124,8 @@ namespace Exiv2 {
         : pImage_(pImage),
           pRoot_(pRoot),
           findDecoderFct_(findDecoderFct),
-          threshold_(threshold)
+          threshold_(threshold),
+          decodedIptc_(false)
     {
         // Find camera make
         TiffFinder finder(0x010f, Group::ifd0);
@@ -185,32 +186,75 @@ namespace Exiv2 {
         }
     }
 
-    void TiffMetadataDecoder::decodeIrbIptc(const TiffEntryBase* object)
+    void TiffMetadataDecoder::decodeIptc(const TiffEntryBase* object)
     {
-        assert(object != 0);
-        assert(pImage_ != 0);
-        if (!object->pData()) return;
-        byte const* record = 0;
-        uint32_t sizeHdr = 0;
-        uint32_t sizeData = 0;
-        if (0 != Photoshop::locateIptcIrb(object->pData(), object->size(),
-                                          &record, &sizeHdr, &sizeData)) {
+        // add Exif tag anyway
+        decodeStdTiffEntry(object);
+
+        // All tags are read at this point, so the first time we come here,
+        // find the relevant IPTC tag and decode IPTC if found
+        if (decodedIptc_) {
             return;
         }
-        if (0 != pImage_->iptcData().load(record + sizeHdr, sizeData)) {
+        decodedIptc_ = true;
+        // 1st choice: IPTCNAA
+        byte const* pData = 0;
+        long size = 0;
+        if (object->tag() == 0x83bb) {
+            pData = object->pData();
+            size = object->size();
+        }
+        if (pData == 0) {
+            TiffFinder finder(0x83bb, Group::ifd0);
+            pRoot_->accept(finder);
+            TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
+            if (te) {
+                pData = te->pData();
+                size = te->size();
+            }
+        }
+        if (pData) {
+            if (0 == pImage_->iptcData().load(pData, size)) {
+                return;
+            }
 #ifndef SUPPRESS_WARNINGS
-            std::cerr << "Warning: Failed to decode IPTC block found in "
-                      << "Directory " << object->groupName()
-                      << ", entry 0x" << std::setw(4)
-                      << std::setfill('0') << std::hex << object->tag()
-                      << "
";
+            else {
+                std::cerr << "Warning: Failed to decode IPTC block found in "
+                          << "Directory Image, entry 0x83bb
";
+            }
+#endif
+        }
+
+        // 2nd choice if no IPTCNAA record found or failed to decode it:
+        // ImageResources
+        TiffEntryBase const* te = 0;
+        if (object->tag() == 0x8649) {
+            te = object;
+        }
+        else {
+            TiffFinder finder(0x83bb, Group::ifd0);
+            pRoot_->accept(finder);
+            te = dynamic_cast<TiffEntryBase*>(finder.result());
+        }
+        if (te) {
+            byte const* record = 0;
+            uint32_t sizeHdr = 0;
+            uint32_t sizeData = 0;
+            if (0 != Photoshop::locateIptcIrb(te->pData(), te->size(), 
+                                              &record, &sizeHdr, &sizeData)) {
+                return;
+            }
+            if (0 == pImage_->iptcData().load(record + sizeHdr, sizeData)) {
+                return;
+            }
+#ifndef SUPPRESS_WARNINGS
+            else {
+                std::cerr << "Warning: Failed to decode IPTC block found in "
+                          << "Directory Image, entry 0x8649
";
+            }
 #endif
-            // Todo: ExifKey should have an appropriate c'tor, it should not be
-            //       necessary to use groupName here
-            ExifKey key(object->tag(), object->groupName());
-            setExifTag(key, object->pValue());
         }
-    } // TiffMetadataDecoder::decodeIrbIptc
+    } // TiffMetadataDecoder::decodeIptc
 
     void TiffMetadataDecoder::decodeSubIfd(const TiffEntryBase* object)
     {
diff --git a/src/tiffvisitor.hpp b/src/tiffvisitor.hpp
index fa8c6ef..c9c348a 100644
--- a/src/tiffvisitor.hpp
+++ b/src/tiffvisitor.hpp
@@ -244,8 +244,8 @@ namespace Exiv2 {
         void decodeOlympThumb(const TiffEntryBase* object);
         //! Decode SubIFD contents to Image group if it contains primary image data
         void decodeSubIfd(const TiffEntryBase* object);
-        //! Decode IPTC data from a Photoshop IRB tag
-        void decodeIrbIptc(const TiffEntryBase* object);
+        //! Decode IPTC data from an IPTCNAA tag or Photoshop ImageResources
+        void decodeIptc(const TiffEntryBase* object);
         //@}
 
     private:
@@ -263,6 +263,7 @@ namespace Exiv2 {
         typedef std::map<uint16_t, uint32_t> GroupType;
         GroupType groupType_;        //!< NewSubfileType for each group
 
+        bool decodedIptc_;           //!< Indicates if IPTC has been decoded yet
     }; // class TiffMetadataDecoder
 
     /*!

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list