Categories We Write About

Batch compress image files

To batch compress image files, you can use various tools depending on your operating system and preferred method (software or script). Here’s how you can do it:


Option 1: Using Free Desktop Tools

Windows

  • IrfanView

    1. Install IrfanView and the IrfanView Plugins.

    2. Open IrfanView.

    3. Go to File > Batch Conversion/Rename.

    4. Select Batch conversion, choose output format (e.g., JPG).

    5. Click Options to set compression level.

    6. Add files/folders and start batch.

  • Caesium Image Compressor

    • Drag and drop images, set compression level, and click “Compress”.

Mac

  • ImageOptim

    • Drag multiple images into the window. Automatically compresses.

  • Automator

    • Create a custom workflow for batch compression using “Scale Images” and “Change Type of Images”.


Option 2: Online Tools


Option 3: Using Command Line (Linux/macOS/WSL)

JPEG Images

bash
for img in *.jpg; do convert "$img" -quality 75 "compressed/$img" done

PNG Images

bash
for img in *.png; do pngquant --quality=65-80 --output "compressed/$img" "$img" done

Install imagemagick for convert, and pngquant for PNG compression.


Option 4: Python Script for Batch Compression

python
from PIL import Image import os input_folder = "images/" output_folder = "compressed/" os.makedirs(output_folder, exist_ok=True) for filename in os.listdir(input_folder): if filename.lower().endswith(('.jpg', '.jpeg', '.png')): img = Image.open(os.path.join(input_folder, filename)) output_path = os.path.join(output_folder, filename) img.save(output_path, optimize=True, quality=70)

Tips for Better Compression

  • Reduce image dimensions if full resolution isn’t needed.

  • Choose appropriate formats: use JPEG for photos, PNG for graphics with transparency.

  • Use WebP for web use (smaller size with good quality).

Let me know if you want a tool with a GUI, script-based automation, or integration in a website.

Share This Page:

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Comments

Leave a Reply

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

Categories We Write About