[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:46:11 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=fd5e983
The following commit has been merged in the master branch:
commit fd5e983746c336336039e91cb6b656cf8eeccdea
Author: Robin Mills <robin at clanmills.com>
Date: Tue Jan 5 14:39:49 2016 +0000
r1108 Recursively dump an image (exiv2 -pR file...)
---
include/exiv2/image.hpp | 2 +-
include/exiv2/jpgimage.hpp | 2 +-
include/exiv2/pngimage.hpp | 2 +-
include/exiv2/tiffimage.hpp | 18 +++-
src/exiv2.1 | 14 ++-
src/image.cpp | 2 +-
src/jpgimage.cpp | 44 +++++++--
src/pngimage.cpp | 80 +++++++++++++---
src/tags.cpp | 71 ++++++++++++++
src/tags_int.hpp | 3 +
src/tiffimage.cpp | 221 +++++++++++++++++++++++++-------------------
11 files changed, 335 insertions(+), 124 deletions(-)
diff --git a/include/exiv2/image.hpp b/include/exiv2/image.hpp
index 099d7c5..eb87d9b 100644
--- a/include/exiv2/image.hpp
+++ b/include/exiv2/image.hpp
@@ -113,7 +113,7 @@ namespace Exiv2 {
not valid (does not look like data of the specific image type).
@caution This function is not thread safe and intended for exiv2 -pS for debugging.
*/
- virtual void printStructure(std::ostream& out, PrintStructureOption option =kpsNone);
+ virtual void printStructure(std::ostream& out, PrintStructureOption option =kpsNone, int depth=0);
/*!
@brief Read all metadata supported by a specific image format from the
image. Before this method is called, the image metadata will be
diff --git a/include/exiv2/jpgimage.hpp b/include/exiv2/jpgimage.hpp
index 50eaffd..b61bfc7 100644
--- a/include/exiv2/jpgimage.hpp
+++ b/include/exiv2/jpgimage.hpp
@@ -159,7 +159,7 @@ namespace Exiv2 {
not valid (does not look like data of the specific image type).
@caution This function is not thread safe and intended for exiv2 -pS for debugging.
*/
- void printStructure(std::ostream& out, PrintStructureOption option);
+ void printStructure(std::ostream& out, PrintStructureOption option,int depth);
//@}
protected:
diff --git a/include/exiv2/pngimage.hpp b/include/exiv2/pngimage.hpp
index 2fa940d..083d017 100644
--- a/include/exiv2/pngimage.hpp
+++ b/include/exiv2/pngimage.hpp
@@ -93,7 +93,7 @@ namespace Exiv2
not valid (does not look like data of the specific image type).
@caution This function is not thread safe and intended for exiv2 -pS for debugging.
*/
- void printStructure(std::ostream& out, PrintStructureOption option);
+ void printStructure(std::ostream& out, PrintStructureOption option,int depth);
//@}
//! @name Accessors
diff --git a/include/exiv2/tiffimage.hpp b/include/exiv2/tiffimage.hpp
index 7ca67ad..76c1af7 100644
--- a/include/exiv2/tiffimage.hpp
+++ b/include/exiv2/tiffimage.hpp
@@ -91,9 +91,23 @@ namespace Exiv2 {
@brief Print out the structure of image file.
@throw Error if reading of the file fails or the image data is
not valid (does not look like data of the specific image type).
- @caution This function is not thread safe and intended for exiv2 -pS for debugging.
+ @caution This function is not thread safe and intended for exiv2 -p{S|R} as a file debugging aid
*/
- void printStructure(std::ostream& out, PrintStructureOption option);
+ void printStructure(std::ostream& out, PrintStructureOption option,int depth=-1);
+
+ /*!
+ @brief Print out the structure of image file.
+ @throw Error if reading of the file fails or the image data is
+ not valid (does not look like data of the specific image type).
+ @caution This function is not thread safe. See TiffImage::printStructure for more details
+ */
+ static void printTiffStructure(BasicIo& io,std::ostream& out, PrintStructureOption option,int depth);
+
+ /*!
+ @brief Print out the structure of a TIFF IFD
+ @caution This function is not thread safe. See TiffImage::printStructure for more details
+ */
+ static void printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStructureOption option,size_t start,bool bSwap,char c,int depth);
/*!
@brief Not supported. TIFF format does not contain a comment.
diff --git a/src/exiv2.1 b/src/exiv2.1
index a242811..28f92ee 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 "Dec 29, 2015"
+.TH EXIV2 1 "Jan 5, 2016"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@@ -175,9 +175,9 @@ fmt Default format is %Y%m%d_%H%M%S.
lvl d | i | i | w | e
debug, info, warning, error
-mod s | a | t | v | h | i | x | c | p | i | S | X :
+mod s | a | t | v | h | i | x | c | p | i | C | R | S | X :
summary, add, translated, vanilla, hex ...
- iptc ,xmp, comment, preview, Structure,XMP raw
+ iptc ,xmp, comment, preview, ICC, Recursive, Structure, raw XMP
tgt a | c | e | i | t | x
all, comment, exif, iptc, thumb, xmp
@@ -315,9 +315,13 @@ c : JPEG comment
.br
p : list available image previews, sorted by preview image size in pixels
.br
-S : print image structure information (jpg, png and tiff only)
+C : print image ICC Profile (jpg only)
.br
-X : print "raw" XMP (jpg, png and tiff only)
+R : print image structure recursively (jpg, tiff only)
+.br
+S : print image structure information (jpg, png, tiff only)
+.br
+X : print "raw" XMP (jpg, png, tiff only)
.TP
.B \-P
Iflgs
P
Print flags for fine control of the tag list ('print' action). Allows
diff --git a/src/image.cpp b/src/image.cpp
index 7cea7d9..9e8ddf4 100644
--- a/src/image.cpp
+++ b/src/image.cpp
@@ -169,7 +169,7 @@ namespace Exiv2 {
{
}
- void Image::printStructure(std::ostream&, PrintStructureOption)
+ void Image::printStructure(std::ostream&, PrintStructureOption,int /*depth*/)
{
throw Error(13, io_->path());
}
diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp
index 4bc8c4c..2f465ec 100644
--- a/src/jpgimage.cpp
+++ b/src/jpgimage.cpp
@@ -35,6 +35,7 @@ EXIV2_RCSID("@(#) $Id$")
#include "config.h"
#include "jpgimage.hpp"
+#include "tiffimage.hpp"
#include "image_int.hpp"
#include "error.hpp"
#include "futils.hpp"
@@ -516,9 +517,9 @@ namespace Exiv2 {
return true ;
}
-#define REPORT_MARKER if ( option == kpsBasic ) out << Internal::stringFormat("%8ld | %#02x %-5s",io_->tell(), marker,nm[marker].c_str())
+#define REPORT_MARKER if ( (option == kpsBasic||option == kpsRecursive) ) out << Internal::stringFormat("%8ld | %#02x %-5s",io_->tell(), marker,nm[marker].c_str())
- void JpegBase::printStructure(std::ostream& out, PrintStructureOption option)
+ void JpegBase::printStructure(std::ostream& out, PrintStructureOption option,int depth)
{
if (io_->open() != 0) throw Error(9, io_->path(), strError());
// Ensure that this is the correct image type
@@ -570,7 +571,8 @@ namespace Exiv2 {
out << " address | marker | length | data" << std::endl ;
REPORT_MARKER;
}
- first = false;
+ first = false;
+ bool bLF = option == kpsBasic||option == kpsRecursive;
// Read size and signature
std::memset(buf.pData_, 0x0, buf.size_);
@@ -590,7 +592,7 @@ namespace Exiv2 {
){
size = getUShort(buf.pData_, bigEndian);
}
- if ( option == kpsBasic ) out << Internal::stringFormat(" | %7d ", size);
+ if ( option == kpsBasic||option==kpsRecursive ) out << Internal::stringFormat(" | %7d ", size);
// only print the signature for appn
if (marker >= app0_ && marker <= (app0_ | 0x0F)) {
@@ -637,15 +639,43 @@ namespace Exiv2 {
bufRead = size;
delete [] icc;
}
- } else if ( option == kpsBasic ) {
- out << "| " << Internal::binaryToString(buf,32,size>0?2:0);
+ } else if ( option == kpsBasic||option==kpsRecursive ) {
+ out << "| " << Internal::binaryToString(buf,size>32?32:size,size>0?2:0);
+ }
+
+ // for MPF: http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/MPF.html
+ if( (option == kpsRecursive && marker == (app0_+1) && std::strcmp(http,"Exif")==0 )
+ || (option == kpsRecursive && marker == (app0_+2) && std::strcmp(http,"MPF" )==0 )
+ ) {
+ // extract Exif data block which is tiff formatted
+ if ( size > 0 ) {
+ out << std::endl;
+
+ // allocate storage and current file position
+ byte* exif = new byte[size];
+ size_t restore = io_->tell();
+
+ // copy the data to memory
+ io_->seek(-bufRead , BasicIo::cur);
+ io_->read(exif,size);
+ std::size_t start = std::strcmp(http,"Exif")==0 ? 8 : 6;
+
+ // create a copy on write memio object with the data, then print the structure
+ BasicIo::AutoPtr p = BasicIo::AutoPtr(new MemIo(exif+start,size-start));
+ TiffImage::printTiffStructure(*p,out,option,depth);
+
+ // restore and clean up
+ io_->seek(restore,Exiv2::BasicIo::beg);
+ delete [] exif;
+ bLF = false;
+ }
}
}
// Skip the segment if the size is known
if (io_->seek(size - bufRead, BasicIo::cur)) throw Error(14);
- if ( option == kpsBasic ) out << std::endl;
+ if ( bLF ) out << std::endl;
if (marker == sos_)
// sos_ is immediately followed by entropy-coded data & eoi_
diff --git a/src/pngimage.cpp b/src/pngimage.cpp
index 6a4c8b4..79d34b9 100644
--- a/src/pngimage.cpp
+++ b/src/pngimage.cpp
@@ -48,6 +48,8 @@ EXIV2_RCSID("@(#) $Id$")
#include <iostream>
#include <cassert>
+#include <zlib.h> // To uncompress IccProfiles
+
// Signature from front of PNG file
const unsigned char pngSignature[8] = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
@@ -92,7 +94,47 @@ namespace Exiv2 {
return "image/png";
}
- void PngImage::printStructure(std::ostream& out, PrintStructureOption option)
+ static void zlibUncompress(const byte* compressedText,
+ unsigned int compressedTextSize,
+ DataBuf& arr)
+ {
+ uLongf uncompressedLen = compressedTextSize * 2; // just a starting point
+ int zlibResult;
+ int dos = 0;
+
+ do {
+ arr.alloc(uncompressedLen);
+ zlibResult = uncompress((Bytef*)arr.pData_,
+ &uncompressedLen,
+ compressedText,
+ compressedTextSize);
+ if (zlibResult == Z_OK) {
+ assert((uLongf)arr.size_ >= uncompressedLen);
+ arr.size_ = uncompressedLen;
+ }
+ else if (zlibResult == Z_BUF_ERROR) {
+ // the uncompressedArray needs to be larger
+ uncompressedLen *= 2;
+ // DoS protection. can't be bigger than 64k
+ if (uncompressedLen > 131072) {
+ if (++dos > 1) break;
+ uncompressedLen = 131072;
+ }
+ }
+ else {
+ // something bad happened
+ throw Error(14);
+ }
+ }
+ while (zlibResult == Z_BUF_ERROR);
+
+ if (zlibResult != Z_OK) {
+ throw Error(14);
+ }
+ }
+
+
+ void PngImage::printStructure(std::ostream& out, PrintStructureOption option, int /*depth*/)
{
if (io_->open() != 0) {
throw Error(9, io_->path(), strError());
@@ -104,7 +146,7 @@ namespace Exiv2 {
throw Error(3, "PNG");
}
- if ( option == kpsIccProfile || option == kpsRecursive ) {
+ if ( option == kpsRecursive || option == kpsIccProfile ) { // disable kpsIccProfile because decompress isn't working!
throw Error(13, io_->path());
}
@@ -112,7 +154,7 @@ namespace Exiv2 {
chType[0]=0;
chType[4]=0;
- if ( option == kpsBasic || option == kpsXMP ) {
+ if ( option == kpsBasic || option == kpsXMP || option == kpsIccProfile ) {
if ( option == kpsBasic ) {
out << "STRUCTURE OF PNG FILE: " << io_->path() << std::endl;
@@ -154,24 +196,38 @@ namespace Exiv2 {
}
if ( option == kpsBasic ) out << Internal::stringFormat("%8d | %5d | %10s |%8d | ",(uint32_t)address, index++,chType,dOff) << dataString << std::endl;
- // for XMP, back up and read the whole block
+
+ // for XMP and ICC, back up and read the whole block
const char* key = "XML:com.adobe.xmp" ;
size_t start = ::strlen(key);
- if ( option == kpsXMP && dataString.find(key)==0 ) {
+ if( (option == kpsXMP && dataString.find(key)==0)
+ || (option == kpsIccProfile && std::strcmp(chType,"iCCP")==0)
+ ){
#if defined(_MSC_VER)
io_->seek(-static_cast<int64_t>(blen) , BasicIo::cur);
#else
io_->seek(-static_cast<long>(blen) , BasicIo::cur);
#endif
dataOffset = dOff ;
- byte* xmp = new byte[dataOffset+5];
- io_->read(xmp,dataOffset+4);
- xmp[dataOffset]=0;
- while ( xmp[start] == 0 ) start++; // crawl over the '
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list