diff --git a/src/actions.cpp b/src/actions.cpp index 34a7a80d..68260186 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -243,7 +243,7 @@ namespace Action { int rc = 0; Exiv2::PrintStructureOption option = Exiv2::kpsNone ; switch (Params::instance().printMode_) { - case Params::pmSummary: rc = printSummary(); break; + case Params::pmSummary: rc = Params::instance().greps_.empty() ? printSummary() : printList(); break; case Params::pmList: rc = printList(); break; case Params::pmComment: rc = printComment(); break; case Params::pmPreview: rc = printPreviewList(); break; diff --git a/src/exiv2.1 b/src/exiv2.1 index 4f6f3b51..048f09af 100644 --- a/src/exiv2.1 +++ b/src/exiv2.1 @@ -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 "Apr 25, 2019" +.TH EXIV2 1 "May 8, 2019" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -222,19 +222,30 @@ Show unknown tags (default is to suppress tags which don't have a name). Only keys which match the given key (grep). .br Multiple \fB\-g\fP options -can be used to grep info for several keys. Example: +can be used to filter info to less keys. Example: exiv2 -v -V -g webready -g time. +The default exiv2 command prints a "summary report" which is quite short. When you use -g without a -pmod option, you do not get a summary report and in effect you get -g pattern -pa image ... .nf -exiv2 \-g Date \-pt R.jpg -Exif.Image.DateTime Ascii 20 2012:08:07 16:01:05 -Exif.Photo.DateTimeOriginal Ascii 20 2011:09:18 16:25:48 -Exif.Photo.DateTimeDigitized Ascii 20 2011:09:18 16:25:48 +$ bin/exiv2 -g Date http://clanmills.com/Stonehenge.jpg +Exif.Image.DateTime Ascii 20 2015:07:16 20:25:28 +Exif.Photo.DateTimeOriginal Ascii 20 2015:07:16 15:38:54 +Exif.Photo.DateTimeDigitized Ascii 20 2015:07:16 15:38:54 +Exif.NikonWt.DateDisplayFormat Byte 1 Y/M/D +Exif.GPSInfo.GPSDateStamp Ascii 11 2015:07:16 +Xmp.xmp.ModifyDate XmpText 25 2015-07-16T20:25:28+01:00 .fi --g (--grep) is only applied to keys. It is not generally applied to all output such as the default -ps report. +You may use -pmod filters to further filter output. For example: +.nf -The key may finish with the optional modifier /i to indicated case insensitive. +$ bin/exiv2 -px -g Date http://clanmills.com/Stonehenge.jpg +Xmp.xmp.ModifyDate XmpText 25 2015-07-16T20:25:28+01:00 + +.fi +The option -g (--grep) applies to keys and not values. + +The key may finish with the optional modifier /i to indicate case insensitive. .TP .B \-K \fIkey\fP Only report data for given key. @@ -243,8 +254,8 @@ Multiple \fB\-K\fP options can be used to report more than a single key. .nf exiv2 \-K Exif.Photo.DateTimeDigitized -K Exif.Photo.DateTimeOriginal \-pt R.jpg -Exif.Photo.DateTimeOriginal Ascii 20 2011:09:18 16:25:48 -Exif.Photo.DateTimeDigitized Ascii 20 2011:09:18 16:25:48 +Exif.Photo.DateTimeOriginal Ascii 20 2011:09:18 16:25:48 +Exif.Photo.DateTimeDigitized Ascii 20 2011:09:18 16:25:48 .fi .TP .B \-n \fIenc\fP @@ -594,17 +605,24 @@ You obtain the lensID for your camera with the command: .nf .sp 1 $ exiv2 -pv --grep lens/i http://clanmills.com/Stonehenge.jpg -0x0083 Nikon3 LensType Byte 1 14 -0x0084 Nikon3 Lens Rational 4 180/10 2500/10 35/10 63/10 -0x008b Nikon3 LensFStops Undefined 4 55 1 12 0 -0x000c NikonLd3 LensIDNumber Byte 1 146 <--- This number -0x000d NikonLd3 LensFStops Byte 1 55 +0x0083 Nikon3 LensType Byte 1 14 +0x0084 Nikon3 Lens Rational 4 180/10 2500/10 35/10 63/10 +0x008b Nikon3 LensFStops Undefined 4 55 1 12 0 +0x000c NikonLd3 LensIDNumber Byte 1 146 <--- This number +0x000d NikonLd3 LensFStops Byte 1 55 .br .ne 40 .SH EXAMPLES .TP exiv2 *.jpg -Prints a summary of the Exif information for all JPEG files in the directory. +Prints a summary of the Exif information for all JPEG files in the directory. The summary report is rather brief and presentation does not use the Family.Group.Tag convention. + +If you use --grep pattern, the default becomes -pa. See -g/grep above. + +.nf +$ exiv2 -g Date http://clanmills.com/Stonehenge.jpg + +.fi .TP exiv2 \-pi image.jpg Prints the IPTC metadata of the image. diff --git a/tests/bugfixes/github/test_issue_818.py b/tests/bugfixes/github/test_issue_818.py new file mode 100644 index 00000000..1e05b18a --- /dev/null +++ b/tests/bugfixes/github/test_issue_818.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +import system_tests + +class TestDefaultCommandGrep(metaclass=system_tests.CaseMeta): + + url = "https://github.com/Exiv2/exiv2/issues/818" + + filename = system_tests.path("$data_path/Reagan.jpg") + commands = [ + "$exiv2 -g Date $filename", + "$exiv2 -px -g Date $filename", + ] + retval = [0, 0] + stderr = [""] * 2 + retval = [0] * 2 + + stdout = [ + """Exif.Image.DateTime Ascii 20 2016:09:13 11:58:16 +Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53 +Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53 +Iptc.Application2.DateCreated Date 8 2004-06-21 +Iptc.Application2.DigitizationDate Date 8 2004-06-21 +Xmp.xmp.ModifyDate XmpText 25 2016-09-13T11:58:16+01:00 +Xmp.xmp.CreateDate XmpText 25 2004-06-21T23:37:53+01:00 +Xmp.xmp.MetadataDate XmpText 25 2016-09-13T11:58:16+01:00 +Xmp.photoshop.DateCreated XmpText 10 2004-06-21\n""", + """Xmp.xmp.ModifyDate XmpText 25 2016-09-13T11:58:16+01:00 +Xmp.xmp.CreateDate XmpText 25 2004-06-21T23:37:53+01:00 +Xmp.xmp.MetadataDate XmpText 25 2016-09-13T11:58:16+01:00 +Xmp.photoshop.DateCreated XmpText 10 2004-06-21\n""" + ]