Every multimedia whether in a form of image, audio, or video comes with specific information that we call metadata along with the basic media data. In short, metadata is data about data that provides the context of information such as source, type, owner, and permissions.
Normally, this metadata is kept hidden and you cannot view it in the default graphical applications. Hence, certain tools are being developed specifically to uncover this hidden meta information of media.
ExifTool – A Meta-Data Reader And Writer for Linux
ExifTool is one such free and open-source command line-based application that not just allows you to read meta-data information but also write and manipulate a variety of file types like TXT, PNG, JPEG, PDF, HTML, XMP, and many more.
You can even read and edit manufacturer-specific metadata format of many digital cameras as well such as Canon, Casio, DJI, FLIR, FujiFilm, Kodak, Leaf, Minolta/Konica-Minolta, Nikon, Nintendo, Olympus/Epson, Panasonic/Leica, Samsung, Sanyo, and Sony.
Here is the summary of the features of ExifTool:
- Powerful, fast, flexible, and customizable.
- Supports a large number of different file formats.
- Numerous output formatting options (including tab-delimited, HTML, XML, and JSON).
- Multi-lingual output.
- Geotags images from GPS track log files.
- Generates track logs from geotagged images.
- Shift date/time values to fix timestamps in images.
- Extracts thumbnail images, and preview images.
- Copies meta information between files (even different-format files).
- Custom user-defined tags.
Before we get to know how to use ExifTool in Linux for manipulating various media like audio, video, and images, let’s first install it.
Install ExifTool on Linux
$ wget https://exiftool.org/Image-ExifTool-12.56.tar.gz
Next, you need to unzip the archive file, navigate to an extracted archive directory and install it as shown.
$ tar xf Image-ExifTool-12.56.tar.gz $ cd Image-ExifTool-12.56 $ perl Makefile.PL $ make test $ sudo make install
Verify the successful installation by checking the ExifTool version using the command:
$ exiftool -ver
Manipulate Metadata Using ExifTool On Linux
Using ExifTool in a terminal is very easy. The only thing you need to do is type exiftool and provide a media path as an argument to read the metadata:
$ exiftool [OPTIONS] [-TAG...] [--TAG...] FILE...
Read Metadata of Images in Linux
The command will read and print all metadata of the media file ranging from file modification time, image height and width, and color type to megapixels.
$ exiftool ~/Pictures/NeoVim-Text-Editor.png
Instead of all metadata, you can also give a property name to get only a specified set of data in the below format:
$ exiftool -<option> <path-to-media>
List All ExifTool Tags
Exiftool provides a list parameter that displays all of the tags it supports.
$ exiftool --list
Using only the list parameter gives all output, so to limit the tag list to get only specified types of tags, you need to append a letter to the list parameter as shown below:
--listr– all recognized file extensions.
--listw– all writable tag names.
--listf– all supported file extensions.
--listwf– all writable file extensions.
--listg– all tag groups.
--listd– all deletable groups.
--listx– all tags, details, and translations in XML format.
For example, to list all the recognized file extensions, type:
$ exiftool --listr
Additionally, you can also edit the details of the tag that are not write-protected using the below syntax:
$ exiftool -<Tag>=<Value> <path-to-file>
As you can see in the above screenshot, we updated the PageCount tag to 5. Interestingly, instead of changing the original file metadata, ExifTool creates a new backup file with updated tag information. The new file was also renamed with an addition of the suffix “_original”.
If you want to delete the backup file created by ExifTool, you can use
$ exiftool -delete_original <path-to-originalfile>
ExifTool – Copy Files Into A New Folder
Apart from just editing metadata, you can also use ExifTool to copy or move several multimedia files into new directories based on year, month, or even day. To copy, use
“-o .” option which means copying over, and leaving the source files in place:
$ exiftool -o . '-Directory<CreateDate' -d <path-to-dest-dir> -r <path-to-source-dir>
To directly move, remove the
“-o .” option:
$ exiftool '-Directory<CreateDate' -d <path-to-dest-dir> -r <path-to-source-dir>
ExifTool – Export Tag List
In case, you intend to use the metadata tags for other purposes, ExifTool allows you to use various options to export results in the following different formats.
-csv– export to csv format.
-h– export to html format.
-json– export to json format.
-x– export to xml format.
Use any of the above options in the below format:
$ exiftool -json -FileName <filename>
For more details about ExifTool and its ability, you can explore its manual pages, which you can get using the command:
$ man exiftool
For command-line enthusiasts, ExifTools is a very powerful-yet-easy-to-use application for reading, writing, and editing metadata of multimedia. In addition, it allows copying, moving, and renaming multiple files at once.
Even, you can copy the metadata of a file to another and export the same to various formats like JSON to use for other purposes. You can explore its other options and tag manipulation on various other file types like PDFs and videos to know the usefulness and feasibility of ExifTools.