Ali Gunes Blog

Ali Ihsan Gunes

Jun 03, 2025 • 4 min read

Managing Image Metadata with Exiv2

Image files are not just visual content—they often contain valuable metadata such as camera information, timestamps, author details, and copyright data. Exiv2 is a powerful command-line tool that allows you to read, edit, and remove metadata from image files.

In this post, we'll walk through how to install and use Exiv2 effectively on Linux systems, including examples for reading, modifying, and bulk-editing metadata.

What is Exiv2?

Exiv2 is a lightweight and efficient tool that works with a wide range of image formats such as JPG, PNG, TIFF, WebP, CR2, and NEF. It supports:

Installation

On Debian-based systems (like Ubuntu and Kali Linux), you can install Exiv2 with:

sudo apt update sudo apt install exiv2

Reading Metadata

Basic metadata information:

exiv2 image.jpg

Detailed metadata (EXIF, IPTC, and XMP):

exiv2 -p a image.jpg

This provides a complete breakdown of all metadata segments.

Writing / Editing Metadata

Set image description (title):

exiv2 -M"set Exif.Image.ImageDescription TestPhotoByAliGunes" image.jpg

Set artist name:

exiv2 -M"set Exif.Image.Artist AliGunes" image.jpg

Set copyright notice:

exiv2 -M"set Exif.Image.Copyright © 2025 AliGunes" image.jpg

The -M flag allows for direct modification of metadata and supports multiple operations in sequence.

Removing Metadata

Delete all metadata from an image:

exiv2 rm image.jpg

Delete a specific metadata field (e.g., artist):

exiv2 -M"del Exif.Image.Artist" image.jpg

Batch Operations

Remove metadata from all .jpg files in a directory:

exiv2 rm *.jpg

List capture dates for all images:

for i in *.jpg; do exiv2 -pt "$i"; done

Displaying Capture Date

To view the date a photo was taken:

exiv2 -pt image.jpg | grep Date

This filters out timestamp-related metadata only.

Example Use Case

Set title, artist, and copyright info on a photo in one command:

exiv2 -M"set Exif.Image.ImageDescription Vacation_Photo" \
-M"set Exif.Image.Artist JohnDoe" \
-M"set Exif.Image.Copyright © 2025 JohnDoe" \
image.jpg

Exiv2 modifies only the metadata—it does not alter or degrade the image content itself.

Exiv2 is an essential tool for photographers, archivists, developers, and privacy-conscious users. It offers a fast and scriptable way to manage image metadata directly from the terminal.

Whether you're organizing a large photo archive, tagging important images, or clearing sensitive information before sharing, Exiv2 makes the process clean and efficient.