📦 Compression •

TinyPNG CLI: How to Compress Images from the Command Line

Developers relying on standard TinyPNG CLI wrappers for automated image compression frequently run into restrictive API rate limits, unpredictable monthly bills, and build pipeline latency. Transmitting production media assets through legacy third-party APIs also introduces data retention liabilities for security-conscious engineering teams.

ImgPipeline delivers a sub-50ms secure edge API replacement designed for high-throughput command-line tools and CI/CD environments, reducing media optimization costs by up to 90% while enforcing strict privacy guarantees.

Why Replace Legacy TinyPNG CLI Workflows?

  • Zero-Retention Data Security: Every payload is processed entirely in-memory across our secure cloud edge network and immediately purged, guaranteeing complete compliance with zero persistent storage.
  • Pure Pay-As-You-Go Billing: Eliminate rigid tier-based subscriptions and unexpected overage charges. Pay only for the exact bandwidth and operations your build scripts consume.
  • Drop-in Integration Parity: Simple standard HTTP request structures allow instant replacement of legacy CLI endpoints within shell scripts, GitHub Actions, or deployment pipelines.

Optimizing Images directly from the Terminal

You can optimize PNG, JPEG, and WebP files instantly without installing heavy local dependencies or language runtimes. Using standard terminal utilities like curl, execute high-ratio lossy compression against our edge API:

# Compress a local PNG image using the ImgPipeline Edge API
curl -X POST "https://api.imgpipeline.com/v1/compress" \
  -H "Authorization: Bearer $IMGPIPELINE_API_KEY" \
  -F "file=@./src/assets/hero.png" \
  -F "format=png" \
  -F "quality=80" \
  --output ./src/assets/hero.png

Automating Batch Compression via Shell Scripts

To recursively compress all assets within a directory prior to static site deployment, loop over target files directly within your shell setup:

#!/usr/bin/env bash
for img in ./public/images/*.{png,jpg,jpeg}; do
  [ -f "$img" ] || continue
  echo "Compressing $img..."
  curl -s -X POST "https://api.imgpipeline.com/v1/compress" \
    -H "Authorization: Bearer $IMGPIPELINE_API_KEY" \
    -F "file=@$img" \
    --output "$img"
done

AI Agent & Terminal Tool Integration

If you are building custom CLI agents or autonomous developer tools using LLM frameworks (such as LangChain, AutoGen, or custom tool definitions), delegating heavy binary asset manipulation to an external edge service prevents context-window saturation and resource exhaustion.

Register the ImgPipeline endpoint within your AI agent's function definitions to handle automated web asset preparation, payload reduction, and image conversion seamlessly:

{
  "name": "compress_image",
  "description": "Compresses PNG or JPEG images via ImgPipeline secure edge API for minimal transfer size.",
  "parameters": {
    "type": "object",
    "properties": {
      "image_url": { "type": "string", "description": "Public URL or local path to raw image" },
      "quality": { "type": "integer", "default": 80, "description": "Target quality compression index (1-100)" }
    },
    "required": ["image_url"]
  }
}
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 →