Automagically optimizes images in a directory (optionally recursively) with a given compression level and criteria for replacement.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Your Name d24d8fb195
Transparancy check
4 months ago
.gitignore initial commit 1 year ago readme, todo updates 1 year ago
TODO.txt readme, todo updates 1 year ago
go.mod remove temp file if not used rather than overwrite and leave a dangling file at the end 1 year ago
go.sum add resolution maximums 1 year ago
main.go Transparancy check 4 months ago


imageoptimizer is a tool for bulk compression of JPG images. It will re-compress original images and replace them if the savings is more than the requested percentage difference and optionally if the original file is bigger than a cefrtain size. You can also set a maximum resolution for images and they will be rescaled if they exceed it, however they are only replaced if they meet the size difference requirement set.

By default it operates 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.


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.


With a recent Go compiler, installation is as easy as:

go install


Recursively check all images starting from the current path. Calculate actions and total savings 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