February 13, 2024

Every once in a while, I do something stupid.

One of the things I don’t want on this blog is data about my location. The problem is that modern cameras – especially cell phone cameras – include your latitude and longitude by default. This is a very handy feature, right up until you decide to publish your images.

I’ve recenty started using my phone camera more often, and some of those pictures have made their way onto this blog, thus exposing my location.

I’m sure it’s too late; things live forever on the internet.

That said, I’m not in the habit of making the same mistake twice, so I endeavored to prevent it in the future. All of the images on this site flow through a single partial (called, appropriately, get-image). Within that partial, I now have this snippet of code before it returns the image:

{{- /* Verify that no EXIF location data exists */ -}}
{{- with $img.Exif -}}
{{-   if or .Lat .Long -}}
{{-     errorf "Image %s has Location data!" $img -}}
{{-   end -}}
{{- end -}}

Now my builds no longer succeed if I accidentally add an image that has GPS data embedded. If you’re wondering, removing it from images is fairly simple from the Linux command line; simply install exiftool, and do this:

$ exiftool -overwrite_original -gps:all= filename.jpg

Yeah, all my images have been fixed.

Fun times!

Someday I’ll figure out how to make Hugo do the removal automagically. It doesn’t pass Exif data through processed images, but I tend to post the originals so people can click on an image and see said original size image, and hugo’s image processing doesn’t touch those…