Camping at Emerald Lake

2024-07-07

I went camping this weekend with some friends at Emerald Lake State Park in Vermont, and figured this would be a good opportunity to figure out how I want to handle pictures on this blog.

We drove up on Friday afternoon, that awkward Friday after a Thursday holiday. My partner still had to get some work done in the morning, but we managed to leave around noon. Just short enough a drive that I could do it without stopping, but just long enough that I was pretty tired when we arrived. A cup of tea from the camp stove helped immensely, and we were able to rig up a picnic table shelter before the rest of our friends arrived. Homemade spiced chai tea in the woods is a treat.

The forecast had been looking grim earlier in the week but the rain held off the first evening, so we built a nice big fire and had baked potatoes and roasted sausages for dinner. The rain arrived overnight, and while it knocked over the picnic table canopy and drenched the camp chairs, no one really got wet in their tents. The sky cleared late Saturday morning, allowing us to go hiking, and me to take this picture!

A photo of a lake, taken from a high adjacent hill. Trees frame the image, and an island stretches horizontally through the lake. The water above the island in the image is a deep green color, while that below it is brown. Snatches of blue sky are visible between the clouds over the slope of the next hill beyond the lake.

It took me a couple tries to include this image. I have gotten used to the Obsidian flavor of markdown which uses a different link format than the CommonMark flavor used by Zola, the static site generator I'm trying out. The correct format is ![alt_text](path).

The second problem is that the image is way too big! I had kind of breezed past the "image resizing" section in Zola's documentation, thinking that I wouldn't need to worry about that since I'm not creating thumbnails, but it turns out that 4080x3072 is way too big to fit on a screen. We really take automatic image resizing for granted in so many applications. Zola has automatic image resizing which I could leverage using its "shortcode" concept, but the better answer turned out to be CSS. One line of img { width: 50em; } later in my global css file and it was showing up just fine (on desktop, at least).

The last step is to not dox myself! I keep geolocation turned on for my camera app because I like having the data in my Immich server. I don't, however, need to share that info on the open internet. I think a git pre-commit hook which runs exiftool to strip metadata is a decent solution here.

Hooks live in the .git/hooks directory, with one script for each type of hook. We are interested in the pre-commit hook. To start, let's grab only the list of files which actually changed for this commit:

staged_files=$(git diff --name-only --cached)

Then, we need to remove the metadata for each of these files. Ideally, we would only run exiftool on actual image files, but it just prints an error if you give it a file it doesn't understand. In the future I may filter for just image files by adding a pipe to grep in the line above.

For now I'm just removing all tags and adding back a select few. This produces a warning that it is discarding the ICC profile (whatever that is) and may lose some color information, so I'll come back to this in the future.

Here's the command:

for f in $staged_files; do
    exiftool -all= -tagsfromfile @ \
             -exif:createdate \
             -creator='xylem' \
             -copyrightowner='xylemphloem.xyz' \
             -copyrightnotice='(C) 2024 xylemphloem.xyz' $f;
    git add $f;
done

Now it's time to try a commit! Doing a few commits of other, non-image changes allowed me to iron out a few small bugs (typo; forgot to make the hook file executable).

One thing I forgot is that after changing the file, it will need to be staged for the commit again to capture the changes. To get something quick and dirty done, I'm just blindly adding it back, but this will break partial staging of files (i.e. git add --patch). I'll come back to this later.

After running the commit, exiftool emerald_lake.jpg returns the following:

ExifTool Version Number         : 12.76
File Name                       : emerald_lake.jpg
Directory                       : content/blog/camping_july_2024
File Size                       : 4.4 MB
File Modification Date/Time     : 2024:07:08 22:32:47-04:00
File Access Date/Time           : 2024:07:08 22:32:47-04:00
File Inode Change Date/Time     : 2024:07:08 22:32:47-04:00
File Permissions                : -rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Exif Byte Order                 : Big-endian (Motorola, MM)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Y Cb Cr Positioning             : Centered
Exif Version                    : 0232
Create Date                     : 2024:07:06 12:26:43
Components Configuration        : Y, Cb, Cr, -
Flashpix Version                : 0100
Color Space                     : Uncalibrated
Current IPTC Digest             : e3d0eb55d679b007d2d12ac662484e4a
Copyright Notice                : (C) 2024 xylemphloem.xyz
Application Record Version      : 4
XMP Toolkit                     : Image::ExifTool 12.76
Creator                         : xylem
Image Width                     : 4080
Image Height                    : 3072
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 4080x3072
Megapixels                      : 12.5

No doxxing myself!