Automagically optimizes images in a directory (optionally recursively) with a given compression level and criteria for replacement.
Go to file
Your Name 417a253ac7 Rename CompressLevel to Quality for clarity 2022-02-01 10:41:50 -05:00
.gitignore initial commit 2022-02-01 10:34:41 -05:00
README.md Rename CompressLevel to Quality for clarity 2022-02-01 10:41:50 -05:00
go.mod initial commit 2022-02-01 10:34:41 -05:00
main.go Rename CompressLevel to Quality for clarity 2022-02-01 10:41:50 -05:00

README.md

imageoptimizer

imageoptimizer is a tool for bulk compression og JPG images. It will re-compress original images and replace them if the savings is more than the requested percentage difference, default is 25%. By defaul it operated in a "dry run" mode where images are not replaced but individual and total savings are reported at the end, unless you supply the '-replace' flag.

why?

Poorly optimized images in most contexts waste space and bandwidth unnecessarily. JPEG compression was designed to highly optimize photos with little or no visually identifiable differences in default conditions, and for scenarios where absolute quality is less important it can compress even farther. Generally quality levels below 75 are where you start to notice a difference.

usage

Recursively check all images starting from the current path. Calculate actions and total svings but don't make any changes.

imageoptimizer -recursive -diff 25

Replace images in the current path with a compressed version if compressing at 80% quality reduces file size by at least 30%

imageoptimizer -quality 80 --replace --diff 30