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
community/fbida

$ pkgfile exiv2
extra/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. Enjoy!