Deleting metadata from files

Housekeeping

© Photo by Robert Linder on Unsplash

© Photo by Robert Linder on Unsplash

Author(s):

Digital camera images often reveal personal information embedded in metadata. Several Linux tools let you remove unwanted metadata to help preserve your privacy.

The progressive digitalization of all areas of life makes it difficult to cope with the growing flood of data. Many users like to share photos taken with their smartphones or webcams, music and video files, and even PDF documents on the Internet. However, all of these file formats contain metadata that can be read with various programs and often reveals private information about the file's creator. Before you publish files on the Internet, you should first check for unwanted metadata and remove sensitive information to protect your privacy. This article looks at some Linux tools that will help you delete metadata from your files at the push of a button.

The Purpose of Metadata

Metadata is usually generated on the basis of defined specifications and intended to record certain characteristics of the files concerned. For example, in the case of image and video files, this metadata includes the camera model and the photo's technical settings. Often the metadata also includes time and date stamps and – if supported and activated on the hardware side – the GPS coordinates where the photo was taken. For all file formats, the author can also be listed in the metadata to make it easier to prove copyright infringements. In addition, the metadata can be used to keyword the files in order to categorize them and make them easier to find in applications such as image collections.

Standards

For video and image files, Exif, IPTC, and XMP are the standards for generating metadata. The respective data can be found in fixed data fields in the files' headers.

The International Press Telecommunications Council – Information Interchange Model (IPTC-IIM) specification [1] was defined as early as 1991 and can be used for all digital media.

More targeted to technical details, the much younger Exchangeable Image File Format (Exif) standard [2] is used on almost all common smartphones and digital cameras to provide images with metadata. Exif's last specification dates from 2010 and was last revised in 2019.

The Extensible Metadata Platform (XMP) [3] container format, similar to Exif, primarily maps the metadata for image files. However, XMP, which was developed by Adobe about 20 years ago, can also store free text and is therefore popular with applications such as Lightroom or darktable. All Adobe products support XMP.

Reading and Editing

Reading metadata does not require any special application software: The file managers of all common desktop interfaces can handle the existing standards. The file managers usually show some of the identified metadata when you view a file, for example, in an image viewer. In many cases, you can also display the most important metadata in a context menu in the respective file manager's Properties dialog (Figure 1). However, to edit metadata, you need special applications that usually focus on one of the existing specifications.

Figure 1: A conventional file manager can reveal information about a wide variety of file formats on Linux.

ExifTool

The cross-platform ExifTool [4] has become the quasi-standard for editing metadata. The command-line tool has a powerful command set and can handle a wide variety of image and video formats. ExifTool's developers provide an easily understandable table [5] that lists the editing options for each format.

ExifTool can be found in the repositories of most common Linux distributions; consequently, it can usually conveniently be set up via the respective package manager. After installing ExifTool, in the simplest case, you can display a file's existing Exif data by entering the command:

exiftool FILE

The application takes all the existing metadata into account, so the output is usually quite long and confusing (Figure 2).

Figure 2: Working from the command line, ExifTool lists existing metadata in detail.

To save the most important metadata separately, redirect the output to a text file (Listing 1, line 1). In addition to the metadata, the Exif tags are also included in the file. To edit individual Exif tags, use the command from line 2 and then verify the modified tag with the command from line 3. As a result, you get a single line with the desired Exif tag and its value. If you want to delete all the tags to protect your privacy prior to publishing an image on the Internet, enter the command from the line 4 at the prompt.

Listing 1

Typical ExifTool Commands

01 $ exiftool --common FILE FILE.txt
02 $ exiftool -EXIF TAG='TAG CONTENT' FILE
03 $ exiftool --EXIF TAG FILE
04 $ exiftool -all=FILE

jExifToolGUI

Due to the complexity of the editing options and the large volume of metadata, ExifTool requires a longer learning curve. It is far easier to edit metadata using the jExifToolGUI [6], which provides a graphical user interface (GUI). The Java-based application requires the installation of ExifTool and version 11 of the Java Runtime Environment, which can be easily installed from the repositories of almost all popular distributions.

After a somewhat slow start, jExifToolGUI comes up with a clear-cut interface. On the left, below the menubar and buttonbar, you will find a pane that displays small thumbnails of the files discovered by jExifToolGUI. To the right of this pane, you can view and edit the metadata of the selected files using the tabs at the top of this pane.

To get started, click on the folder icon in the top left corner of the window and select the desired folder in the file manager that then opens. jExifToolGUI then reads the files it discovers and displays them one below the other as thumbnails in the pane on the left. After clicking on one of the files, the associated metadata appears in a table on the right in the View Data tab (Figure 3).

Figure 3: jExifToolGUI lets users view and edit metadata in an easy-to-use GUI.

Using the Edit Data tab, you can then modify the existing data. A second tab bar, which categorizes the corresponding data, lets you to reach the data quickly without having to trudge through a long, confusing table of Exif tags and their values. The Exif tags belonging to the respective category appear one below the other on the individual tabs; you can enter the modified values in corresponding input fields. To the right, you click checkboxes to save the new values; by default, jExifToolGUI checks all the boxes for saving the values.

After completing the modifications, transfer the new metadata to the respective image(s) in each tab by clicking the Copy to selected image(s) and save button at the bottom of the active dialog. jExifToolGUI will then transfer the modified data to the correct location in the metadata inventory. If necessary, you can also simply copy existing data to the appropriate tab category by clicking Copy from selected images at the bottom of the relevant editing segment after selecting an image. By selecting this option, you must reread the data in each category for the selected images.

Metadata | Remove metadata saves you from having to laboriously go through the individual editing dialogs one by one to remove metadata. Clicking on it opens a new dialog in which you select the categories in question by checking the matching options (Figure 4). At the same time, the default Back up originals option ensures that backups of the original data are preserved.

Figure 4: Existing metadata is quickly deleted in jExifToolGUI if necessary.

After clicking OK and confirming the prompt, jExifToolGUI removes the metadata from the image header. If you then reselect the image and reread the metadata using the Copy from selected images button, you will see empty fields for the corresponding Exif tags.

ExifCleaner

ExifCleaner [7] also relies on ExifTool as the basis for reading and removing Exif data. Due to its simple user interface, ExifCleaner is best suited for users who only occasionally want to remove metadata from images. The program cannot edit metadata. You will find RPM and DEB binary packages for ExifCleaner on GitHub, as well as a generic AppImage package. The source code is also available on GitHub.

ExifCleaner opens a spartan-looking empty window with only one menubar. Drag the image files whose metadata you want to remove into the empty space. In two columns, the tool shows how many Exif values it has found in each image file and how many values will remain after the removal process (Figure 5). You can only see the number of read-only values that cannot be removed, but not which Exif tags the values belong to.

Figure 5: ExifCleaner is a plain vanilla metadata removal tool.

ExifCleaner automatically starts removing the metadata immediately after loading the files. Since the tool does not back up the original files, the deleted metadata cannot be reconstructed. Take care when selecting and transferring image files to ExifCleaner to avoid data loss.

Contrary to what the program name suggests, ExifCleaner does not just manipulate image files, but also video formats such as M4A, MOV, QT, and MP4. In addition, ExifCleaner removes all metadata except for read-only metadata (which cannot be deleted) from PDF files.

jhead

You can use jhead [8], a small command-line program, to modify the Exif headers in JPEG files. Due to the software's considerable number of parameters, jhead requires a longer training period depending on your intended use. Because jhead can only handle JPEGs, you will get an error message if you call a file in any other format.

To display an image file's metadata, use the command:

jhead FILE

The application then lists the individual Exif tags in the terminal (Figure 6). To change the tags based on the parameters supported by the software, use the command:

jhead PARAMETER FILE
Figure 6: jhead deletes or modifies metadata in JPEG files only.

The individual parameters are revealed by calling jhead -h. To change the same Exif tag for multiple files located in a directory, you can also specify the file names using wildcards, resulting in jhead doing the job in one fell swoop.

mat2

A classic tool for removing metadata from file collections, the Metadata Anonymisation Toolkit 2 (mat2) [9] not only supports images and audio and video files, but it also supports PDF and Office file formats. This makes mat2 particularly suitable for users in sensitive areas, such as journalists or lawyers.

The command-line tool offers numerous options and parameters, which require some familiarization. However, a plugin for the Gnome file manager Nautilus lets you clean up groups of files at the command line even without knowing the syntax (Figure 7). To do this, you simply select the files to be cleaned and then right-click to call up a context menu in which you click the Remove metadata option.

Figure 7: You can use mat2 in the Gnome file manager Nautilus via a plugin.

Using the plugin, you can select files with a wide variety of formats; mat2 identifies the format and applies the correct routines to remove the metadata. During cleanup, the plugin also displays a progress bar at the top of the program window. In addition to the original file, which remains unprocessed, the cleaned file, which has the same name with cleaned appended, is created in the working directory.

The Tails security distribution ships mat2 with the Nautilus plugin pre-configured.

Metadata Cleaner

Only a few distributions currently have Metadata Cleaner [10] in their repositories. Native binaries are available for Arch Linux, Debian, and Ubuntu and their descendants; a Flatpak and the Python source code are also available.

After installation and first startup, Metadata Cleaner loads with a visually modern and functionally spartan window: Metadata Cleaner has no conventional menubar or buttonbar. Instead, the GTK-based application follows the Gnome operating principle and integrates all controls of interest in the titlebar (Figure 8).

Figure 8: Metadata Cleaner stands out due to its brightly colored interface.

The Add Files button in the top left corner takes you to a file manager where you can select the image files to be processed. Metadata Cleaner then displays them in a list, with the number of identified Exif tags highlighted in red in a column on the right. Clicking on the rightmost arrow after each file icon opens a detailed display of the metadata embedded in the respective image file. The arrow pointing to the left in the titlebar takes you back to the file display.

To remove the metadata from all of the loaded files, simply press the big red Clean button bottom right in the program window. Metadata Cleaner will suggest creating a backup copy and then it will delete all metadata it finds without further ado. The application does not automatically create any backup copies of the originals, so the metadata cannot be reconstructed later.

If you click on the gear icon to the left of the Clean button, a small dialog opens in which you can switch on a Superficial cleanup via a slider. This mode does not completely remove the metadata from the respective file, but tries to preserve functionally relevant metadata. The Superficial cleanup is best suited for file formats such as PDF, where you can also make changes. Modifications such as text changes in a PDF or image compression may be controlled by the metadata and will be lost if the meta tags are missing. Consequently, you should not delete all the metadata for these types of file formats. The slider effects all files stored in the program window. Cleaning up the files takes some time, depending on the number.

digiKam

With digiKam [11], which is part of the KDE Plasma library, you can view metadata with the push of a button and edit the data in a convenient editor. You'll find digiKam in the repositories of all of the popular distributions, and you can use digiKam with any desktop environment. When you launch digiKam for the first time, a multi-step wizard helps out with the basic configuration, which includes paths and settings for the software, as well the link to a database back end.

The program window that appears after the initial configuration has a conventional menubar and buttonbar for frequently used functions and three main panes below (Figure 9). On the left, the system's folder hierarchy is displayed as a tree view; in the center, you can see thumbnails of the image files that reside in the current folder. On the far right, digiKam displays information about the selected image.

Figure 9: A heavyweight among image editing programs, digiKam has a fairly cluttered appearance at first.

If you select the Metadata tab in the unusual but space-saving vertical tab bar on the far right, the data from the headers of the active image appear in the information pane on the right. digiKam also divides this pane into several tabs. By default, it displays the Exif tags. In addition, the IPTC and XMP tabs will show the metadata for these specifications if available.

To edit the metadata in the active image, click Item in the menubar and select Edit Metadata from the context menu that opens. A separate dialog now lists all metadata sorted by tags and lets you modify the field content (Figure 10). You can also exclude or include individual fields by checking or unchecking the boxes to the left. On the left side of the dialog box, you can choose between several categories that group similar settings. At the top of the workspace, there are additional tabs that let you switch between the different metadata standards.

Figure 10: You can edit metadata in digiKam conveniently as field content.

The dialogs for the IPTC and XMP standard primarily contain comment fields, a copyright note, and keywords for keyword tagging. The categories in the left sidebar change to reflect the options available for each standard. Once you have made your changes, first click Apply bottom left in the buttonbar and then OK to close the dialog. You are then returned to the digiKam main window.

XnView MP

The commercial XnView MP [12] tool, which is distributed as freeware for private and educational use, is a cross-platform image viewer with numerous image editing functions. XnView MP supports more than 500 image formats and is available for download for Linux from the vendor's website as a TGZ archive, a DEB binary package, and as an AppImage. The DEB package integrates seamlessly into Ubuntu and its derivatives and also creates an entry in the respective desktop's menu tree.

After starting XnView MP, a clear-cut, tab-based interface opens (Figure 11); it has four panes, a menubar, and a buttonbar. The top left pane contains a tree view of the system's folder hierarchy; in a large pane on the right, XnView MP displays the images from the current folder as previews. In the bottom right pane, you'll find a horizontal category list for tagging the images, as well as an info segment in the bottom left pane that displays the matching metadata in the EXIF, IPTC-IIM, and XMP tabs. However, if the current image has no metadata for a certain standard, XnView MP does not show you a tab for that standard.

Figure 11: XnView MP also offers numerous image processing functions.

Under Tools | Metadata, you will find various options for editing metadata, sorted by the supported standards. A separate Edit GPS data entry also lets you change existing GPS coordinates. The Delete option removes existing metadata completely, and you can specify which metadata XnView MP should delete in another dialog by checking a box (Figure 12). However, XnView MP does not consider individual tags, but only the respective standards.

Figure 12: Metadata can be deleted in XnView MP with a few mouse clicks.

While XnView MP can only edit a number of selected Exif tags, it offers more advanced modifications for IPTC and XMP metadata. To modify Exif tags, go to the Transfer dialog under Tools | Metadata, select the individual tags from a list, and populate them with predefined values from a drop-down list.

Conclusions

Linux proves to be very flexible when editing metadata in a wide variety of file formats. While there fewer Linux applications for this tasks compared with other operating systems, the tools that are available cover all common areas of application (see Table 1). Both command-line users and users who prefer a GUI will find a solution to meet their needs.

Table 1

Metadata Editing Tools

 

ExifTool

jExifToolGUI

ExifCleaner

jhead

mat2

Metadata Cleaner

digiKam

XnView MP

License

GPL

GPL

MIT

Public Domain

LGPL

GPL

GPL

Commercial

Properties

GUI

No

Yes

Yes

No

Yes1

Yes

Yes

Yes

Text-Based Interface

Yes

No

No

Yes

Yes

No

No

No

Cross-Platform

Yes

Yes2

Yes

Yes

Yes

No

Yes

Yes

Supported Standards/Formats

Exif/IPTC/XMP

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Multimedia (Image/Audio/Video)

Yes

Yes

Yes

JPEG

Yes

Yes

Yes

Yes

PDF Files

No

No

Yes3

No

Yes

Yes

No

No

Office Files

No

No

No

No

Yes

No

No

No

Functions

Removing Metadata

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Modifying Metadata

Yes

Yes

No

Yes

No

No

Yes

Yes

1File Manager, 2Java, 3Restricted

Image editors like digiKam or XnView MP require some training, as they cover a very large range of functions, which makes their interfaces more confusing. Casual users who just want to remove metadata from their images for publication are better off using one of the point-and-click, meta tag removal-only programs. \