all notes🪴evergreen·Updated
Compress images via the terminal on MacOS

Juri Strumpflohner
A quick and easy way is to use sips
:
sips -Z 640 example.png
This resizes the image and is therefore less useful.
Do do proper compression in various formats, e.g. avif
, ImageMagick is nice.
Install the required tools
brew install libheif
brew install imagemagick
Run the conversion
magick input.jpg -quality 50 output.avif
Some examples
Convert all images from HEIC to JPG
for file in *.HEIC; do sips -s format jpeg "$file" --out "${file%.HEIC}.jpg"; done
Convert all jpg files to webp (or avif)
for file in *.jpg; do magick "$file" -quality 60 "${file%.jpg}.webp"; done
Automatically adjust the orientation of images
magick mogrify -auto-orient -format webp -quality 60 *.jpg