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

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:41:59 UTC 2017


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

The following commit has been merged in the master branch:
commit e62c70a867f6da064a25e2749f22688a226c5747
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Fri Oct 1 14:09:47 2010 +0000

    Improved determination of MIME type (not complete yet), optimized TIFF accessors pixelWidth, pixelHeight, mimeType and primaryGroup.
---
 src/rw2image.cpp  |  2 +-
 src/tiffimage.cpp | 47 +++++++++++++++++++++++++++++++++++++----------
 src/tiffimage.hpp |  7 +++++++
 3 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/src/rw2image.cpp b/src/rw2image.cpp
index fc146ea..c9a0a2a 100644
--- a/src/rw2image.cpp
+++ b/src/rw2image.cpp
@@ -64,7 +64,7 @@ namespace Exiv2 {
 
     std::string Rw2Image::mimeType() const
     {
-        return "image/x-raw";
+        return "image/x-panasonic-rw2";
     }
 
     int Rw2Image::pixelWidth() const
diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp
index e9341b6..bf0da31 100644
--- a/src/tiffimage.cpp
+++ b/src/tiffimage.cpp
@@ -80,17 +80,40 @@ namespace Exiv2 {
     using namespace Internal;
 
     TiffImage::TiffImage(BasicIo::AutoPtr io, bool /*create*/)
-        : Image(ImageType::tiff, mdExif | mdIptc, io)
+        : Image(ImageType::tiff, mdExif | mdIptc, io),
+          pixelWidth_(0), pixelHeight_(0)
     {
     } // TiffImage::TiffImage
 
+    struct MimeTypeList {
+        bool operator==(int compression) const { return compression_ == compression; }
+        int compression_;
+        const char* mimeType_;
+    };
+
+    MimeTypeList mimeTypeList[] = {
+        { 32770, "image/x-samsung-srw" },
+        { 34713, "image/x-nikon-nef"   }
+    };
+
     std::string TiffImage::mimeType() const
     {
-        return "image/tiff";
+        if (!mimeType_.empty()) return mimeType_;
+
+        mimeType_ = std::string("image/tiff");
+        std::string key = "Exif." + primaryGroup() + ".Compression";
+        ExifData::const_iterator md = exifData_.findKey(ExifKey(key));
+        if (md != exifData_.end() && md->count() > 0) {
+            const MimeTypeList* i = find(mimeTypeList, static_cast<int>(md->toLong()));
+            if (i) mimeType_ = std::string(i->mimeType_);
+        }
+        return mimeType_;
     }
 
     std::string TiffImage::primaryGroup() const
     {
+        if (!primaryGroup_.empty()) return primaryGroup_;
+
         static const char* keys[] = {
             "Exif.Image.NewSubfileType",
             "Exif.SubImage1.NewSubfileType",
@@ -104,38 +127,42 @@ namespace Exiv2 {
             "Exif.SubImage9.NewSubfileType"
         };
         // Find the group of the primary image, default to "Image"
-        std::string groupName = "Image";
+        primaryGroup_ = std::string("Image");
         for (unsigned int i = 0; i < EXV_COUNTOF(keys); ++i) {
             ExifData::const_iterator md = exifData_.findKey(ExifKey(keys[i]));
             // Is it the primary image?
             if (md != exifData_.end() && md->count() > 0 && md->toLong() == 0) {
                 // Sometimes there is a JPEG primary image; that's not our first choice
-                groupName = md->groupName();
-                std::string key = "Exif." + groupName + ".JPEGInterchangeFormat";
+                primaryGroup_ = md->groupName();
+                std::string key = "Exif." + primaryGroup_ + ".JPEGInterchangeFormat";
                 if (exifData_.findKey(ExifKey(key)) == exifData_.end()) break;
             }
         }
-        return groupName;
+        return primaryGroup_;
     }
 
     int TiffImage::pixelWidth() const
     {
+        if (pixelWidth_ != 0) return pixelWidth_;
+
         ExifKey key(std::string("Exif.") + primaryGroup() + std::string(".ImageWidth"));
         ExifData::const_iterator imageWidth = exifData_.findKey(key);
         if (imageWidth != exifData_.end() && imageWidth->count() > 0) {
-            return imageWidth->toLong();
+            pixelWidth_ = static_cast<int>(imageWidth->toLong());
         }
-        return 0;
+        return pixelWidth_;
     }
 
     int TiffImage::pixelHeight() const
     {
+        if (pixelHeight_ != 0) return pixelHeight_;
+
         ExifKey key(std::string("Exif.") + primaryGroup() + std::string(".ImageLength"));
         ExifData::const_iterator imageHeight = exifData_.findKey(key);
         if (imageHeight != exifData_.end() && imageHeight->count() > 0) {
-            return imageHeight->toLong();
+            pixelHeight_ = imageHeight->toLong();
         }
-        return 0;
+        return pixelHeight_;
     }
 
     void TiffImage::setComment(const std::string& /*comment*/)
diff --git a/src/tiffimage.hpp b/src/tiffimage.hpp
index 5bf5ed3..ea608d4 100644
--- a/src/tiffimage.hpp
+++ b/src/tiffimage.hpp
@@ -109,6 +109,13 @@ namespace Exiv2 {
         std::string primaryGroup() const;
         //@}
 
+    private:
+        // DATA
+        mutable std::string primaryGroup_;     //!< The primary group
+        mutable std::string mimeType_;         //!< The MIME type
+        mutable int pixelWidth_;               //!< Width of the primary image in pixels 
+        mutable int pixelHeight_;              //!< Height of the primary image in pixels 
+
     }; // class TiffImage
 
     /*!

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list