· Design My Website · Images · 1 min read
Compress images on Mac with ImageMagick
How to batch compress a whole folder of JPEG and PNG images on Mac using ImageMagick mogrify commands in Terminal, keeping your original files untouched.
Download: https://imagemagick.org/script/download.php
To compress a folder full of images using ImageMagick on Mac, you can use the command line to batch process all images in that folder. Here’s a step-by-step guide:
- Open Terminal on your Mac.
- Navigate to the folder containing your images using the
cdcommand. For example:textcd /path/to/your/images - Run a loop command that compresses each image. For JPEG images, you can use:text
magick mogrify -quality 75 -path compressed_folder *.jpgThis will compress all.jpgimages in the folder to 75% quality and save the compressed images into a subfolder namedcompressed_folder. You can create this folder first usingmkdir compressed_folder. - To compress PNG images, you could adjust the compression level like:text
magick mogrify -path compressed_folder -format png -define png:compression-level=9 *.png - You can adjust the
-qualityparameter to control the compression level (lower means smaller file size but reduced quality).
Summary of key commands:
- Navigate to folder:text
cd /path/to/images - Create output folder:text
mkdir compressed_folder - Compress JPEGs:text
magick mogrify -quality 75 -path compressed_folder *.jpg - Compress PNGs:text
magick mogrify -path compressed_folder -format png -define png:compression-level=9 *.png
This approach processes all images in bulk efficiently and keeps originals untouched by saving compressed files separately. You can change extensions, quality, and output folder as needed for your specific use.
About the author
Tommy O'Shea
Tommy owns and runs Design My Website, a web design studio in Kilcummin, Co. Kerry. He has built and maintained over 100 websites for businesses across Kerry, Cork and Ireland over the last 13 years.
