Skip to content

Commit ee31327

Browse files
authored
Merge pull request #989 from Exiv2/fix_987
Fix 987 (taglist.cpp changes)
2 parents 961409a + ca4396d commit ee31327

File tree

7 files changed

+179
-47
lines changed

7 files changed

+179
-47
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ endif()
105105
configure_file(cmake/exiv2.pc.in exiv2.pc @ONLY)
106106
install(FILES ${CMAKE_BINARY_DIR}/exiv2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
107107

108+
# ******************************************************************************
109+
# Man page
110+
install( FILES ${PROJECT_SOURCE_DIR}/man/man1/exiv2.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 )
111+
112+
108113
include(cmake/printSummary.cmake)
109114

110115
# That's all Folks!

README-SAMPLES.md

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,13 @@ Test conversions from string to long, float and Rational types.
482482
#### taglist
483483

484484
```
485-
Usage: taglist [--group name|Groups|Exif|Canon|CanonCs|CanonSi|CanonCf|Fujifilm|Minolta|Nikon1|Nikon2|Nikon3|Olympus|Panasonic|Pentax|Sigma|Sony|Iptc|dc|xmp|xmpRights|xmpMM|xmpBJ|xmpTPg|xmpDM|pdf|photoshop|crs|tiff|exif|aux|iptc]
485+
$ taglist --help
486+
Usage: taglist [--help]
487+
[--group name|
488+
Groups|Exif|Canon|CanonCs|CanonSi|CanonCf|Fujifilm|Minolta|Nikon1|Nikon2|Nikon3|Olympus|
489+
Panasonic|Pentax|Sigma|Sony|Iptc|
490+
dc|xmp|xmpRights|xmpMM|xmpBJ|xmpTPg|xmpDM|pdf|photoshop|crs|tiff|exif|aux|iptc|all|ALL
491+
]
486492
Print Exif tags, MakerNote tags, or Iptc datasets
487493
```
488494

@@ -494,7 +500,7 @@ The data from this program is formatted as HTML on the web-site. https://exiv2.
494500
For example, to show the binary definition of Group `Nikon3`:
495501

496502
```
497-
1516 rmills@rmillsmbp:~/gnu/github/exiv2/0.27-maintenance $ taglist Nikon3
503+
$ taglist Nikon3
498504
Version, 1, 0x0001, Nikon3, Exif.Nikon3.Version, Undefined, Nikon Makernote version
499505
ISOSpeed, 2, 0x0002, Nikon3, Exif.Nikon3.ISOSpeed, Short, ISO speed setting
500506
ColorMode, 3, 0x0003, Nikon3, Exif.Nikon3.ColorMode, Ascii, Color mode
@@ -511,15 +517,52 @@ We can see those tags being used:
511517

512518
```
513519
$ exiv2 -pa --grep Nikon3 http://clanmills.com/Stonehenge.jpg
514-
1519 rmills@rmillsmbp:~/gnu/github/exiv2/0.27-maintenance $ exiv2 -pa --grep Nikon3 http://clanmills.com/Stonehenge.jpg
515520
Exif.Nikon3.Version Undefined 4 2.11
516521
Exif.Nikon3.ISOSpeed Short 2 200
517-
1520 rmills@rmillsmbp:~/gnu/github/exiv2/0.27-maintenance $
518522
...
519523
```
520524

521525
This information is formatted (search Nikon (format 3) MakerNote Tags): [https://exiv2.org/tags-nikon.html](https://exiv2.org/tags-nikon.html)
522526

527+
#### taglist all
528+
529+
These options are provided to list every Exif tag known to Exiv2. The option `all` prints Group.Name for every tag. The option `ALL` print Group.Name followed by the TagInfo for that tag. For example:
530+
531+
```bash
532+
$ taglist all | grep ISOSpeed$
533+
Photo.ISOSpeed
534+
PanasonicRaw.ISOSpeed
535+
CanonCs.ISOSpeed
536+
CanonSi.ISOSpeed
537+
Casio2.ISOSpeed
538+
MinoltaCs5D.ISOSpeed
539+
MinoltaCs7D.ISOSpeed
540+
Nikon1.ISOSpeed
541+
Nikon2.ISOSpeed
542+
Nikon3.ISOSpeed
543+
Olympus.ISOSpeed
544+
Olympus2.ISOSpeed
545+
```
546+
547+
```bash
548+
$ taglist ALL | grep ISOSpeed,
549+
Photo.ISOSpeed, 34867, 0x8833, Photo, Exif.Photo.ISOSpeed, Long, This tag indicates the ISO speed value of a camera or input device that is defined in ISO 12232. When recording this tag, the PhotographicSensitivity and SensitivityType tags shall also be recorded.
550+
PanasonicRaw.ISOSpeed, 23, 0x0017, PanasonicRaw, Exif.PanasonicRaw.ISOSpeed, Short, ISO speed setting
551+
CanonCs.ISOSpeed, 16, 0x0010, CanonCs, Exif.CanonCs.ISOSpeed, SShort, ISO speed setting
552+
CanonSi.ISOSpeed, 2, 0x0002, CanonSi, Exif.CanonSi.ISOSpeed, Short, ISO speed used
553+
Casio2.ISOSpeed, 20, 0x0014, Casio2, Exif.Casio2.ISOSpeed, Short, ISO Speed
554+
MinoltaCs5D.ISOSpeed, 38, 0x0026, MinoltaCs5D, Exif.MinoltaCs5D.ISOSpeed, Short, ISO speed setting
555+
MinoltaCs7D.ISOSpeed, 28, 0x001c, MinoltaCs7D, Exif.MinoltaCs7D.ISOSpeed, Short, ISO speed setting
556+
Nikon1.ISOSpeed, 2, 0x0002, Nikon1, Exif.Nikon1.ISOSpeed, Short, ISO speed setting
557+
Nikon2.ISOSpeed, 6, 0x0006, Nikon2, Exif.Nikon2.ISOSpeed, Short, ISO speed setting
558+
Nikon3.ISOSpeed, 2, 0x0002, Nikon3, Exif.Nikon3.ISOSpeed, Short, ISO speed setting
559+
Olympus.ISOSpeed, 4097, 0x1001, Olympus, Exif.Olympus.ISOSpeed, SRational, ISO speed value
560+
Olympus2.ISOSpeed, 4097, 0x1001, Olympus, Exif.Olympus.ISOSpeed, SRational, ISO speed value
561+
Sony1MltCs7D.ISOSpeed, 28, 0x001c, MinoltaCs7D, Exif.MinoltaCs7D.ISOSpeed, Short, ISO speed setting
562+
```
563+
564+
565+
523566
[Sample](#TOC1) Programs [Test](#TOC2) Programs
524567

525568
<div id="tiff-test">

src/exiv2.1 renamed to man/man1/exiv2.1

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.\" First parameter, NAME, should be all caps
33
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
44
.\" other parameters are allowed: see man(7), man(1)
5-
.TH EXIV2 1 "May 22, 2019"
5+
.TH EXIV2 1 "Aug 25, 2019"
66
.\" Please adjust this date whenever revising the manpage.
77
.\"
88
.\" Some roff macros, for reference:
@@ -608,6 +608,57 @@ To register additional XMP namespaces, combine the command with:
608608
Empty lines and lines starting with \fB#\fP in a command file are
609609
ignored (comments). Remaining lines are commands as described above.
610610
.br
611+
612+
613+
.ne 40
614+
.SH EXIF TAGNAMES AND VALUES
615+
Exiv2 displays metadata tags and values.
616+
.sp 1
617+
The tag is a triplet of Family.Group.Tagname. The following groups are defined for the family Exif:
618+
.sp 1
619+
.nf
620+
GPSInfo Canon Fujifilm NikonLd1 OlympusFe1 Pentax
621+
Image CanonCf NikonLd2 OlympusFe2 PentaxDng
622+
Image2 CanonCs Nikon1 NikonLd3 OlympusFe3
623+
Image3 CanonF1 Nikon2 NikonMe OlympusFe4 Samsung2
624+
Iop CanonPa Nikon3 NikonPc OlympusFe5 SamsungPictureWizard
625+
MakerNote CanonPi NikonAFT NikonPreview OlympusFe6 SamsungPreview
626+
MpfInfo CanonPr NikonAf NikonSi01xx OlympusFe7
627+
Photo CanonSi NikonAf2 NikonSi02xx OlympusFe8 Sony1
628+
SubImage1 CanonTi NikonAf22 NikonSiD300a OlympusFe9 Sony1Cs
629+
SubImage2 NikonCb1 NikonSiD300b OlympusFi Sony1Cs2
630+
SubImage3 Casio NikonCb2 NikonSiD40 OlympusIp Sony1MltCs7D
631+
SubImage4 Casio2 NikonCb2a NikonSiD80 OlympusRd Sony1MltCsA100
632+
SubImage5 NikonCb3 NikonVr OlympusRd2 Sony1MltCsNew
633+
SubImage6 Minolta NikonCb4 NikonWt OlympusRi Sony1MltCsOld
634+
SubImage7 MinoltaCs5D NikonFi Sony2
635+
SubImage8 MinoltaCs7D NikonFl1 Olympus Panasonic Sony2Cs
636+
SubImage9 MinoltaCsNew NikonFl2 Olympus2 PanasonicRaw Sony2Cs2
637+
SubThumb1 MinoltaCsOld NikonFl3 OlympusCs Sony2Fp
638+
Thumbnail NikonIi OlympusEq Sigma SonyMinolta
639+
.fi
640+
.sp 1
641+
Exiv2 supports Exif 2.2 Standard Tags. Exiv2 also supports reading and writing manufacturer's MakerNote. The information in Exif.Photo.MakerNote is encoded as manufacturer's sub-records. For example, CanonCs are Camera Settings, NikonAf are Nikon Auto Focus records, NikonCb are Nikon Color Balance Records. Every tag is defined by a unique tagId (16 bit integer) which is unique within a Group.
642+
.sp
643+
You can query Exiv2 groups and tags with the sample program taglist which is documented in README-SAMPLES.md
644+
.sp
645+
.ne 20
646+
Exif Metadata values are defined in the Exif Standard. All data is an array of data elements. The Count defines the number elements in the array. All elements in an array have the same type.
647+
.sp 1
648+
.nf
649+
Type Explanation
650+
1 BYTE An 8-bit unsigned integer.
651+
2 ASCII 7-bit ASCII. NUL terminated.
652+
3 SHORT A 16-bit (2-byte) unsigned integer.
653+
4 LONG A 32-bit (4-byte) unsigned integer
654+
5 RATIONAL Two LONGs. Numerator, denominator.
655+
7 UNDEFINED An 8-bit byte.
656+
8 SSHORT A 16-bit (2-byte) signed integer.
657+
9 SLONG A 32-bit (4-byte) signed integer.
658+
10 SRATIONAL Two SLONGs. Numerator, denominator.
659+
.fi
660+
.sp
661+
The printing flag t = translated and is intended for human use. Scripts should never use translated values as they are localised and the format may change as Exiv2 evolves. The printing flag v reports the values recorded in the metadata and should be used by scripts.
611662
.ne 40
612663
.SH CONFIGURATION FILE
613664
Exiv2 can read an optional configuration file ~/.exiv2 on Unix systems and %USERPROFILE%\\exiv2.ini on Windows (using a Visual Studio build). Cygwin and MinGW/msys2 follow the unix convention and use ~/.exiv2 You can fine the location of the configuration file with the command:

samples/taglist.cpp

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,27 @@
1212

1313
#include <iostream>
1414
#include <string>
15+
#include <sstream>
1516

1617
using namespace Exiv2;
1718

1819
int main(int argc, char* argv[])
1920
{
21+
int rc = EXIT_SUCCESS;
22+
std::ostringstream out;
2023
try {
21-
int rc = 0;
24+
bool bHelp = false;
2225

2326
switch (argc) {
2427
case 2: {
2528
std::string item(argv[1]);
2629

30+
if ( item == "--help" ) {
31+
bHelp = true;
32+
break;
33+
}
34+
2735
if (item == "Groups") {
28-
/*
29-
https://cgit.kde.org/digikam.git/tree/core/libs/dmetadata/metaengine_exif.cpp#n1077
30-
const Exiv2::GroupInfo* gi = Exiv2::ExifTags::groupList();
31-
32-
while (gi->tagList_ != 0)
33-
{
34-
// NOTE: See BUG #375809 : MPF tags = exception Exiv2 0.26
35-
36-
if (QLatin1String(gi->ifdName_) != QLatin1String("Makernote"))
37-
{
38-
Exiv2::TagListFct tl = gi->tagList_;
39-
const Exiv2::TagInfo* ti = tl();
40-
41-
while (ti->tag_ != 0xFFFF)
42-
{
43-
tags << ti;
44-
++ti;
45-
}
46-
}
47-
48-
++gi;
49-
}
50-
*/
5136
const GroupInfo* groupList = ExifTags::groupList();
5237
if (groupList) {
5338
while (groupList->tagList_) {
@@ -58,6 +43,26 @@ int main(int argc, char* argv[])
5843
break;
5944
}
6045

46+
if (item == "all" || item == "ALL" ) {
47+
const GroupInfo* groupList = ExifTags::groupList();
48+
if (groupList) {
49+
std::string line;
50+
while (groupList->tagList_) {
51+
std::ostringstream tags;
52+
ExifTags::taglist(tags,groupList->groupName_);
53+
std::istringstream input(tags.str()) ;
54+
while (std::getline(input, line)) {
55+
std::cout << groupList->groupName_ << "."
56+
<< (item == "all" ? line.substr(0,line.find(",")) : line)
57+
<< std::endl;
58+
}
59+
groupList++;
60+
}
61+
}
62+
break;
63+
}
64+
65+
6166
if (item == "Exif") {
6267
ExifTags::taglist(std::cout);
6368
break;
@@ -78,6 +83,7 @@ int main(int argc, char* argv[])
7883
} catch (const AnyError&) {
7984
rc = 2;
8085
}
86+
std::cerr << "Unexpected argument " << argv[1] << std::endl;
8187

8288
break;
8389
}
@@ -88,12 +94,12 @@ int main(int argc, char* argv[])
8894
case 3: {
8995
std::string item(argv[1]);
9096
std::string name(argv[2]);
91-
rc = 1; // assume unhappy ending!
97+
rc = EXIT_FAILURE; // assume unhappy ending!
9298

9399
if (item == "--group") {
94100
if ( ExifTags::isExifGroup(name) ) {
95101
ExifTags::taglist(std::cout,name);
96-
rc = 0; // result is good
102+
rc = EXIT_SUCCESS; // result is good
97103
} else {
98104
std::cerr << "warning:"
99105
<< name
@@ -109,7 +115,7 @@ int main(int argc, char* argv[])
109115
std::cout << tagInfo->name_ << std::endl;
110116
tagInfo++;
111117
}
112-
rc = 0; // result is good
118+
rc = EXIT_SUCCESS; // result is good
113119
}
114120
groupList++;
115121
}
@@ -119,21 +125,23 @@ int main(int argc, char* argv[])
119125
} break;
120126

121127
default:
122-
rc = 1;
123-
break;
128+
rc = EXIT_FAILURE;
129+
break;
124130
}
125131

126-
if (rc) {
127-
std::cout << "Usage: " << argv[0]
128-
<< " [--group "
129-
"name|Groups|Exif|Canon|CanonCs|CanonSi|CanonCf|Fujifilm|Minolta|Nikon1|Nikon2|Nikon3|Olympus|"
130-
"Panasonic|Pentax|Sigma|Sony|Iptc"
131-
<< "|dc|xmp|xmpRights|xmpMM|xmpBJ|xmpTPg|xmpDM|pdf|photoshop|crs|tiff|exif|aux|iptc]\n"
132-
<< "Print Exif tags, MakerNote tags, or Iptc datasets\n";
132+
if (rc || bHelp) {
133+
std::cout << "Usage: taglist [--help]" << std::endl
134+
<< " [--group name|" << std::endl
135+
<< " Groups|Exif|Canon|CanonCs|CanonSi|CanonCf|Fujifilm|Minolta|Nikon1|Nikon2|Nikon3|Olympus|" << std::endl
136+
<< " Panasonic|Pentax|Sigma|Sony|Iptc|" << std::endl
137+
<< " dc|xmp|xmpRights|xmpMM|xmpBJ|xmpTPg|xmpDM|pdf|photoshop|crs|tiff|exif|aux|iptc|all|ALL" << std::endl
138+
<< " ]" << std::endl
139+
<< "Print Exif tags, MakerNote tags, or Iptc datasets" << std::endl
140+
;
133141
}
134-
return rc;
135142
} catch (AnyError& e) {
136143
std::cout << "Caught Exiv2 exception '" << e << "'\n";
137-
return 1;
144+
rc = EXIT_FAILURE ;
138145
}
146+
return rc;
139147
}

src/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,5 @@ if(EXIV2_BUILD_EXIV2_COMMAND)
281281
install(TARGETS exiv2 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
282282
endif()
283283

284-
# ******************************************************************************
285-
# Man page
286-
install( FILES exiv2.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 )
287-
288284
# That's all Folks!
289285
##
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from system_tests import CaseMeta, path
4+
import zlib
5+
6+
class tagListTest(metaclass=CaseMeta):
7+
def compare_stdout(self, i, command, got_stdout, expected_stdout):
8+
lines = got_stdout.split('\n')
9+
count = len(lines);
10+
checksum = zlib.adler32(got_stdout.encode())
11+
new_got = "%s,%s" % (count, checksum)
12+
return super().compare_stdout(i, command, new_got, expected_stdout)
13+
14+
commands = ["$taglist --help",
15+
"$taglist all",
16+
"$taglist ALL",
17+
"$taglist Groups",
18+
"$taglist nothing",
19+
]
20+
stdout = ["8,198867862",
21+
"5426,1072295739",
22+
"5426,838787056",
23+
"107,430791180",
24+
"8,198867862",
25+
]
26+
27+
stderr = ["","","","","Unexpected argument nothing\n"]
28+
retval = [ 0,0, 0, 0, 2]

tests/suite.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ data_path: ../test/data
1717
tiff_test: ${ENV:exiv2_path}/tiff-test${ENV:binary_extension}
1818
largeiptc_test: ${ENV:exiv2_path}/largeiptc-test${ENV:binary_extension}
1919
easyaccess_test: ${ENV:exiv2_path}/easyaccess-test${ENV:binary_extension}
20+
taglist: ${ENV:exiv2_path}/taglist${ENV:binary_extension}
2021

2122
[variables]
2223
kerFailedToReadImageData: Failed to read image data

0 commit comments

Comments
 (0)