Resize, compress images in bulk using Mac Terminal

by | Oct 31, 2020 | WordPress, Tips | 5 comments

When it comes to websites, keeping the image files as small as possible helps your sites to load faster. You may find numerous plugins out there for WordPress. Plugins are handy, however, resizing or compressing your images using plugins is an extra burden for your web server. It’s a good practise to compress the images on your local machine & upload the compressed version to the web site.

In this article, we will guide you on how to resize and compress your images using Mac’s terminal. In general, using a command-line program for such tasks is ideal as it won’t consume many resources of your computer. Also processing through a terminal is much faster than using a GUI application for bulk tasks.

Before

Codechilli - codechilli blog bulk resize compress images imagemagick 01

For this example, we took 3 images. All the images are above 4900px in width & the total size of the images is 7.2MB. After processing the images with the width of 800px, the total size came down to 184KB

After

Codechilli - codechilli blog bulk resize compress images imagemagick 02

How to achieve this?

ImageMagick is an open-source suite of command-line tools for manipulating digital images. It is useful for batch processing a large number of images, or to quickly perform precise image modification tasks.

Install ImageMagick

The easiest & recommended way of installing ImageMagick is via Homebrew. Let’s install Homebrew first. Open up your Terminal and paste following command;

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Homebrew Documentation

Once Homebrew is installed, use the command below to install ImageMagick;

brew install imagemagick

ImageMagick depends on Ghostscript fonts. To install;

brew install ghostscript

To verify the installation;

magick --version
Codechilli - codechilli blog bulk resize compress images imagemagick 03

Compress / Resize Images

Important: Take a backup of your images before manipulating them ✨

cd to your image directory

cd [your-directory-path]

Use below command to check your image sizes & dimensions. Use * to process all the images in the directory

identify *

Now paste below command to start processing the bulk resize / compress;

mogrify * -resize 800 *

800 is the image width (in Pixels). Replace it your desired value.

This is a handy tool to have if you are uploading images to your website regularly. This tool is not limited to only resize or compress. You can even use this tool to convert image formats, rename in bulk, etc. All it’s use cases can be found here.

Bookmarking this page is a good idea for you to refer whenever you need to process your images 😍

5 Comments

  1. Hayley Macredie

    Is there any programs available for windows?

    Reply
    • Codechilli

      Hi Hayley, thanks for your comment. Yes, ImageMagick itself available on Windows. If you are looking for an alternative, IrfanView is a very good GUI program with multiple features for image processing.

      Reply
      • Hayley Macredie

        Awesome, thank you!

        Reply
        • Codechilli

          You’re most welcome, Hayley.

          Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

What we do

We create brilliant digital products that help our clients get ahead and stay there.

codechilli-services-digital-marketing

Digital Marketing

We were born from digital and it remains our core capability of communication. We activate all of our studios (strategy, brand, data analytics, and technology) to work in harmony to deliver the right message to the right audience at the right time on the right platform.

codechilli-services-digital-analytics

Digital Analytics

Digital marketing thrives on data. No matter what type of site/app you have, whether it’s a large e-commerce site, a personal website, a site for a small business, or a high scale app people used to order food, it’s essential to understand how people interact with your web/app. We’re at your disposal.

codechilli-services-wordpress

Web Development

As your modern-day business card, your website is a digital biopsy of your essence. Through qualitative and quantitative research and analysis, we distill the essence of your brand and express it through user-centric design to create a bespoke digital experience.

Let's Talk

about your next project.

Share This