Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Photo Compress Script

Batch-compress JPEG photos with Sharp and MozJPEG. Keeps full resolution, reduces file size, and outputs .jpg files to compressed-photos/.

What it does

  • Reads all .jpg / .jpeg files from source_photos/
  • Compresses each photo without resizing
  • Auto-rotates using EXIF orientation
  • Strips metadata to save extra space
  • Writes compressed files to compressed-photos/ with the same filename

Original files in source_photos/ are never modified.

Requirements

  • Node.js 18.17 or newer

Setup

npm install

Usage

  1. Put your photos in source_photos/
  2. Run:
npm run compress
  1. Get compressed photos from compressed-photos/

Example output:

DSC05215.JPG: 7.50 MB -> 3.76 MB (49.9% smaller)

Total: 51.25 MB -> 25.02 MB (51.2% smaller)
Saved to compressed-photos/

Project structure

photo-compress/
├── source_photos/       # input photos (not committed)
├── compressed-photos/   # output photos (not committed)
├── compress-photos.js   # compression script
└── package.json

Adjust quality

Open compress-photos.js and change:

const JPEG_QUALITY = 75;
  • 90–95 — near-original look, larger files
  • 75–85 — good balance for most photos
  • Lower — smaller files, more visible compression

Notes

  • JPEG compression is lossy. This tool aims for visually clean results, not bit-perfect lossless output.
  • Re-running the script overwrites files in compressed-photos/.

About

trying to save my cloud storage space

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages