There is no shortage of privacy related issues on the Internet. One of them I decided to tackle today is EXIF metadata embedded to the photos I publish here. I do not publish photos too often currently, but occasionally I do. Before today, I did not strip any EXIF metadata and this practice is considered to be a potential privacy issue too.

Getting the right tools

The starting point for me was in zola#838 issue, mentioning exiftran and exiv2 tools. Lets pick them up:

$ pkgfile exiftran

$ pkgfile exiv2

$ sudo pacman -S --needed fbida exiv2

This should be sufficient, adapt for a different package manager if needed.

Implementing into a publishing pipeline

What I have come up with is this bash snippet:

files=$(git diff --cached --name-only | egrep -i "\.(jpe?g|png|gif)$")

echo "$files" | xargs -I % exiftran -i -a %
echo "$files" | xargs -I % exiv2 rm %

I know, it uses xargs on files. This is potentially dangerous, consider taking a look at possible safe usage of xargs on files. Anyway, the danger is greatly mitigated by the fact that xargs -I is only applied on files that end with common image extensions and more importantly, only to such image files that were just added into git index.

The full script source can be seen in the blog repository if anyone is interested. I will test it over following days, so maybe it gets some updates over time. For now on it seems to more or less do the job.