|Original author(s)||Andreas Huggel|
|Developer(s)||Andreas Huggel, Alan Pater, Dan Fandrich, Harry McKame, Ben Touchette, Adam Hooper, Thomas Beutlich, Wil Cowb and others|
|Operating system||Linux, macoS|
|Type||Image metadata manipulation|
exiv2 is a console image metadata viewer and editor capable of reading, writing and manipulating Exif, IPTC and XMP metadata. It supports all the common image formats such as jpeg, exv, cr2, crw, tiff, webm, png, bmp and many more. It is also available as a C++ library you can use to easily provide metadata-editing capabilities to any free software program. exiv2 is a great go-to Swiss army knife type tool for all image metadata manipulation.
exiv2 is a Swiss army knife for photo metadata. It is capable of doing everything in that particular area. It is a command-line program, and it is, as such, not all that easy or strait-forward to use the more advanced editing capabilities. You will have to read or skim the somewhat long manual page if you want to utilize its full potential.
Just viewing a brief summery of what, if any, metadata is embedded into an image file is as easy as:
That command will show the file name, size MIME type, image resolution and, if present, some of the metadata included in filename.jpg.
exiv2 -pa filename.jpg will give you a list of all the metadata embedded in an image file.
p is short for print and
a tells the print feature to show all Exif, IPTC and XMP metadata.
Editing And Manipulating Photo Metadata
exiv2 to modify metadata is a bit harder. This can be done in two ways: You can either use
exiv2 -M and provide a list commands, keys and values OR make a text file with the commands you would like to have applied to your image(s) and tell
exiv2 about that file by running
exiv2 -m manipulation-commands.txt filename.jpg
Using a separate file is easier, specially if you want to add several typically the same keys to an image. You can combine
-M if you want to apply a series of metadata keys to all your images and add one or more per-image tags to each image.
Applying or changing a photo metadata key requires you to give one of the following commands:
|add||add new metadata to an image (will not change keys if they exist)|
|set||will either add metadata or change metadata if a key already exists|
|del||removes a metadata key if one exists|
del requires you to provide a
key, preferably a
value type and the actual
value you would like to set. You do not have to provide the right kind of
exiv2 will try to figure out what to use if you do not provide one.
You will have to look up what
key needs what
value type in the schema that provides the
key you want to use. As an example, the
creator tag in the Dublin Core (dc) XMP schema should have the
seq ProperName value type that is, by exiv2, called
XmpSeq. Adding a creator tag to an image can be done by using these command-line parameters:
exiv2 -M"set Xmp.dc.creator XmpSeq LinuxReviews.org" filename.jpg
-M option seems easy enough if you just want to add or change one tag. Changing more requires you to add multiple
-M commands like:
exiv2 -M"set Xmp.dc.creator XmpSeq LinuxReviews.org" -M"set Xmp.xmpRights.UsageTerms LangAlt Public Domain filename.jpg
You can probably see how that becomes very cumbersome if you want to add or remove a lot of metadata tags.
Using A Command File To Manipulate Image Metadata
the gwenview image viewer showing some photo metadata that has been added to it using exiv2.
Using a file to add a series of tags is preferable if you want to add tags images created by a program that won't let you edit them (like the GNU Image Manipulation Program) on a regular basis. Here is an example you can base your own command file on:
The above long lists of commands add some metadata that are useful both when uploading images to content management systems like MediaWiki, who do not strip them, and a limited number of search engines such as Google Image Search.
You can make
exiv2 use the above command file by running
exiv2 -m /path/to/command-file.txt your_photo.jpg
You could, alternatively, place
$HOME/bin and create a simple one-liner bash-script:
Such a script would allow you to change metadata of an image to your standards by running
You can combine
-m command_file.txt with
-M"add key value" if you want to add a series of standard commands and a key or two specific to the image you are working on.
exiv2 lets you set language-specific tags for any key using
The gwenview photo viewer showing a photo of the k-pop group Rockit Girl with a "special" IPTC metadata tag that is added to all images uploaded to Facebook and other platforms they own such as Instagram. They use this key to track images hosted by their platforms that are re-used on and off their platforms.
Removing image metadata using
exiv2 can be done by running a series of
del commands listing individual keys you would like to remove. First, run
exiv2 -pa file_name.jpg to see what keys are present and eradicate them with something like:
exiv2 -M"del Xmp.dc.rights" -M"del Exif.Image.Make" -M"del Exif.Image.Model"
Removing individual tags like that is obviously both foolish and very tiresome if you want to get rid of all the incriminating evidence berried within an images metadata. Luckily, there's a
--delete option available that allows you to quickly get rid of:
|a||all supported metadata (the default)|
|t||Exif thumbnail only|
|I||All IPTC data|
The most useful of the
--delete commands is probably
a (you have to provide it even if it is the "default").
exiv2 -d a file_name.jpg
will eradicate all the metadata from
file_name.jpg. Do note that this will not eradicate other information such as the sRGB profile information embedded into jpeg images. A file created by GIMP will still retain information like
Profile Description: GIMP built-in sRGB and the same is true for pictures taken with some cameras.
Image File Formats Supported By Exiv2
|Image Formats Supported By Exiv2|
|Type||Exif||IPTC||XMP||Image Comments||ICC Profile|
Verdict And Conclusion
exiv2 is the best and most complete command-line tool for manipulating photo metadata. It is not all that easy to use if you don't know how but it is also not that hard to learn how to harness its power. You will hopefully have an idea how to use it after reading or skimming this page.
- Website: exiv2.org
- Book (online): Exiv2 C++ metadata library: Image Metadata and Exiv2 Architecture by Robin Mills
- Manpage: exiv2.1
- Rate this article: