Fix exiv2 option --binary to enable report of long binary values.

This commit is contained in:
clanmills
2020-05-12 10:58:29 +01:00
parent deaed70f7c
commit 7515d85a09
2 changed files with 22 additions and 8 deletions
+3 -3
View File
@@ -2,7 +2,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 "May 11, 2020"
.TH EXIV2 1 "May 12, 2020"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@@ -132,7 +132,7 @@ exiv2 [ opt [arg] ]+ [ act ] file ...
.sp 1
option [arg] long option description
-a tim --adjust Modify time stamps. [+|-]HH[:MM[:SS[.mmm]]]
-b --binary Show large binary values (default is to suppress them).
-b --binary Show large binary values (default is to restrict them).
-c txt --comment JPEG comment string to set in the image ('modify' action). ...
-d tgt --delete Delete target(s) for the 'delete' action. ...
-D +-n --days Time adjustment by a positive or negative number of days ...
@@ -211,7 +211,7 @@ or 'm'(ute). The default log-level is 'w'. \fB\-Qm\fP is equivalent
to \fB\-q\fP. All log messages are written to standard error.
.TP
.B \-b
Show large binary values (default is to suppress them).
The output from large binary values is to restricted by default. When outputting the value of a large value such as MakerNote, the default behaviour is to restrict the data and end with "...". The option --binary enables you to see all the data.
.TP
.B \-u
Show unknown tags (default is to suppress tags which don't have a name).
+19 -5
View File
@@ -606,6 +606,16 @@ namespace Action {
return result ;
}
static void binaryOutput(bool suppressLong,const std::ostringstream& os)
{
const int dots = 100;
if ( suppressLong && os.str().length() > dots ) {
std::cout << os.str().substr(0,dots) << " ..." ;
} else {
std::cout << os.str();
}
}
bool Print::printMetadatum(const Exiv2::Metadatum& md, const Exiv2::Image* pImage)
{
if (!grepTag(md.key()))
@@ -689,21 +699,25 @@ namespace Action {
if (!first)
std::cout << " ";
first = false;
std::ostringstream os;
// #1114 - show negative values for SByte
if (md.typeId() != Exiv2::signedByte) {
std::cout << std::dec << md.value();
} else {
if (md.typeId() == Exiv2::signedByte) {
for ( int c = 0 ; c < md.value().count() ; c++ ) {
int value = md.value().toLong(c);
std::cout << (c?" ":"") << std::dec << (value < 128 ? value : value - 256);
os << (c?" ":"") << std::dec << (value < 128 ? value : value - 256);
}
} else {
os << std::dec << md.value();
}
binaryOutput(Params::instance().binary_,os);
}
if (Params::instance().printItems_ & Params::prTrans) {
if (!first)
std::cout << " ";
first = false;
std::cout << std::dec << md.print(&pImage->exifData());
std::ostringstream os;
os << std::dec << md.print(&pImage->exifData());
binaryOutput(Params::instance().binary_,os) ;
}
if (Params::instance().printItems_ & Params::prHex) {
if (!first)