# Sqoosh Image Compressor (`eunit/sqoosh-image-compressor`) Actor

Optimize images for SEO with the Squoosh Actor on Apify. Batch compress, resize, and convert images to WebP, AVIF, and MozJPEG to boost site speed and Core Web Vitals. Automate high-performance image optimization for web scraping and developer workflows with ease.

- **URL**: https://apify.com/eunit/sqoosh-image-compressor.md
- **Developed by:** [Emmanuel Uchenna](https://apify.com/eunit) (community)
- **Categories:** SEO tools, Automation, Developer tools
- **Stats:** 8 total users, 3 monthly users, 99.7% runs succeeded, 3 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $15.00 / 1,000 processed images

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Squoosh Image Optimizer: Advanced Batch Compression for SEO

Boost your website performance and improve **Core Web Vitals** with the most powerful and cost-effective image optimization Actor on Apify. Powered by Google Chrome Labs' **Squoosh** engine, this tool provides professional-grade compression without sacrificing quality.

🔥 **Pay-Per-Result Pricing:** Up to 3x cheaper than TinyPNG! Only pay for the images you successfully compress.

![Squoosh Optimizer](https://i.postimg.cc/1X1VKsJz/image.png)

### Why Squoosh Image Optimizer?

Slow-loading images are the #1 reason for high bounce rates. This Actor automates the heavy lifting of preparing your images for the web, ensuring they are lightning-fast and SEO-friendly.

- **Superior Compression:** Outperforms standard libraries by using industry-leading codecs like **MozJPEG**, **WebP**, and **AVIF**.
- **Batch Processing:** Don't waste time manual-cropping. Pass a list of URLs and let the Actor handle the rest.
- **Modern Formats:** Effortlessly convert legacy JPG/PNG files into modern, high-performance formats.
- **Fine-Grained Control:** Full access to preprocessing (resizing, quantizing) and advanced encoder settings.

***

### Key Features

- **Multi-Format Support:** MozJPEG, WebP, AVIF, OxiPNG, and more.
- **Smart Resizing:** Automatically resize images to fit your UI perfectly.
- **Quality Tuning:** Dial in the exact balance between file size and visual fidelity.
- **Apify Integration:** Seamlessly integrates with your existing scraping or data pipelines to process images on the fly.

***

### 💰 Transparent Pay-Per-Event Pricing

Stop paying expensive monthly subscriptions for image APIs you don't fully use. Squoosh Image Optimizer uses a fair **Pay-Per-Event** model:

- **Up to 3x cheaper** than standard TinyPNG or Kraken.io pricing.
- You are **only charged** when an image is successfully downloaded, compressed, and saved. No hidden API or overage fees.

***

### How to Use

#### Input Configuration

The Actor accepts a JSON object where you specify your source images and your desired output settings.

##### Example Input

```json
{
    "images": [
        "https://example.com/hero-image.png"
    ],
    "preprocess": {
        "resize": {
            "enabled": true,
            "width": 1200
        }
    },
    "encode": {
        "webp": {
            "quality": 80
        },
        "avif": {
            "quality": 65
        }
    }
}
```

#### Output Results

1. **Key-Value Store:** All optimized images are stored here with public URLs.
2. **Dataset:** A detailed report containing:
   - Original vs. Optimized file sizes.
   - Compression ratios.
   - Public links to your new assets.

***

### SEO Benefits

Using the Squoosh Actor directly impacts your SEO ranking by:

1. **Improving Page Speed:** Smaller images = faster TTI (Time to Interactive).
2. **Passing Core Web Vitals:** Reduce LCP (Largest Contentful Paint) scores.
3. **Better Mobile Experience:** Fast-loading images for users on 3G/4G/5G networks.

***

### For Developers

This Actor is perfect for:

- Post-processing images after a web scrape.
- Automating asset preparation for e-commerce catalogs.
- Dynamic image resizing microservices.

**Try the Squoosh Image Optimizer today and make your web assets lean and fast!**

### Related Actors

#### [Fast Sitemap Generator](https://apify.com/eunit/sitemap-generator)

- **URL:** <https://apify.com/eunit/sitemap-generator>
- **Description:** Boost SEO with this automatic Sitemap Generator. Crawl any site to create XML, HTML, & TXT sitemaps. Supports custom depth, regex filters, & robots.txt. Compatible with Google Search Console.

#### [AI Website Content Localizer & Scraper](https://apify.com/eunit/ai-website-content-localizer-scraper)

- **URL:** <https://apify.com/eunit/ai-website-content-localizer-scraper>
- **Description:** Scrape any website and instantly translate the content into 83+ languages using Lingo.dev AI. Build multilingual datasets, localize competitor data, and power global RAG pipelines with clean, context-aware translations. The ultimate tool for shipping global apps fast!

#### [Google Indexer & Instant SEO Submitter](https://apify.com/eunit/google-indexing)

- **URL:** <https://apify.com/eunit/google-indexing>
- **Description:** Instantly index your URLs with the Google Indexing API. Automate sitemap submissions, speed up crawling, and boost SEO rankings. Perfect for fresh content, bulk indexing, and removing dead links. Fast, secure, and pay-per-result!

### Your feedback

We are always working on improving the performance of our Actors. So if you’ve got any technical feedback for the [Sqoosh Image Compressor](https://apify.com/eunit/squoosh-image-compressor) Actor or simply found a bug, please create an issue on the [Actor’s Issues tab](https://console.apify.com/actors/b5wukW2IJZJ6hpl8d/issues) in [Apify Console](https://console.apify.com/actors/b5wukW2IJZJ6hpl8d).

# Actor input Schema

## `images` (type: `array`):

List of Image URLs to process.

## `preprocess` (type: `object`):

Options for preprocessing (resize, rotate). Example: {"resize": {"enabled": true, "width": 800}}

## `encode` (type: `object`):

Options for encoding. Keys are codecs. Example: {"mozjpeg": {"quality": 75}}

## Actor input object example

```json
{
  "images": [
    "https://github.com/GoogleChromeLabs/squoosh/raw/dev/codecs/example.png"
  ],
  "preprocess": {},
  "encode": {
    "mozjpeg": {
      "quality": 75
    }
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `files` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "images": [
        "https://github.com/GoogleChromeLabs/squoosh/raw/dev/codecs/example.png"
    ],
    "preprocess": {},
    "encode": {
        "mozjpeg": {
            "quality": 75
        }
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("eunit/sqoosh-image-compressor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "images": ["https://github.com/GoogleChromeLabs/squoosh/raw/dev/codecs/example.png"],
    "preprocess": {},
    "encode": { "mozjpeg": { "quality": 75 } },
}

# Run the Actor and wait for it to finish
run = client.actor("eunit/sqoosh-image-compressor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "images": [
    "https://github.com/GoogleChromeLabs/squoosh/raw/dev/codecs/example.png"
  ],
  "preprocess": {},
  "encode": {
    "mozjpeg": {
      "quality": 75
    }
  }
}' |
apify call eunit/sqoosh-image-compressor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eunit/sqoosh-image-compressor"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/b5wukW2IJZJ6hpl8d/builds/Bfen7rIutQpxKKt9N/openapi.json
