Skip to content

feat(scripts): add image compression script#55

Merged
CalvinAllen merged 1 commit intomainfrom
feat/scripts/image-compression
Jan 29, 2026
Merged

feat(scripts): add image compression script#55
CalvinAllen merged 1 commit intomainfrom
feat/scripts/image-compression

Conversation

@CalvinAllen
Copy link
Collaborator

Summary

  • Adds npm run compress script to optimize PNG and JPEG images in blog posts
  • Uses sharp with palette-based PNG compression (~60-80% size reduction)
  • Uses mozjpeg for JPEG compression
  • Only replaces images if savings exceed 5%
  • Can target all blog images or a specific directory

Usage

# Compress all blog images
npm run compress

# Compress specific post
npm run compress src/content/blog/2026/some-post

Test Results

Tested on sample blog post images:

Total savings: 683.1 KB (73.5%)

Test plan

  • Run npm run compress on existing blog posts
  • Verify compressed images still look good
  • Check that small images (<10KB) are skipped

Adds a script to compress PNG and JPEG images in blog posts using sharp.
Uses palette-based PNG compression and mozjpeg for JPEGs. Only replaces
images if savings exceed 5%. Run with `npm run compress` to process all
blog images, or pass a specific directory path.
@CalvinAllen CalvinAllen merged commit 5689da7 into main Jan 29, 2026
2 checks passed
@CalvinAllen CalvinAllen deleted the feat/scripts/image-compression branch January 29, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant