Compression •

How to Compress WebP Images via Command Line (cwebp, ImageMagick & Bash)

Ready-to-Run Interactive Pipeline
Compress Thousands of Images Automatically
Run up to 2,000 images in parallel or automate via REST API & MCP.

Managing local binary dependencies like cwebp across fragmented CI/CD runners introduces severe dependency drift and excessive CPU compilation overhead during deployments. Meanwhile, legacy cloud compression APIs force developers into rigid, overpriced subscription tiers while holding proprietary assets on insecure third-party storage.

ImgPipeline delivers a sub-50ms secure cloud edge engine designed for developers who need high-throughput image optimization without local infrastructure strain, reducing image payloads by up to 85% and infrastructure API spend by up to 90%.

  • Zero-Retention Security: Images are processed ephemerally in-memory at the cloud edge with strict zero-disk persistence, guaranteeing compliance with GDPR, HIPAA, and SOC2 standards.
  • Seamless CLI & CI/CD Integration: Trigger ultra-fast compression directly from terminal workflows and automated build scripts using standard utilities like curl without managing native C libraries.
  • Usage-Based Developer Pricing: Eliminate the costly monthly minimums and concurrency limits typical of legacy alternatives like TinyPNG.

Native CLI Compression: cwebp and ImageMagick

If you have Google's native libwebp package installed locally, the standard cwebp encoder provides granular control over lossy and lossless quantization profiles:

# Compress an existing WebP with quality factor 75 and compression effort 6
cwebp -q 75 -m 6 input.webp -o output.webp

For environments running ImageMagick 7+, execute compression while stripping non-essential EXIF metadata using the command-line utility:

magick input.webp -quality 75 -define webp:method=6 -strip output.webp

Batch Compressing WebP Assets via Bash

To recursively compress an entire directory tree before deploying static assets to object storage, run this POSIX-compliant Bash loop:

#!/usr/bin/env bash
# Recursively compress all WebP files in place
find ./public/images -type f -name "*.webp" | while read -r file; do
  cwebp -q 80 -m 6 "$file" -o "${file%.webp}_temp.webp" > /dev/null 2>&1
  mv "${file%.webp}_temp.webp" "$file"
done

Edge Compression via cURL and ImgPipeline

Compiling native C tools like libwebp inside ephemeral Docker containers and GitHub Actions runners slows down build pipelines and consumes excessive CPU cycles. ImgPipeline allows you to offload encoding to an ultra-low latency edge API using raw curl commands:

curl -X POST "https://api.imgpipeline.com/v1/compress" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image_url": "https://example.com/asset.webp", "quality": 80, "format": "webp"}' \
  --output asset-optimized.webp

By executing image quantization through ImgPipeline's edge infrastructure, engineering teams reduce build times, eliminate infrastructure maintenance overhead, and guarantee that uncompressed media is never written to persistent logs or intermediate storage.

Try It For Free

Compress Thousands of Images Automatically

Fit, pad, and optimize catalog assets or photos at high throughput. Sub-50ms speeds with secure, zero-retention processing.

Open Bulk Pipeline →