exiv2
is a program to read and write Exif, IPTC, XMP metadata and
image comments and can read many vendor makernote tags. The program
optionally converts between Exif tags, XMP properties and IPTC
datasets as recommended by the Exif Standard, the IPTC Standard,
the XMP specification and Metadata Working Group guidelines.
The following image formats are supported:
Type | Exif | IPTC | XMP | Image Comments | ICC Profile |
EXV | Read/Write | Read/Write | Read/Write | Read/Write Read/Write | |
CR2 | Read/Write | Read/Write | Read/Write | - | Read/Write |
CRW | Read/Write | - | - | Read/Write | - |
MRW | Read | Read | Read | - | - |
TIFF | Read/Write | Read/Write | Read/Write | - | Read/Write |
WEBP | Read/Write | - | Read/Write | - | Read/Write |
DNG | Read/Write | Read/Write | Read/Write | - | Read/Write |
NEF | Read/Write | Read/Write | Read/Write | - | Read/Write |
PEF | Read/Write | Read/Write | Read/Write | - | Read/Write |
ARW | Read | Read | Read | - | - |
RW2 | Read | Read | Read | - | - |
SR2 | Read | Read | Read | - | - |
SRW | Read/Write | Read/Write | Read/Write | - | - |
ORF | Read/Write | Read/Write | Read/Write | - | - |
PNG | Read/Write | Read/Write | Read/Write | Read/Write | Read/Write |
PGF | Read/Write | Read/Write | Read/Write | Read/Write | Read/Write |
RAF | Read | Read | Read | - | - |
EPS | - | - | Read/Write | - | - |
XMP | - | - | Read/Write | - | - |
GIF | - | - | - | - | - |
PSD | Read/Write | Read/Write | Read/Write | - | - |
TGA | - | - | - | - | - |
BMP | - | - | - | - | - |
JP2 | Read/Write | Read/Write | Read/Write | - | Read/Write |
exiv2 [ opt [arg] ]+ [ act ] file ... option [arg] long option description -a tim --adjust Modify time stamps. [+|-]HH[:MM[:SS[.mmm]]] -b --binary Show large binary values (default is to restrict them). -c txt --comment JPEG comment string to set in the image ('modify' action). ... -d tgt --delete Delete target(s) for the 'delete' action. ... -D +-n --days Time adjustment by a positive or negative number of days ... -e tgt --extract Extract target(s) for the 'extract' action. -f --force Do not prompt before overwriting existing files ... -F --Force Do not prompt before renaming files (Force rename) ... -g key --grep Only output info for this Exiv2 key -h --help Display help and exit. -i tgt --insert Insert target(s) for the 'insert' action. ... -k --keep Preserve file timestamps when updating files -K key --key Report key. Similar to -g (grep) however key must match exactly. -l dir --location Location (directory) for files to be inserted or extracted. -m file --modify read commands from cmd-file -M cmd --Modify Command line for the 'modify' action. ... -n enc --encode Charset to decode Exif Unicode user comments. See: man 3 iconv_open -O +-n --months Time adjustment by a positive or negative number of months, ... -p mod --print Print report (common reports) -P flg --Print Print report (fine grained control) -q --quiet Silence warnings and error messages from the Exiv2 library ... -Q lvl --log Set the log-level to 'd'(ebug), 'i'(nfo), 'w'(arning), 'e'(rror) -r fmt --rename Filename format for the 'rename' action. ... -S suf --suffix Use suffix .suf for source files for insert command. -t --timestamp Set the file timestamp according to the Exif create timestamp ... -T --Timestamp Only set the file timestamp according to Exif create timestamp ... -u --unknown Show unknown tags ... -v --verbose verbose -V --version Show the program version and exit. -Y +-n --years Time adjustment by a positive or negative number of years ... act pr | ex | in | rm | ad | mo | mv | fi | fc print, extract, insert, delete, adjust, modify, rename, fixiso, fixcom cmd See "Commands" below. flg E | I | X | x | g | k | l | n | y | c | s | v | t | h Exif, IPTC, XMP, num, grp, key, label, name, type, count, size, vanilla, translated, hex fmt Default format is %Y%m%d_%H%M%S. lvl d | i | i | w | e debug, info, warning, error mod s | a | e | t | v | h | i | x | c | p | i | C | R | S | X summary, all, exif, translated, vanilla, hex, iptc, xmp, comment, preview, ICC Profile, Recursive Structure, Simple Structure, raw XMP tgt a | c | e | i | p | t | x | C | X | XX | - all, comment, exif, iptc, preview, thumb, xmp, ICC Profile, SideCar, RawXMP, stdin/out
$ 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
You may use -pmod filters to further filter output. For example:
$ bin/exiv2 -px -g Date http://clanmills.com/Stonehenge.jpg Xmp.xmp.ModifyDate XmpText 25 2015-07-16T20:25:28+01:00
The option -g (--grep) applies to keys and not values.
The key may finish with the optional modifier /i to indicate case insensitive.
$ 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
The options --force and --Force apply to the 'rename' command.
The 'extract' command treats --force and --Force as permission to
overwrite.
The default behaviour is to prompt the user.
-f = Do not prompt before overwriting existing files.
-F = Do not prompt before renaming files. Appends '_1'
('_2', ...) to the name of the new file. For example:
$ curl --silent -O http://clanmills.com/Stonehenge.jpg $ exiv2 --verbose --Force rename Stonehenge.jpg File 1/1: Stonehenge.jpg Renaming file to ./20150716_153854.jpg $ curl --silent -O http://clanmills.com/Stonehenge.jpg $ exiv2 --verbose --Force rename Stonehenge.jpg File 1/1: Stonehenge.jpg Renaming file to ./20150716_153854_1.jpg
The 'rename' command will only overwrite files when the option --force is used. The option --Force is provided to avoid unintentional loss of valuable image files.
The 'extract' command will overwrite files when either --force or --Force is used. Overwriting extracted files will not cause the loss of image files.
:basename: | original filename without extension |
:dirname: | name of the directory holding the original file |
:parentname: | name of parent directory |
s : print a summary of the Exif metadata (the default) | |
a : print Exif, IPTC and XMP metadata (shortcut for -Pkyct) | |
e : print Exif metadata (shortcut for -PEkycv) | |
t : interpreted (translated) Exif tags (-PEkyct) | |
v : plain Exif tag values (-PExgnycv) | |
h : hexdump of the Exif data (-PExgnycsh) | |
i : IPTC datasets (-PIkyct) | |
x : XMP properties (-PXkyct) | |
c : JPEG comment | |
p : list available image previews, sorted by preview image size in pixels | |
C : print image ICC Profile (jpg, png, tiff, webp, cr2, jp2 only) | |
R : print image structure recursively (jpg, png, tiff, webp, cr2, jp2 only) | |
S : print image structure information (jpg, png, tiff, webp, cr2, jp2 only) | |
X : print "raw" XMP (jpg, png, tiff, webp, cr2, jp2 only) |
E : include Exif tags in the list | |
I : IPTC datasets | |
X : XMP properties | |
x : print a column with the tag number | |
g : group name | |
k : key | |
l : tag label | |
n : tag name | |
y : type | |
c : number of components (count) | |
s : size in bytes | |
v : plain data value (vanilla values) | |
V : plain data value AND the word 'set ' (for use with exiv2 -m-) | |
t : interpreted (translated) human readable data | |
h : hexdump of the data |
a : all supported metadata (the default) | |
e : Exif section | |
t : Exif thumbnail only | |
i : IPTC data | |
x : XMP packet | |
c : JPEG comment | |
C : ICC Profile | |
I : All IPTC data |
X : Insert metadata from an XMP sidecar file <file>.xmp. The remaining insert targets determine what metadata to insert from the sidecar file. Possible are Exif, IPTC and XMP and the default is all of these. Note that the inserted XMP properties include those converted to Exif and IPTC.
XX: Insert "raw" XMP metadata from a sidecar (see option -pX)
- : Read from stdin. This option is intended for "filter" operations such as:
$ exiv2 -e{tgt}- filename | xmllint .... | exiv2 -i{tgt}- filename
Only JPEG thumbnails can be inserted (not TIFF thumbnails), and must be named file-thumb.jpg.
C : Extract embedded ICC profile to <file>.icc
X : Extract metadata to an XMP sidecar file <file>.xmp. The remaining extract targets determine what metadata to extract to the sidecar file. Possible are Exif, IPTC and XMP and the default is all of these.
XX: Extract "raw" XMP metadata to a sidecar (see -pX)
You may not use modify commands with the -eXX option and only XMP is written to the sidecar.
- Output to stdout (see -i tgt for an example of this feature)
$ exiv2 -m cmd.txt image.jpg
or given on the command line, as in
$ exiv2 -M"add Iptc.Application2.Credit String Mr. Smith" image.jpg
Note the quotes. Multiple -m and -M options can be combined, and a non-standard XMP namespace registered.
$ exiv2 -M"reg myprefix http://ns.myprefix.me/" -M"add Xmp.myprefix.Whom Mr. Smith" -M"set Exif.Image.Artist Mr. Smith" image.jpg
When writing Exif, IPTC and XMP metadata, exiv2 enforces only a correct metadata structure. It is possible to write tags with types and values different from those specified in the standards, duplicate Exif tags, undefined tags, or incomplete metadata. While exiv2 is able to read all metadata that it can write, other programs may have difficulties with images that contain non standard-conforming metadata.
set | add | del key [[type] value]
A default type is used if none is explicitly given. The default is determined based on key.
The value is optional. Not providing any value is equivalent to an empty value ("") and is mainly useful to create an XMP array property, e.g., a bag.
The format of Exif Comment values include an optional charset specification at the beginning. Comments are used by the tags Exif.Photo.UserComment, Exif.GPSInfo.GPSProcessingMethod and Exif.GPSInfo.GPSAreaInformation. Comments are stored as Undefined tags with an 8 byte encoding definition follow by the encoded data. The charset is specified as follows:
[charset=Ascii|Jis|Unicode|Undefined] comment
charset=Undefined is the default
$ exiv2 -M'set Exif.Photo.UserComment charset=Ascii My photo' x.jpg $ exiv2 -pa --grep UserComment x.jpg Exif.Photo.UserComment Undefined 16 My photo $ exiv2 -pv --grep UserComment x.jpg 0x9286 Photo UserComment Undefined 16 charset=Ascii My photo $ exiv2 -M'set Exif.Photo.UserComment charset=Unicode \u0052\u006f\u0062\u0069\u006e' x.jpg $ exiv2 -pa --grep UserComment x.jpg Exif.Photo.UserComment Undefined 18 Robin $ exiv2 -pv --grep UserComment x.jpg 0x9286 Photo UserComment Undefined 18 charset=Unicode Robin $ exiv2 -M'set Exif.GPSInfo.GPSProcessingMethod HYBRID-FIX' x.jpg $ exiv2 -pa --grep ProcessingMethod x.jpg Exif.GPSInfo.GPSProcessingMethod Undefined 18 HYBRID-FIX $ exiv2 -pv --grep ProcessingMethod x.jpg 0x001b GPSInfo GPSProcessingMethod Undefined 18 HYBRID-FIX
The format for an IPTC Date value is: YYYY-MM-DD (year, month, day)
The format for an IPTC Time value is: HH:MM:SS (hours, minutes, seconds) and may optionally be followed by: -HH:MM or +HH:MM (hours, minutes ahead/behind UTC)
The format of Rational (and SRational) is one of: integer | integer/integer | Fnumber | number
Rational Examples:
$ exiv2 "-Mset Exif.Photo.MaxApertureValue 557429/62500" X.jpg $ exiv2 "-Mset Exif.Photo.MaxApertureValue F5.6" X.jpg
The Rational format Fnumber is for the convenience of setting aperture values. Aperture values are stored in Exif is an APEX value which can be evaluated by the expression:
apex-value = log(Fnumber) * 2.0 / log(2.0) number = exp(apex-value * log(2.0) / 2.0)
The Rational format Fnumber is valid for any Rational, even when the key is not an Aperture. More information about APEX value is available from: http://en.wikipedia.org/wiki/APEX_system
The format of XMP LangAlt values includes an optional language qualifier:
lang=language-code text
lang="x-default" is used if the value doesn't start with a language qualifier.
$ exiv2 -M'set Xmp.dc.title lang="de-DE" Euros' X.jpg $ exiv2 -M'set Xmp.dc.title lang="en-GB" Pounds' X.jpg $ exiv2 -M'set Xmp.dc.title lang="en-US" In God We Trust' X.jpg $ exiv2 -M'set Xmp.dc.title All others pay cash' X.jpg
To remove a language specification, set the value to '' (empty string)
$ exiv2 -M'set Xmp.dc.title lang="en-US"' X.jpgTo remove all language specifications, delete the key:
$ exiv2 -M'del Xmp.dc.title' X.jpgTo register additional XMP namespaces, combine the command with:
reg prefix namespace
The tag is a triplet of Family.Group.Tagname. The following groups are defined for the family Exif:
GPSInfo Canon Fujifilm NikonLd1 OlympusFe1 Pentax Image CanonCf NikonLd2 OlympusFe2 PentaxDng Image2 CanonCs Nikon1 NikonLd3 OlympusFe3 Image3 CanonF1 Nikon2 NikonMe OlympusFe4 Samsung2 Iop CanonPa Nikon3 NikonPc OlympusFe5 SamsungPictureWizard MakerNote CanonPi NikonAFT NikonPreview OlympusFe6 SamsungPreview MpfInfo CanonPr NikonAf NikonSi01xx OlympusFe7 Photo CanonSi NikonAf2 NikonSi02xx OlympusFe8 Sony1 SubImage1 CanonTi NikonAf22 NikonSiD300a OlympusFe9 Sony1Cs SubImage2 NikonCb1 NikonSiD300b OlympusFi Sony1Cs2 SubImage3 Casio NikonCb2 NikonSiD40 OlympusIp Sony1MltCs7D SubImage4 Casio2 NikonCb2a NikonSiD80 OlympusRd Sony1MltCsA100 SubImage5 NikonCb3 NikonVr OlympusRd2 Sony1MltCsNew SubImage6 Minolta NikonCb4 NikonWt OlympusRi Sony1MltCsOld SubImage7 MinoltaCs5D NikonFi Sony2 SubImage8 MinoltaCs7D NikonFl1 Olympus Panasonic Sony2Cs SubImage9 MinoltaCsNew NikonFl2 Olympus2 PanasonicRaw Sony2Cs2 SubThumb1 MinoltaCsOld NikonFl3 OlympusCs Sony2Fp Thumbnail NikonIi OlympusEq Sigma SonyMinolta
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.
You can query Exiv2 groups and tags with the sample program taglist which is documented in README-SAMPLES.md
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.
Type Explanation 1 BYTE An 8-bit unsigned integer. 2 ASCII 7-bit ASCII. NUL terminated. 3 SHORT A 16-bit (2-byte) unsigned integer. 4 LONG A 32-bit (4-byte) unsigned integer 5 RATIONAL Two LONGs. Numerator, denominator. 7 UNDEFINED An 8-bit byte. 8 SSHORT A 16-bit (2-byte) signed integer. 9 SLONG A 32-bit (4-byte) signed integer. 10 SRATIONAL Two SLONGs. Numerator, denominator.
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.
YYYY:MM:DD HH:MM:SS
The exiv2 command-line program options -t and -T will accept files in which the Date has been incorrectly stored as YYYY-MM-DD. The option -a enables the user to adjust the DateTime in the file and applies the YYYY:MM:DD HH:MM:SS standard.
$ exiv2 --verbose --version --grep config_path exiv2 0.27.0.1 config_path=/Users/rmills/.exiv2
The purpose of the configuration file is to define your own lenses for recognition by Exiv2. The configuration file is in Windows .ini format and has sections for each of the major camera manufactures canon,nikon,pentax,minolta,olympus and sony. The lens metadata is stored as a integer called the lensID. You can change the lens name associated with any lensID.
$ cat ~/.exiv2 [nikon] 146=Robin's Sigma Lens <--- The name of your lens
You obtain the lensID for your camera with the command:
$ 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
$ exiv2 *.jpgPrints 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.
$ exiv2 -g Date http://clanmills.com/Stonehenge.jpg
$ exiv2 -pi image.jpgPrints the IPTC metadata of the image.
$ exiv2 rename img_1234.jpgRenames img_1234.jpg (taken on 13-Nov-05 at 22:58:31) to 20051113_225831.jpg
$ exiv2 -r':basename:_%Y%m' rename img_1234.jpgRenames img_1234.jpg to img_1234_200511.jpg
$ exiv2 -et img1.jpg img2.jpgExtracts the Exif thumbnails from the two files into img1-thumb.jpg and img2-thumb.jpg.
$ exiv2 -it img1.jpg img2.jpgInserts (copies) metadata from img1.exv to img1.jpg and from img2.exv to img2.jpg.
$ exiv2 -ep1,2 image.jpgExtracts previews 1 and 2 from the image to the files image-preview1.jpg and image-preview2.jpg.
$ exiv2 -eiX image.jpgExtracts IPTC datasets into an XMP sidecar file image.xmp and in the process converts them to "IPTC Core" XMP schema.
$ exiv2 -iixX image.jpgInserts IPTC and XMP metadata from an XMP sidecar file image.xmp into image.jpg. The resulting IPTC datasets are converted from the "IPTC Core" XMP schema properties in the sidecar file to the older IPTC IIM4 format. The inserted XMP properties include those in the "IPTC Core" XMP schema.
$ exiv2 -M"set Exif.Photo.UserComment charset=Ascii New Exif comment" image.jpgSets the Exif comment to an ASCII string.
$ exiv2 -M"set Exif.GPSInfo.GPSLatitude 4/1 15/1 33/1" \ -M"set Exif.GPSInfo.GPSLatitudeRef N" image.jpgSets the latitude to 4 degrees, 15 minutes and 33 seconds north. The Exif standard stipulates that the GPSLatitude tag consists of three Rational numbers for the degrees, minutes and seconds of the latitude and GPSLatitudeRef contains either 'N' or 'S' for north or south latitude respectively.
$ exiv2 insert -l/tmp -S.CRW /data/*.JPGCopy all metadata from CRW files in the /tmp directory to JPG files with corresponding basenames in the /data directory. Note that this copies metadata as is, without any modifications to adapt it to the requirements of the target format. Some tags copied like this may not make sense in the target image.
https://exiv2.org/sample.html#modifySample command files.
https://exiv2.org/metadata.htmlTaglists with key and default type values.