[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:33 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=f1c4c53
The following commit has been merged in the master branch:
commit f1c4c53c226b9a7d7428b9caa427c95493943984
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Tue Jun 16 12:06:17 2009 +0000
#638: Embed IPTC data in Photoshop IRB, some more code re-work.
---
src/pngchunk.cpp | 51 ++++++++++++----------------
src/pngchunk_int.hpp | 26 ++++++--------
src/pngimage.cpp | 96 +++++++++++++++++++---------------------------------
3 files changed, 66 insertions(+), 107 deletions(-)
diff --git a/src/pngchunk.cpp b/src/pngchunk.cpp
index 32f137a..36fc8b1 100644
--- a/src/pngchunk.cpp
+++ b/src/pngchunk.cpp
@@ -359,40 +359,32 @@ namespace Exiv2 {
} // PngChunk::parseChunkContent
- DataBuf PngChunk::makeMetadataChunk(const DataBuf& metadata, MetadataType type, bool compress)
+ std::string PngChunk::makeMetadataChunk(const std::string& metadata,
+ MetadataId type)
{
- // Todo: Return std::string instead of DataBuf, take metadata also as a std::string
-
std::string chunk;
+ std::string rawProfile;
switch (type) {
- case comment_Data:
- {
- std::string text((const char*)metadata.pData_, metadata.size_);
- chunk = makeUtf8TxtChunk("Description", text, compress);
+ case mdComment:
+ chunk = makeUtf8TxtChunk("Description", metadata, true);
break;
- }
- case exif_Data:
- {
- std::string rawProfile = writeRawProfile(metadata, "exif");
- chunk = makeAsciiTxtChunk("Raw profile type exif", rawProfile, compress);
+ case mdExif:
+ rawProfile = writeRawProfile(metadata, "exif");
+ chunk = makeAsciiTxtChunk("Raw profile type exif", rawProfile, true);
break;
- }
- case iptc_Data:
- {
- std::string rawProfile = writeRawProfile(metadata, "iptc");
- chunk = makeAsciiTxtChunk("Raw profile type iptc", rawProfile, compress);
+ case mdIptc:
+ rawProfile = writeRawProfile(metadata, "iptc");
+ chunk = makeAsciiTxtChunk("Raw profile type iptc", rawProfile, true);
break;
- }
- case xmp_Data:
- std::string text((const char*)metadata.pData_, metadata.size_);
- chunk = makeUtf8TxtChunk("XML:com.adobe.xmp", text, compress);
+ case mdXmp:
+ chunk = makeUtf8TxtChunk("XML:com.adobe.xmp", metadata, false);
break;
- }
+ case mdNone:
+ assert(false);
+ }
- DataBuf buf(chunk.size());
- chunk.copy((char*)buf.pData_, buf.size_);
- return buf;
+ return chunk;
} // PngChunk::makeMetadataChunk
@@ -636,14 +628,15 @@ namespace Exiv2 {
} // PngChunk::readRawProfile
- std::string PngChunk::writeRawProfile(const DataBuf& profileData, const char* profileType)
+ std::string PngChunk::writeRawProfile(const std::string& profileData,
+ const char* profileType)
{
static byte hex[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
std::ostringstream oss;
- oss << '
' << profileType << '
' << std::setw(8) << profileData.size_;
- const byte* sp = profileData.pData_;
- for (long i = 0; i < profileData.size_; i++) {
+ oss << '
' << profileType << '
' << std::setw(8) << profileData.size();
+ const char* sp = profileData.data();
+ for (std::string::size_type i = 0; i < profileData.size(); ++i) {
if (i % 36 == 0) oss << '
';
oss << hex[((*sp >> 4) & 0x0f)];
oss << hex[((*sp++) & 0x0f)];
diff --git a/src/pngchunk_int.hpp b/src/pngchunk_int.hpp
index 7e19578..90c77da 100644
--- a/src/pngchunk_int.hpp
+++ b/src/pngchunk_int.hpp
@@ -71,15 +71,6 @@ namespace Exiv2 {
zTXt_Chunk = 1,
iTXt_Chunk = 2
};
- /*!
- @brief Metadata Chunk types.
- */
- enum MetadataType {
- exif_Data = 0,
- iptc_Data = 1,
- xmp_Data = 2,
- comment_Data = 3
- };
public:
/*!
@@ -115,14 +106,15 @@ namespace Exiv2 {
static DataBuf keyTXTChunk(const DataBuf& data, bool stripHeader=false);
/*!
- @brief Return a complete PNG chunk data compressed or not as buffer. Data returned is formated
- accordingly with metadata \em type to host passed by \em metadata.
+ @brief Return a complete PNG chunk data compressed or not as buffer.
+ Data returned is formated accordingly with metadata \em type
+ to host passed by \em metadata.
@param metadata metadata buffer.
@param type metadata type.
- @param compress compress or not metadata.
*/
- static DataBuf makeMetadataChunk(const DataBuf& metadata, MetadataType type, bool compress);
+ static std::string makeMetadataChunk(const std::string& metadata,
+ MetadataId type);
private:
/*!
@@ -182,7 +174,7 @@ namespace Exiv2 {
/*!
@brief Wrapper around zlib to compress a PNG chunk content.
*/
- static std::string zlibCompress(const std::string& text);
+ static std::string zlibCompress(const std::string& text);
/*!
@brief Decode from ImageMagick raw text profile which host encoded Exif/Iptc/Xmp metadata byte array.
@@ -190,9 +182,11 @@ namespace Exiv2 {
static DataBuf readRawProfile(const DataBuf& text);
/*!
- @brief Encode to ImageMagick raw text profile which host encoded Exif/Iptc/Xmp metadata byte array.
+ @brief Encode to ImageMagick raw text profile, which host encoded
+ Exif/IPTC/XMP metadata byte arrays.
*/
- static std::string writeRawProfile(const DataBuf& profileData, const char* profileType);
+ static std::string writeRawProfile(const std::string& profileData,
+ const char* profileType);
}; // class PngChunk
diff --git a/src/pngimage.cpp b/src/pngimage.cpp
index 9f53881..cdb2b82 100644
--- a/src/pngimage.cpp
+++ b/src/pngimage.cpp
@@ -44,6 +44,7 @@ EXIV2_RCSID("@(#) $Id$")
#ifdef EXV_HAVE_LIBZ
#include "pngchunk_int.hpp"
#include "pngimage.hpp"
+#include "jpgimage.hpp"
#include "image.hpp"
#include "basicio.hpp"
#include "error.hpp"
@@ -252,83 +253,54 @@ namespace Exiv2 {
if (outIo.write(chunkBuf.pData_, chunkBuf.size_) != chunkBuf.size_) throw Error(21);
// Write all updated metadata here, just after IHDR.
-
- if (!comment_.empty())
- {
- // Update Comment data to a new compressed iTXt PNG chunk
-
- DataBuf com(reinterpret_cast<const byte*>(comment_.data()), static_cast<long>(comment_.size()));
- DataBuf chunkData = PngChunk::makeMetadataChunk(com, PngChunk::comment_Data, true);
-
-#ifdef DEBUG
- std::cout << "Exiv2::PngImage::doWriteMetadata: Write chunk with Comment metadata (lenght: "
- << chunkData.size_ << ")
";
-#endif
- if (outIo.write(chunkData.pData_, chunkData.size_) != chunkData.size_) throw Error(21);
+ if (!comment_.empty()) {
+ // Update Comment data to a new PNG chunk
+ std::string chunk = PngChunk::makeMetadataChunk(comment_, mdComment);
+ if (outIo.write((const byte*)chunk.data(), chunk.size()) != (long)chunk.size()) {
+ throw Error(21);
+ }
}
- if (exifData_.count() > 0)
- {
- // Update Exif data to a new zTXt PNG chunk
-
+ if (exifData_.count() > 0) {
+ // Update Exif data to a new PNG chunk
Blob blob;
ExifParser::encode(blob, littleEndian, exifData_);
- if (blob.size())
- {
- const unsigned char ExifHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00};
-
- DataBuf rawExif(sizeof(ExifHeader) + blob.size());
- memcpy(rawExif.pData_, ExifHeader, sizeof(ExifHeader));
- memcpy(rawExif.pData_ + sizeof(ExifHeader), &blob[0], blob.size());
- DataBuf chunkData = PngChunk::makeMetadataChunk(rawExif, PngChunk::exif_Data, true);
-
-#ifdef DEBUG
- std::cout << "Exiv2::PngImage::doWriteMetadata: Write chunk with Exif metadata (lenght: "
- << chunkData.size_ << ")
";
-#endif
- if (outIo.write(chunkData.pData_, chunkData.size_) != chunkData.size_) throw Error(21);
+ if (blob.size() > 0) {
+ static const char exifHeader[] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 };
+ std::string rawExif = std::string(exifHeader, 6)
+ + std::string((const char*)&blob[0], blob.size());
+ std::string chunk = PngChunk::makeMetadataChunk(rawExif, mdExif);
+ if (outIo.write((const byte*)chunk.data(), chunk.size()) != (long)chunk.size()) {
+ throw Error(21);
+ }
}
}
- if (iptcData_.count() > 0)
- {
- // Update Iptc data to a new zTXt PNG chunk
-
- DataBuf rawIptc = IptcParser::encode(iptcData_);
- if (rawIptc.size_ > 0)
- {
- DataBuf chunkData = PngChunk::makeMetadataChunk(rawIptc, PngChunk::iptc_Data, true);
-
-#ifdef DEBUG
- std::cout << "Exiv2::PngImage::doWriteMetadata: Write chunk with Iptc metadata (lenght: "
- << chunkData.size_ << ")
";
-#endif
- if (outIo.write(chunkData.pData_, chunkData.size_) != chunkData.size_) throw Error(21);
+ if (iptcData_.count() > 0) {
+ // Update IPTC data to a new PNG chunk
+ DataBuf newPsData = Photoshop::setIptcIrb(0, 0, iptcData_);
+ if (newPsData.size_ > 0) {
+ std::string rawIptc((const char*)newPsData.pData_, newPsData.size_);
+ std::string chunk = PngChunk::makeMetadataChunk(rawIptc, mdIptc);
+ if (outIo.write((const byte*)chunk.data(), chunk.size()) != (long)chunk.size()) {
+ throw Error(21);
+ }
}
}
- if (writeXmpFromPacket() == false)
- {
- if (XmpParser::encode(xmpPacket_, xmpData_) > 1)
- {
+ if (writeXmpFromPacket() == false) {
+ if (XmpParser::encode(xmpPacket_, xmpData_) > 1) {
#ifndef SUPPRESS_WARNINGS
std::cerr << "Error: Failed to encode XMP metadata.
";
#endif
}
}
- if (xmpPacket_.size() > 0)
- {
- // Update Xmp data to a new uncompressed iTXt PNG chunk
- // Note than XMP spec. Ver September 2005, page 97 require an uncompressed chunk to host XMP data
-
- DataBuf xmp(reinterpret_cast<const byte*>(xmpPacket_.data()), static_cast<long>(xmpPacket_.size()));
- DataBuf chunkData = PngChunk::makeMetadataChunk(xmp, PngChunk::xmp_Data, false);
-
-#ifdef DEBUG
- std::cout << "Exiv2::PngImage::doWriteMetadata: Write chunk with XMP metadata (lenght: "
- << chunkData.size_ << ")
";
-#endif
- if (outIo.write(chunkData.pData_, chunkData.size_) != chunkData.size_) throw Error(21);
+ if (xmpPacket_.size() > 0) {
+ // Update XMP data to a new PNG chunk
+ std::string chunk = PngChunk::makeMetadataChunk(xmpPacket_, mdXmp);
+ if (outIo.write((const byte*)chunk.data(), chunk.size()) != (long)chunk.size()) {
+ throw Error(21);
+ }
}
}
else if (!memcmp(cheaderBuf.pData_ + 4, "tEXt", 4) ||
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list