Exif

From HerzbubeWiki
Jump to: navigation, search

This page contains information about the image metadata format Exif ("Exchangeable Image File Format"). Also see the wiki pages about IPTC and XMP.


References


Intended Exif usage

This discussion in the Aperture forum on discussions.apple.com asks the question:

Is it better to use the IPTC caption instead of the EXIF user comment field?


The answers are quite illuminating and point to IPTC rather unambiguously. The best answer is this (term explanations in brackets added by me) :

EXIF metadata is generally organized to reflect information about the digital image capture - information about the camera, settings, etc. EXIF was a standard created by an organization representing camera mfgs [mfg is short for "manufacturer"]. The IPTC standard was defined by news agencies in the early 90s to record data about an image - photog [photog is short for "photographer"], where, when, subject, + hundreds more. IPTC has been the generally accepted set of tags to use for data such as a comment.


Exiv2

Summary

Exiv2 is a C++ library and a command line utility to manage image metadata (Exif, IPTC and XMP). The website is

http://www.exiv2.org/

On my Mac I install Exiv2 via Homebrew. The remaining part of this section has a few command line examples.


Basic usage

Display nicely formatted summary of Exif metadata:

exiv2 pr /path/to/file

Display Exif, IPTC and XMP metadata:

exiv2 -pa pr /path/to/file

The previous command does NOT display the JPEG comment. After studying the man page, it appears to be impossible to display both the metadata and the JPEG comment with the same command line invocation. This is the command to display the standalone JPEG comment:

exiv2 -pc pr /path/to/file

Display raw Exif metadata

exiv2 -pv pr /path/to/file


Working with timestamps

Adjust the Exif timestamp:

# Add/subtract 1 day
exiv2 --keep --days 1 ad /path/to/file
# Add 7 hours
exiv2 --keep --adjust +07 ad /path/to/file

Discussion:

  • Without --keep both modification AND creation are updated. The reason is that a new file is created (at least the inode number changes).
  • With --keep both modification AND creation time remain unchanged. This works even though a new inode is created here, too.


Adjust the file timestamp to be the same as the Exif timestamp:

exiv2 --Timestamp /path/to/file

Discussion:

  • Generally this sets the modification time ONLY
  • Because of the Mac OS X behaviour of utimes(), this also sets the creation time if the new modification time is before the current creation time (the reasoning is that a file cannot be modified before it was created)


To view all sorts of file times on Mac OS X:

file="/path/to/file"; echo "ctime - inode change time - time when file status was last changed"; ls -ldc "$file"; echo "atime - time of last access"; ls -ldu "$file"; echo "mtime - time of last modification"; ls -ld "$file"; echo "? - time of file creation"; ls -ldU "$file"