brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: mat2 shows and removes the metadata in PDFs, Office files and images

Linux
~/tips/tip-privacy-mat2-clean-metadata

mat2 --show report.pdf

Lists and removes metadata from documents, images and other files, writing a cleaned copy.

PDFs and Office documents tell a lot about their maker: the author name, the company, the software, sometimes a lot more. I already know exiftool for photos, but mat2 covers many more file types with one command.

Look first, then clean:

mat2 --show report.pdf
mat2 report.pdf

The first command lists the harmful metadata mat2 can find without changing the file. The second writes a cleaned copy called report.cleaned.pdf and leaves the original alone. Only --inplace cleans in place and skips the backup, so use it carefully. mat2 -l lists the supported formats, which include PDF, Office and OpenDocument files, images such as jpeg, png and webp, audio, mp4, zip and tar archives.

On a Mac, the project’s README gives the dependencies as a brew command: brew install exiftool cairo pygobject3 poppler gdk-pixbuf librsvg ffmpeg. The README has the rest.

The caveat is in the README and I would take it seriously. By default mat2 may change your data to get rid of metadata: text in a PDF may no longer be selectable, and compressed images may be compressed again. The -L (lightweight) flag removes only some metadata and leaves the data alone. And an empty --show does not prove a file is clean, because there is no reliable way to detect every kind of metadata in complex formats. So clean a file, whatever --show says.

Further reading: mat2 README (GitHub)

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link