Andy's Cafe

Test With Hugo Images

Page created :
Last updated :

Here is an image:

Here’s what I did to get it all working

# Install the tools I need
sudo apt install imagemagick
sudo apt install jpegoptim

# Copy the file for stats later
cp IMG_20250604_091538.jpg IMG_20250604_091538.jpg.orig

# Compress the image and strip EXIF metadata
jpegoptim --strip-all --totals --max=70 IMG_20250604_091538.jpg

# Copy for stats again
cp IMG_20250604_091538.jpg small-bad-rotate.jpg

# Compression rotated the image, so I don't know if this is always needed
convert small-bad-rotate.jpg -rotate 90 small.jpg

# Copy for stats again
cp small.jpg small-300.jpg

# Resize the image
mogrify -resize 300 small-300.jpg

I got most of these commands from a quick google search pointing me to this blog post

The file size savings are huge

2.3M IMG_20250604_091538.jpg.orig
568K IMG_20250604_091538.jpg
568K small-bad-rotate.jpg
565K small.jpg
 11K small-300.jpg

So for now, I’m going to shove all of these images into git until it’s too hard to clone my website repo. I’ve added a public Cloudflare R2 bucket to host these images.

Reply via email

Tags

#hugo