How to compress image files?

Web developers and designers usually have to optimize a number of images. So individually optimizing the images one by one is a pathetic process as the task is time taking and mundane. Why only web developers, even casual users can optimize multiple images at a time before uploading it on the web fast. It would be better if there was a way to optimize them simultaneously. Here is a convenient way how to compress image files inside a folder using command line. 
If you have a computer with Windows OS then it would be better to install Cygwin. The bash shell makes it easy to perform an operation on multiple files simultaneously in Linux or Mac systems.

video_pptSteps to Compress Multiple Images Files Inside a folder:

  1. Install Cygwin on your Windows computer.
  2. Switch to the /cygdrive/c/ folder using the command: cd /cygdrive/c/
  3. Use the cd and ls commands to figure out where you are currently in, and navigate into the image folder that you want to manipulate.
  4. Run the following command:
 for f in *.jpg; do convert -quality 80 $f $f; done

Compress Single Image File Using command Line
Use the following command to optimize a single image file:

 convert -quality 80 image1.jpg image2.jpg
  1. -quality parameter determines the level of compression for the image file. Lower the value, more is the compression, but lower is the quality of the image file.
  2. The first name (image1.jpg) is the name of the image file to be compressed.WinRAR1
  3. The second name (image2.jpg) is the name of the compressed file that you wish to save it as.

Make sure to backup all the images before compressing.

Swasti Pujari
Swasti Pujari

Swasti Pujari is a versatile Engineer, blogger, content writer, and Social Media Enthusiast. With a passion for technology and creativity, she has devoted her career to solving engineering challenges and crafting engaging content. Her online presence is a strategic platform for connecting with people and sharing insights. Swasti's unique blend of technical expertise and creative expression has made her a key figure in her field. Her mantra for success is continuous learning and happiness in her work, reflecting her innovative approach to both engineering and writing.

Leave a Reply