How to Compress a Folder of Images from the Command Line using ImageMagick?

Updated on September 3, 2017

Command Line always come handy and prove really very efficient to perform whatever kind of operation you want! What if you have large number of images and wish to save them as optimized web files? Will you prefer to open each of them in a photo editor and then save it? or, do it in bulk with a single line? I got you and here is how to for you!

If you are running Windows, we’d recommend installing Cygwin and pick the ImageMagick package while installation. For Linux or Mac,  bash shell comes for action and you’ll need to install ImageMagick package only.

* Open a terminal window already set to the folder of images you want to compress.

* For cygwin, use cd command and switch to the /cygdrive/c/ folder.

cd /cygdrive/c/

* Run the command given below.

for f in *.jpg; do convert -quality 80 $f $f; done

The command will change the quality of the JPG file and bring it down to 80 using ImageMagick

Was this article helpful?

Related Articles

Leave a Comment