From dc4ae73013ba7e24a54e07119a27be5394bd44aa Mon Sep 17 00:00:00 2001 From: Peter Date: Tue, 12 Jul 2022 15:31:43 +0100 Subject: [PATCH] Add tag description option to exiv2 app (#2279) * Add `tagDesc()` to (Exif|Xmp|Iptc) Datums and Keys * Add `--Print d` option to exiv2 app * Add testing for all exiv2 application `--Print` options * Update manpage --- app/actions.cpp | 6 ++++ app/exiv2.cpp | 13 +++++--- app/exiv2app.hpp | 3 +- exiv2.md | 31 +++++++++---------- include/exiv2/datasets.hpp | 1 + include/exiv2/exif.hpp | 1 + include/exiv2/iptc.hpp | 1 + include/exiv2/metadatum.hpp | 4 +++ include/exiv2/properties.hpp | 1 + include/exiv2/tags.hpp | 3 +- include/exiv2/xmp_exiv2.hpp | 1 + src/datasets.cpp | 4 +++ src/exif.cpp | 4 +++ src/iptc.cpp | 4 +++ src/properties.cpp | 7 +++++ src/xmp.cpp | 4 +++ test/data/test_reference_files/exiv2-test.out | 9 ++++-- tests/bash_tests/test_pr_2279.py | 21 +++++++++++++ 18 files changed, 92 insertions(+), 26 deletions(-) create mode 100644 tests/bash_tests/test_pr_2279.py diff --git a/app/actions.cpp b/app/actions.cpp index 1f5502dd..0cb99382 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -498,6 +498,12 @@ bool Print::printMetadatum(const Exiv2::Metadatum& md, const Exiv2::Image* pImag first = false; std::cout << std::setw(30) << std::setfill(' ') << std::left << md.tagLabel(); } + if (Params::instance().printItems_ & Params::prDesc) { + if (!first) + std::cout << " "; + first = false; + std::cout << std::setw(30) << std::setfill(' ') << std::left << md.tagDesc(); + } if (Params::instance().printItems_ & Params::prType) { if (!first) std::cout << " "; diff --git a/app/exiv2.cpp b/app/exiv2.cpp index 6f04e6e3..12e1d434 100644 --- a/app/exiv2.cpp +++ b/app/exiv2.cpp @@ -283,14 +283,16 @@ void Params::help(std::ostream& os) const { << _(" X : Extract \"raw\" XMP\n") << _(" -P flgs Print flags for fine control of tag lists ('print' action):\n") << _(" E : Exif tags\n") << _(" I : IPTC tags\n") << _(" X : XMP tags\n") - << _(" x : Tag number (Exif and IPTC only)\n") + << _(" x : Tag number for Exif or IPTC tags (in hexadecimal)\n") << _(" g : Group name (e.g. Exif.Photo.UserComment, Photo)\n") << _(" k : Key (e.g. Exif.Photo.UserComment)\n") << _(" l : Tag label (e.g. Exif.Photo.UserComment, 'User comment')\n") + << _(" d : Tag description\n") << _(" n : Tag name (e.g. Exif.Photo.UserComment, UserComment)\n") << _(" y : Type\n") - << _(" c : Number of components (count)\n") - << _(" s : Size in bytes (Ascii and Comment types include NULL)\n") - << _(" v : Plain data value, untranslated (vanilla)\n") + << _(" y : Type\n") << _(" c : Number of components (count)\n") + << _(" s : Size in bytes of vanilla value (may include NULL)\n") + << _(" v : Plain data value of untranslated (vanilla)\n") + << _(" V : Plain data value, data type and the word 'set'\n") << _(" t : Interpreted (translated) human readable values\n") << _(" h : Hex dump of the data\n") << _(" -d tgt1 Delete target(s) for the 'delete' action. Possible targets are:\n") @@ -720,6 +722,9 @@ int Params::evalPrintFlags(const std::string& optArg) { case 'V': printItems_ |= prSet | prKey | prType | prValue; break; + case 'd': + printItems_ |= prDesc; + break; default: std::cerr << progname() << ": " << _("Unrecognized print item") << " `" << i << "'\n"; rc = 1; diff --git a/app/exiv2app.hpp b/app/exiv2app.hpp index 5c278f9a..02fd72fc 100644 --- a/app/exiv2app.hpp +++ b/app/exiv2app.hpp @@ -151,7 +151,8 @@ class Params : public Util::Getopt { prValue = 256, prTrans = 512, prHex = 1024, - prSet = 2048 + prSet = 2048, + prDesc = 4096 }; //! Enumerates common targets, bitmap diff --git a/exiv2.md b/exiv2.md index 6049327f..86dd7fd2 100644 --- a/exiv2.md +++ b/exiv2.md @@ -566,34 +566,33 @@ as well as data columns included in the print output. Valid flags are: | g | Group name (e.g., for Exif.Photo.UserComment, outputs Photo) | | k | Key (e.g., Exif.Photo.UserComment) | | l | Tag label (human-readable tagname, e.g., for Exif.Photo.UserComment, outputs 'User comment') | -| n | Tagname (e.g., for Exif.Photo.UserComment, outputs UserComment) | +| d | Tag description | +| n | Tag name (e.g., for Exif.Photo.UserComment, outputs UserComment) | | y | Type (for available types, see [Exif/IPTC/XMP types](#exiv2_types)) | | c | Number of components (for single entry types, the number of **sizeof('type')** in 'size'. For multi-entry types, the number of entries. See [Exif/IPTC/XMP types](#exiv2_types)) | | s | Size in bytes of vanilla output (see note in [Exif 'Comment' values](#exif_comment_values)). Some types include a *NULL* character in the size (see [Exif/IPTC/XMP types](#exiv2_types)) | | v | Plain data value (vanilla values, i.e., untranslated) | -| V | Plain data value, data type and the word 'set ' (see ['MODIFY' COMMANDS](#modify_cmds))| +| V | Plain data value, data type and the word 'set' (see ['MODIFY' COMMANDS](#modify_cmds))| | t | Interpreted (translated) human-readable data values (includes plain vanilla values) | | h | Hex dump of the data | +**--Print** *flgs* can be combined with [--grep str](#grep_str) or +[--key key](#key_key) to further filter the output. +