Skip to content

Commit 50b3232

Browse files
tomarraclaude
andauthored
feat: convert all images to WebP with pre-commit optimization hook (#90)
* feat: convert all images to WebP with pre-commit optimization hook - Convert all 63 images from JPG/JPEG/PNG to WebP (63 MB → 23 MB, 63% reduction) - Update every image reference in posts, pages, and _config.yml to .webp - Add .githooks/pre-commit that auto-converts staged images on commit - Add scripts/optimize-images.sh for bulk conversion and scripts/install-hooks.sh for setup - Add CLAUDE.md documenting the image workflow and local setup Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * rotate image * spelling and formatting --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 25c9b01 commit 50b3232

172 files changed

Lines changed: 190 additions & 64 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.githooks/pre-commit

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
# Pre-commit hook: converts staged JPG/JPEG/PNG images to WebP automatically.
3+
# Install once with: ./scripts/install-hooks.sh
4+
5+
QUALITY_PHOTO=82
6+
QUALITY_SCREENSHOT=88
7+
8+
if ! command -v cwebp &>/dev/null; then
9+
echo "Warning: cwebp not found — skipping image optimization. Install with: brew install webp"
10+
exit 0
11+
fi
12+
13+
STAGED_IMAGES=$(git diff --cached --name-only --diff-filter=A | grep -iE '\.(jpg|jpeg|png)$' || true)
14+
15+
if [ -z "$STAGED_IMAGES" ]; then
16+
exit 0
17+
fi
18+
19+
CONVERTED=0
20+
21+
while IFS= read -r img; do
22+
[ -z "$img" ] && continue
23+
[ -f "$img" ] || continue
24+
25+
webp_path="${img%.*}.webp"
26+
27+
if echo "$img" | tr '[:upper:]' '[:lower:]' | grep -q '\.png$'; then
28+
quality=$QUALITY_SCREENSHOT
29+
else
30+
quality=$QUALITY_PHOTO
31+
fi
32+
33+
cwebp -q "$quality" -quiet "$img" -o "$webp_path"
34+
rm "$img"
35+
git rm --cached "$img" >/dev/null 2>&1
36+
git add "$webp_path"
37+
38+
echo " Optimized: $img$webp_path"
39+
CONVERTED=$((CONVERTED + 1))
40+
done <<< "$STAGED_IMAGES"
41+
42+
if [ "$CONVERTED" -gt 0 ]; then
43+
echo ""
44+
echo " $CONVERTED image(s) converted to WebP. Reference them with the .webp extension in your posts."
45+
fi

.vscode/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"codeyear",
3131
"curlingscoreboard",
3232
"currentdate",
33+
"cwebp",
3334
"dasow",
3435
"dennisleary",
3536
"difftool",

CLAUDE.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# tomarra.github.io
2+
3+
Personal blog built with Jekyll, hosted on GitHub Pages.
4+
5+
## Setup
6+
7+
After cloning, install the git hooks so images are automatically optimized on commit:
8+
9+
```bash
10+
./scripts/install-hooks.sh
11+
```
12+
13+
Requires `cwebp` for image optimization: `brew install webp`
14+
15+
## Images
16+
17+
All images live in `images/` (root-level) or `images/posts/` (post images).
18+
19+
**Format:** WebP only. All images must be `.webp` before committing.
20+
21+
**The pre-commit hook handles this automatically:** drop any `.jpg`, `.jpeg`, or `.png` into `images/`, stage it with `git add`, and the hook converts it to `.webp` and swaps the staged file before the commit lands. You never commit non-WebP images.
22+
23+
**Reference images in posts using the `.webp` extension:**
24+
25+
```markdown
26+
![Alt text]({{site.baseurl}}/images/posts/my_photo.webp)
27+
```
28+
29+
**To bulk-convert images manually** (e.g. if hooks aren't installed):
30+
31+
```bash
32+
./scripts/optimize-images.sh
33+
```
34+
35+
## Running locally
36+
37+
```bash
38+
bundle exec jekyll serve
39+
```

_config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#-------------------------------
33
# General Site Settings
44
title: Tom Arra
5-
logo: # You can add own logo. For example '/images/logo.png'.
5+
logo: # You can add own logo. For example '/images/logo.webp'.
66
description: Thoughts, stories and ideas. Mostly.
77
baseurl: "" # the subpath of your site, e.g. /blog
88
url: "https://tomarra.com" # the base hostname & protocol for your site, e.g. http://example.com
@@ -11,7 +11,7 @@ url: "https://tomarra.com" # the base hostname & protocol for your site, e.g. ht
1111
# Author Settings
1212
author:
1313
name: Tom Arra
14-
avatar: "/images/headshot.jpg"
14+
avatar: "/images/headshot.webp"
1515

1616
social:
1717
- { icon: "fa-twitter", label: Twitter, link: "https://twitter.com/tom_arra" }
@@ -53,7 +53,7 @@ social:
5353
hero:
5454
hero__title: Hey, I’m Tom! Product Leader & Engineer.
5555
hero__description: I'm a product leader & engineer who loves to work with global teams and products. I help organize the corporate chaos to make the best solutions for customers. Here I post about not just tech but a few hobbies as well.
56-
hero__image: "/images/headshot.jpg"
56+
hero__image: "/images/headshot.webp"
5757

5858
#-------------------------------
5959
# Build Settings

_pages/about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
layout: page
33
title: About
44
permalink: /about/
5-
image: "/images/curling_slide.jpeg"
5+
image: "/images/curling_slide.webp"
66
---
77

88
**Tom Arra** has over ten years of experience in the software engineering world but has been interested in technology a few years before that. While attending school he started as an intern focused on product testing and hasn’t looked back since. Tom has experience as a software engineer, team lead, and product owner across many different types of products and frameworks.

_posts/2011-06-28-Just-What-We-Need-Another-Social-Network.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ tags: web google
77

88
Looks like Google is going to try it’s hand again at some kind of social network. The landing page for [Google+](http://plus.google.com/) has just surfaced and with that it seems as though Google is rolling out some possible rebranding.
99

10-
![Black Google Top Bar]({{ site.baseurl }}/images/posts/Google_Top_Black_Bar.png)
10+
![Black Google Top Bar]({{ site.baseurl }}/images/posts/Google_Top_Black_Bar.webp)
1111

1212
Really Google? A black top bar? Doesn’t that go against your entire web UI?
1313

_posts/2011-07-06-Inverted-Scrolling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ I upgraded my MacBook Pro to the Golden Master release of Lion this morning and
99

1010
To get scrolling back to the trusty way it has been since…forever just plug in a USB mouse or connect a Bluetooth mouse. Then in System Preferences go to Mouse and uncheck the checkbox at the top.
1111

12-
![Scrolling Setting]({{ site.baseurl }}/images/posts/Scrolling_Setting.png)
12+
![Scrolling Setting]({{ site.baseurl }}/images/posts/Scrolling_Setting.webp)
1313

1414
The setting will apply to the external mouse but it will also carry over to the trackpad.

_posts/2011-07-07-The-Icons-Shape-the-Platform.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ tags: mobile software
77

88
Mobile platforms. Just saying the phrase makes some people cringe due to the number of ecosystems out there. But with each ecosystem/platform comes a new UI. [WPCentral](http://www.wpcentral.com/smartphone-os-shapes) has an interesting article how how close each platform’s icon size/shape really is.
99

10-
![Icon Shapes]({{ site.baseurl }}/images/posts/Icon_Shapes.jpg)
10+
![Icon Shapes]({{ site.baseurl }}/images/posts/Icon_Shapes.webp)
1111

1212
It’s something you don’t really see until you line them all up. Also notice the absence of BlackBerry OS and Android. Both platforms have no standard/bounding shape for developers to use. While some people might hate the restrictions on icon shape and size I think it’s good to have when you want to really give the consumer the best UI possible.

_posts/2011-07-11-The-Last-Shuttle.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ date: 2011-07-11
55
tags: space nasa
66
---
77

8-
![The Last Shuttle]({{ site.baseurl }}/images/posts/The_Last_Shuttle.jpg)
8+
![The Last Shuttle]({{ site.baseurl }}/images/posts/The_Last_Shuttle.webp)
99

1010
The last shuttle mission launched last Friday and what a shot this was. Photo taken from [Robert Scobel’s Flickr Stream](http://www.flickr.com/photos/scobleizer/5915301679/in/photostream)

_posts/2011-08-09-We-Stopped-Dreaming.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ tags: politics space
77

88
Not much else to add to this video except the fact that Neil deGrasse Tyson is the man. We need to get other people to think the same way so we can rejuvenate not only this country but the whole world.
99

10-
[![We Stopped Dreaming](http://img.youtube.com/vi/3_F3pw5F_Pc/0.jpg)](http://www.youtube.com/watch?v=3_F3pw5F_Pc "We Stopped Dreaming")
10+
[![We Stopped Dreaming](http://img.youtube.com/vi/3_F3pw5F_Pc/0.webp)](http://www.youtube.com/watch?v=3_F3pw5F_Pc "We Stopped Dreaming")

0 commit comments

Comments
 (0)