Automating image compression locallyI recently poked around some command-line tools for compression. There are a lot of options, but the best seem to be pngquant and jpegoptim. They are fairly cross-platform and free. Both big bonuses in my book.I want to use CLI tools because they:Work across entire projects, not one file at a timeAre easy to automate (CI, build scripts, pre-deploy steps)Produce consistent, repeatable resultsAre not GUI tools which means no manual exporting requiredCompressed using pngquant - 59,449 bytesStep 1: Install the ToolsmacOS (Homebrew)brew install pngquant jpegoptimLinuxUbuntu / Debian:sudo apt update sudo apt install pngquant jpegoptimFedora:sudo dnf install pngquant jpegoptimArch:sudo pacman -S pngquant jpegoptimYou can then verify installation with:pngquant --version jpegoptim --versionStep 2: Compress PNGsSingle PNG file compressionpngquant --quality=65-85 --force --ext .png image.pngRecursively compress all PNGs in a projectfind ./website-folder -type f -name "*.png" -exec pngquant --skip-if-larger --ext .png --quality=65-85 {} \; This command recursively finds all PNG files, compresses them in place, preserves filenames, and applies a quality range suitable for most web UI and illustration assets. It will skip the file if larger, meaning that it won't try to recompress files that it has already compressed. Step 3: Compress JPGsSingle JPG file compressionjpegoptim --strip-all --max=85 image.jpgRecursively compress all JPGs in a projectfind ./website-folder \( -iname "*.jpg" -o -iname "*.jpeg" \) -type f -exec jpegoptim --strip-all --max=85 {} \;--max=85 applies strong compression with minimal visual loss, while --strip-all removes EXIF and metadata. Files are overwritten in place. Optional: Parallel Processing! Parallel execution is especially useful on Linux servers and modern multi-core Macs. # PNGs find ./website-folder -type f -name "*.png" -print0 \ | xargs -0 -P 4 pngquant --force --ext .png --quality=65-85 # JPGs find ./websit...
First seen: 2026-01-29 22:35
Last seen: 2026-01-29 22:35