How to add support for a new makernote

This page is a work in progress. For the moment it only documents the most common aspect of makernote maintenance:

Changes needed to add a new group to an existing makernote

Groups consist of tags from the same composite tag in the TIFF structure, e.g., a sub-IFD or binary arrays. While the standard Exif groups are well defined and don't change, makernotes and the community's understanding of them tend to evolve and adding new groups of makernote tags to an existing makernote is a fairly common task. The changes necessary to add a new group to the Exiv2 library are binary compatible.

Revision r2620 is a complete example for the changes discussed here and the filenames below are linked to the corresponding portions of that changeset.

The middle part of an Exif key is the group name. E.g., the group of the key Exif.NikonAFT.AFFineTune is NikonAFT.
Every group needs a unique identifier in enum IfdId. E.g., the IfdId which corresponds to group NikonAFT is nikonAFTId. (The type is called IfdId for historical reasons. Nowadays, it is used for all Exif groups, not only IFDs.)

Update the groupInfo[] table. This table links IFD id (GroupInfo::ifdId_), Group name (GroupInfo::groupName_) and taglists (GroupInfo::tagList_). Note that different groups can use the same taglist.

<MAKE> refers to the camera make, e.g., for Nikon makernotes, src/<MAKE>mn_int.hpp refers to the source file src/nikonmn_int.hpp.
Add a static function to access the tag list, similar to the existing functions.
Add a static const TagInfo array variable for the taglist.
By convention, pretty-print functions are declared here as well.

The taglists and pretty-print mappings and functions defined here describe the tags and how their values are interpreted.
Define the taglist array and the function to access the taglist. If the parent tag, which refers to or contains the group doesn't have an entry in the parent group table yet, add that as well (TagInfo(0x00b9, "AFTune", ... in the example).
If new pretty-print mappings are required, define them here as well and use the EXV_PRINT_TAG macro in the print function field of the taglist array. If new pretty-print functions are required, define them here. See existing code for plenty of examples.

The configurations in this file describe how to decode and encode the tags from/to the binary makernote.
Update the TiffCreator::tiffTreeStruct_[] and TiffCreator::tiffGroupStruct_[] tables. In tiffTreeStruct_[], the new group must be added with its parent group and parent tag to define where in the TIFF tree it belongs to. (The root element is also listed to specify which TIFF tree(s) it is found in.)
tiffGroupStruct_[] describes the layout of the new group. Specify the tag in the parent group, which refers to the new group together with the respective composite TIFF component and for each tag of the group itself, which TIFF component is to be used to parse (read and write) it. Refer to the comments in the code and the existing table for more info and plenty of examples. The sample linked above also defines ArrayCfg and ArrayDef structures. These are only required for binary array components, to configure the component for the new group.

Finally, compile and test the library with the changes. In addition to simple read-tests, please also test if writing a tag in each new group works as expected.


The tag reference documentation is generated automatically, it requires just a trigger in the Makefile and an updated template.

Add the name of the new group to the TABLES variable.

Add a section for the new group, similar to existing sections.

Updated by Andreas Huggel over 7 years ago ยท 16 revisions