How to get and change image metadata in Linux

Image metadata is information that is embedded into files like jpeg, tiff, and other common formats. The primary form of metadata used in photos is called EXIF (Exchangeable Image File Format). This data can contain supplemental information for the image, such as the date and time that the photo was taken, with what camera model, GPS info, author, copyright information, and more.

This kind of metadata comes in handy when you need to determine additional information about an image, such as who the original author is. It is also possible to manually add or edit metadata to an image file. In this tutorial, you will learn how to get and change image metadata on a Linux system. This can be accomplished from the command line with the ExifTool program. We will cover usage examples below.

In this tutorial you will learn:

  • What is image EXIF metadata?
  • How to install ExifTool on major Linux distros
  • How to use ExifTool to get and change image metadata
How to get and change image metadata in Linux
How to get and change image metadata in Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software ExifTool
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Get and change image metadata – command line




You have a few options when it comes to handling EXIF metadata for images on the command line. One of our favorite tools for the job is ExifTool, which can be easily installed on all major Linux distros. Let’s first start by installing the program.

How to install ExifTool

You can use the appropriate command below to install ExifTool with your system’s package manager.

To install ExifTool on Ubuntu, Debian, and Linux Mint:

$ sudo apt install libimage-exiftool-perl

To install ExifTool on Fedora, CentOS, AlmaLinux, and Red Hat:

$ sudo dnf install perl-Image-ExifTool

To install ExifTool on Arch Linux and Manjaro:

$ sudo pacman -S perl-image-exiftool

ExifTool usage examples

Now that ExifTool has been installed, let’s see how to use the command in order to get and change image metadata. Check out some of the examples below and adapt them to fit your own situation as needed.

  1. To see all of the metadata for an image, just use the exiftool command and specify the file name of your image.
    $ exiftool image.jpg
    

    ExifTool showing all the EXIF metadata for our image
    ExifTool showing all the EXIF metadata for our image



  2. You can also get the metadata for multiple images at once:
    $ exiftool image1.jpg image2.jpg image3.jpg
    OR
    $ exiftool image*.jpg
    
  3. To see the metadata for a specific EXIF field, you can enter the field you want to see as an option passed to exiftool. For example, to see the camera model that was used to capture an image:
    $ exiftool -model image.jpg 
    Camera Model Name               : iPhone 12 Pro Max
    
  4. To edit the metadata of an image, specify the field or fields you wish to modify, along with what information you want to insert. For example, to add information to the Author field:
    $ exiftool -author="linuxconfig" image.jpg 
        1 image files updated
    
  5. You can also edit multiple fields simulataneously. For example, let’s edit the author and title metadata fields:
    $ exiftool -author="linuxconfig" -title="Linux penguin" image.jpg 
        1 image files updated
    
  6. In case you need to remove the data from a field, use the same syntax as above but do not specify any information:
    $ exiftool -author= image.jpg
    
  7. You can also remove all of the metadata from an image file:
    $ exiftool -all= image.jpg
    

Closing Thoughts




In this tutorial, we saw how to get and change image metadata on a Linux system. This is accomplished with the ExifTool command line program, which can be installed from the official software repositories on all major Linux distros. We have covered a lot of the essential usage of exiftool in this tutorial, but you should check the manual page for further options.



Comments and Discussions
Linux Forum