How to erase file metadata with mat2

How to erase file metadata with mat2

By lingy | Lingy | 27 Nov 2021

Okay, you probably think it's weird that I worry about this, but let's get to the facts: if you take a picture with your cell phone, it will record various data attached to the picture, such as the date it was taken, the cell's MAC, between other information. Of course, for most people, this information doesn't matter much, but this information can be used by criminals, dictatorial governments and even stalkers to track you down and disrupt your life. That's why security-conscious people tend to delete these records, and that's what you'll learn here.

What is metadata?

Metadata is information incorporated into the file, informing relevant data such as creator, creation date, type of camera used, software used, etc. For most users they don't mean anything, but for others it can be the difference between life and death.

Imagine that you build a top secret document about the government of Abakatistan (a fictitious country) revealing the existence of aliens, with various evidence attached, such as photographs, audio, videos, among many others, all true and irrefutable. Then you go and post on Wikileaks. From there, two things can happen:

  • The government looks at the file's properties, identifies who you are and forces you to deny everything about extortion, or even erases you so you don't reveal everything you know;
  • The government opens up the properties of the file, sees that there is no relevant metadata, and has to get by to convince everyone that this is all a lie.

I know it's a silly example, but metadata can reveal a lot about you, such as your device's brand, software you use, and even in some cases your geographic location. Do you really want a potential criminal to know where you live and that you take selfies with your iPhone 12? So keep reading...

The tool

The tool we are going to use is mat2, a tool developed in Python3 to remove metadata from media and files in general. The tool is very complete, having a simple and objective functionality, in addition to a very straightforward and readable documentation even if you have little knowledge in English.

Using the tool is also very simple, and if you already use Tails, you can even skip the first steps, as it is already installed by default in Tails.


First let's install mat2. Assuming you are using Ubuntu or derivatives, open a terminal and type the following command:

sudo apt install mat

The mat package actually redirects to the most current program package (in this case, mat2), so you don't have to worry about technical details. I also recommend installing the necessary packages to remove metadata from videos:

sudo apt install python3-pip
sudo apt install --no-install-recommends ffmpeg
pip install ffmpeg scikit-video

And presto, you have all the necessary dependencies to use mat2 to remove metadata from files.


Let's say you have a photo named foto-da-minha-familia.jpg. First let's look at the photo's metadata. Right click on it and then click on "properties". If the image has metadata, it will appear on this screen:


From here, there are two ways to use it, one via the graphical interface and one via the terminal.

Graphic interface

After you have installed mat2, you will see an extra option when you right click on a file: Remove metadata:

opções do arquivo

This option will run mat2 to erase the chosen file's metadata. When doing this, the program will make a copy of the file, but removing all possible metadata from the copy, adding the word cleaned to differentiate one from the other. Look:


Then you just take this copy without the metadata and share.


Open the terminal in the desired folder and run the following command:

mat2 foto-da-minha-familia.jpg

And that's it, the program has just done the exact same thing it would do if you ran it via a graphical interface.

So what's the advantage of running like this?

Simple: you can run extra options. For example, the command below will not create a copy of the file without the metadata, it will remove the metadata from the original file:

mat2 --inplace foto-da-minha-familia.jpg

And the command below will list all formats supported by the program:

mat2 --list

And the command below will show the dependencies, informing if they are installed or not:

mat2 --check-dependencies


Did you like the content? Leave your opinion there in the comments.

How do you rate this article?




My personal blog about technology

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.