# WhatsApp Product Image Resizer (Carousel, Catalog, Templates) (`treplit/whatsapp-product-image-resizer-carousel-catalog-templates`) Actor

Prepare inventory for WhatsApp sales actions & catalogs. Smart padding ensures fashion products are never cropped in Carousels or Thumbnails. Automate formatting for bulk marketing pushes. Supports all API specs (1125x600, <5MB) to maximize conversion rates.

- **URL**: https://apify.com/treplit/whatsapp-product-image-resizer-carousel-catalog-templates.md
- **Developed by:** [Treplit](https://apify.com/treplit) (community)
- **Categories:** E-commerce, Social media, Developer tools
- **Security:** Limited permissions
- **Stats:** 26 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## 🖼️ WhatsApp Image Resizer

**Automatically resize, pad, and optimize product images for WhatsApp Business API formats.**

Transform product photos into WhatsApp-ready images in seconds. No manual work, no cropping disasters, no file size rejections.

![Before and After](https://api.apify.com/v2/key-value-stores/tQZV7u0zsPESUnc5s/records/assets-general_examples-before_after.png)

***

### 📍 What Does WhatsApp Image Resizer Do?

**WhatsApp Image Resizer** is a specialized image processing Actor designed to prepare product catalog images, marketing carousels, and message headers for the WhatsApp Business API.

WhatsApp enforces strict dimension and file size limits (e.g., **1125×600px** for carousels, **<5MB** file size). Manually resizing thousands of product images is tedious and often leads to awkward cropping or quality loss.

This Actor automates the entire workflow:

1. **Accepts images** via public URLs or Base64
2. **Resizes** them to exact WhatsApp specifications
3. **Smartly pads** images (instead of cropping) to preserve the entire product view
4. **Compresses** files to meet strict size limits (especially the 2MB limit for headers)
5. **Returns** public URLs ready for your API calls

**Built for**: E-commerce businesses, marketing agencies, and developers building on the WhatsApp Business Platform.

***

### 🎯 Why Use WhatsApp Image Resizer?

#### The Problem

- WhatsApp rejects images that don't match exact dimensions (1125×600, 640×640, etc.)
- Cropping product images loses important details (especially for tall/portrait photos)
- File size limits (5MB for media, 2MB for headers) cause frequent rejections
- Manually processing hundreds of product images is time-consuming and error-prone

#### The Solution

- **Automated Processing**: Batch process up to 100 images in one run
- **Smart Padding**: Preserves entire product view with intelligent background fill
- **Guaranteed Compliance**: Every output meets WhatsApp's exact specifications

***

### ✨ Features

- **Exact WhatsApp Formats**: Pre-configured presets for:
  - `carousel` (1125×600px)
  - `catalog_thumbnail` (640×640px)
  - `template_header` (1125×600px)
- **Smart Padding**: Never cuts off your product. Adds padding (solid color, blurred, or edge-extended) to fit the aspect ratio. [See examples below](#-padding-modes-explained).
- **Auto-Compression**: Uses a binary search algorithm to find the highest quality that fits within WhatsApp's file size limits (5MB or 2MB).
- **Batch Processing**: Process up to 100 images in a single run.
- **Privacy & Security**: Includes SSRF protection to prevent access to internal network resources.
- **High Performance**: Built with Python's `Pillow` and `httpx` for fast, async processing.

***

### 🎨 Padding Modes Explained

When your product image doesn't match WhatsApp's required aspect ratio (e.g., a tall portrait photo going into a wide 1125×600 carousel), the Actor adds padding to the sides. You can choose how that padding looks:

#### Original Image

![Original product image](https://api.apify.com/v2/key-value-stores/tQZV7u0zsPESUnc5s/records/assets-example_inputs-sample-01.jpg)
*Portrait product photo (before processing)*

#### Edge Extend (`edge_extend`)

Stretches the edge pixels of the image outward. Creates a seamless transition that feels natural.

![Edge extend padding mode](https://api.apify.com/v2/key-value-stores/tQZV7u0zsPESUnc5s/records/assets-example_outputs-sample-01-carousel-edge-extend.jpg)

**Best for**: Photos with gradient backgrounds, studio shots, images where you want the background to "continue".

```json
{
    "expansionMode": "edge_extend"
}
```

#### Solid (`solid`)

Fills the padding area with a single solid color. Clean and professional.

![Solid padding mode](https://api.apify.com/v2/key-value-stores/tQZV7u0zsPESUnc5s/records/assets-example_outputs-sample-01-carousel-solid.jpg)

**Best for**: White background product photos, catalog images, minimalist brands.

```json
{
    "expansionMode": "solid",
    "backgroundColor": "#FFFFFF"
}
```

#### Blur (`blur`)

Creates a softly blurred version of the image edges to fill the padding. Adds visual depth without distraction.

![Blur padding mode](https://api.apify.com/v2/key-value-stores/tQZV7u0zsPESUnc5s/records/assets-example_outputs-sample-01-carousel-blur.jpg)

**Best for**: Lifestyle photos, fashion items, images with colored backgrounds.

```json
{
    "expansionMode": "blur"
}
```

#### Quick Comparison

| Mode | Effect | Best Use Case |
|------|--------|---------------|
| `edge_extend` | Stretched edge pixels | Gradient/studio backgrounds |
| `solid` | Clean solid color fill | White/plain backgrounds |
| `blur` | Soft blurred edges | Lifestyle & fashion photos |

***

### 🖼️ Combining Multiple Images

Show multiple product angles or variants in a single WhatsApp card by combining 2 or 3 images side-by-side. Set `combineImages: true` to enable this feature.

#### 2 Images Combined

![Two images combined](https://api.apify.com/v2/key-value-stores/tQZV7u0zsPESUnc5s/records/assets-example_outputs-combined-01-02-carousel-edge-extend.jpg)

```json
{
    "images": [
        { "url": "https://myshop.com/product-front.jpg" },
        { "url": "https://myshop.com/product-back.jpg" }
    ],
    "targetFormat": "carousel",
    "combineImages": true
}
```

#### 3 Images Combined

![Three images combined](https://api.apify.com/v2/key-value-stores/tQZV7u0zsPESUnc5s/records/assets-example_outputs-combined-01-02-03-template-header-edge-extend.jpg)

```json
{
    "images": [
        { "url": "https://myshop.com/product-front.jpg" },
        { "url": "https://myshop.com/product-side.jpg" },
        { "url": "https://myshop.com/product-back.jpg" }
    ],
    "targetFormat": "template_header",
    "combineImages": true
}
```

**Best for**: Product variants, multiple angles, before/after comparisons, color options.

***

### 🎓 How to Resize Images for WhatsApp Business API

Follow these simple steps to prepare your product images for WhatsApp:

#### 1. Prepare Your Image URLs

Ensure your images are publicly accessible via HTTPS. You can use:

- Your e-commerce platform (Shopify, WooCommerce, etc.)
- Cloud storage (AWS S3, Google Cloud Storage, Cloudinary)
- Any public CDN or web server

Alternatively, provide images as **Base64-encoded strings** for private images.

#### 2. Choose Your WhatsApp Format

Select the format that matches your use case:

- **`carousel`** (1125×600px) - For product carousels in marketing messages
- **`catalog_thumbnail`** (640×640px) - For product catalog thumbnails
- **`template_header`** (1125×600px, max 2MB) - For message template headers

#### 3. Configure the Actor Input

In the **Input** tab, paste your configuration:

```json
{
    "images": [
        { "url": "https://yourstore.com/product1.jpg" },
        { "url": "https://yourstore.com/product2.jpg" }
    ],
    "targetFormat": "carousel"
}
```

**Note**: The `id` field is optional. If omitted, results are returned in the same order as your input URLs.

#### What You Pay For

- ✅ Successfully processed images (charged at $0.01 each)
- ❌ Failed images (download errors, invalid formats) are **NOT charged**

#### Why Pay-Per-Event?

- **Transparent**: Know exactly what you'll pay before running
- **Fair**: Only charged for successful outputs
- **Predictable**: No hidden compute costs or variable pricing
- **Controlled**: Set spending limits to prevent overruns

***

### 💼 Use Cases

- E-commerce stores preparing product images for WhatsApp catalogs
- Marketing agencies creating carousel campaigns
- WhatsApp chatbot developers processing user-uploaded images
- Product launches requiring bulk image preparation
- Multi-channel retailers repurposing product photography

***

### ⬇️ How to Configure WhatsApp Image Resizing Input

The input is a JSON object containing a list of images and configuration settings. You can provide images via `url` or `data` (base64).

#### Minimal Example (Just URLs)

```json
{
    "images": [
        { "url": "https://myshop.com/images/shoe_v1.jpg" },
        { "url": "https://myshop.com/images/shirt_red.png" }
    ],
    "targetFormat": "carousel"
}
```

**Results are returned in the same order as your input URLs** - no `id` field required!

#### With Custom IDs (Optional)

If you need to track specific images, add an optional `id` field:

```json
{
    "images": [
        { "url": "https://myshop.com/images/shoe_v1.jpg", "id": "sku-123" },
        { "url": "https://myshop.com/images/shirt_red.png", "id": "sku-456" }
    ],
    "targetFormat": "carousel"
}
```

#### Full Configuration Example

```json
{
    "images": [
        { "url": "https://myshop.com/images/shoe_v1.jpg", "id": "product-001" },
        { "url": "https://myshop.com/images/shirt_red.png", "id": "product-002" }
    ],
    "targetFormat": "carousel",
    "backgroundColor": "#FFFFFF",
    "outputFormat": "jpeg",
    "outputQuality": 85,
    "expansionMode": "edge_extend"
}
```

See the **Input** tab for a full description of all parameters.

***

### ⬆️ WhatsApp Image Resizer Output Data

The Actor stores results in two places:

1. **Key-Value Store**: The actual processed image files (JPEGs/PNGs)
2. **Dataset**: A JSON record for each processed image containing metadata and the public URL

#### Output Data Fields

Each processed image returns the following data points:

| Field | Description | Example Value |
|-------|-------------|---------------|
| `success` | Processing status | `true` or `false` |
| `id` | Your custom identifier (optional) | `"sku-123"` or `null` |
| `sourceUrl` | Original image URL | `"https://myshop.com/image.jpg"` |
| `publicUrl` | **WhatsApp-ready URL** | `"https://api.apify.com/v2/key-value-stores/..."` |
| `originalWidth` | Source image width | `2400` |
| `originalHeight` | Source image height | `3600` |
| `outputWidth` | Final width (WhatsApp format) | `1125` |
| `outputHeight` | Final height (WhatsApp format) | `600` |
| `outputFormat` | Image format (jpeg/png) | `"jpeg"` |
| `fileSizeBytes` | Final file size (must be <5MB or <2MB) | `145023` |
| `targetFormat` | WhatsApp format used | `"carousel"` |
| `processingTimeMs` | Processing duration | `845` |

#### Dataset Item Example

```json
{
    "success": true,
    "id": "sku-123",
    "sourceUrl": "https://myshop.com/images/shoe_v1.jpg",
    "publicUrl": "https://api.apify.com/v2/key-value-stores/mI5.../records/sku-123-carousel.jpg",
    "originalWidth": 2400,
    "originalHeight": 3600,
    "outputWidth": 1125,
    "outputHeight": 600,
    "outputFormat": "jpeg",
    "fileSizeBytes": 145023,
    "targetFormat": "carousel",
    "processingTimeMs": 845
}
```

#### Error Example

```json
{
    "success": false,
    "id": "sku-999",
    "error": "DOWNLOAD_FAILED",
    "message": "HTTP 404: Image not found"
}
```

***

### 🧩 Integrations

Since this Actor outputs clean JSON data, it integrates easily with:

- **N8N / Make.com / Zapier**: Trigger the Actor when a new product is added to Shopify/WooCommerce, then send the `publicUrl` to your WhatsApp API provider (Twilio, Meta, WATI, etc.).
- **Custom API**: Call this Actor via the [Apify API](https://docs.apify.com/api/v2) to process images on-demand for your application.

***

### ❓ WhatsApp Image Processing FAQ

#### Why padding instead of cropping?

WhatsApp images (especially carousels) have a wide aspect ratio (1.91:1). Most product photos are portrait (2:3) or square (1:1). Cropping to 1.91:1 would remove the top and bottom of your product. Padding ensures the **entire** product is visible and centered.

#### Can I combine images?

Yes! Set `combineImages: true` to stitch 2 or 3 images side-by-side. This is great for showing multiple angles of a product in a single carousel card.

#### How much does it cost to resize images for WhatsApp?

Simple, transparent pricing: **$0.01 per image** ($1 per 100 images, $10 per 1,000 images). Only successfully processed images are charged - failed images are free. You can set spending limits to control costs. See the [Pricing section](#-how-much-does-whatsapp-image-processing-cost) for details.

#### Can I process images in Python?

While this Actor is built with Python, you interact with it through Apify's platform (UI or API). No Python knowledge required. For custom Python integrations, use the [Apify Python SDK](https://docs.apify.com/sdk/python).

#### What's the difference between carousel and catalog formats?

- **Carousel** (1125×600px): Wide format for marketing messages with multiple product cards
- **Catalog** (640×640px): Square thumbnails for WhatsApp Business product catalogs
- **Template Header** (1125×600px, max 2MB): Headers for message templates with stricter size limits

#### How do I integrate with Shopify or WooCommerce?

Use automation platforms like **Make.com**, **Zapier**, or **n8n**:

1. Trigger: New product added to your store
2. Action: Extract product image URL
3. Action: Run this Actor with the image URL
4. Action: Send the `publicUrl` to your WhatsApp Business provider

#### Can I use this for other platforms besides WhatsApp?

Yes! While optimized for WhatsApp, the presets work for any platform with similar requirements. The smart padding and compression features are useful for any image processing workflow.

#### What happens if an image fails to process?

The Actor returns a JSON object with `"success": false`, an error code (e.g., `DOWNLOAD_FAILED`), and a descriptive message. Failed images don't stop the batch - other images continue processing.

#### Do I need to provide an ID for each image?

No! The `id` field is completely optional. If you omit it, the Actor will still process your images and return results **in the same order** as your input URLs. Use IDs only if you need to track specific images (like SKUs or product codes).

# Actor input Schema

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

List of images to resize. Each image must have either a URL or base64-encoded data.

## `targetFormat` (type: `string`):

WhatsApp format to resize images to. Carousel (1.91:1) and Template Header (1.91:1) are 1125x600px. Catalog Thumbnail is 640x640px (1:1).

## `outputFormat` (type: `string`):

Image format for the processed output. JPEG is recommended for photos. PNG supports transparency.

## `outputQuality` (type: `integer`):

JPEG compression quality (1-95). Lower values reduce file size but may show artifacts. 85 is a good balance. Only applies when Output Format is JPEG.

## `backgroundColor` (type: `string`):

Hex color code for the padding area (the 'bars' added to fit the aspect ratio). Supports #RGB and #RRGGBB formats.

## `expansionMode` (type: `string`):

Strategy for filling the empty space when the image aspect ratio doesn't match the target. 'Edge Extend' repeats the last pixel (subtle). 'Blur' creates a blurred background version. 'Solid' uses the Background Color.

## `combineImages` (type: `boolean`):

Stitch all input images side-by-side into a single output image. Useful for showing multiple product angles in one carousel card.

## `combineSpacing` (type: `integer`):

Gap width in pixels between combined images. Only used when 'Combine Images' is enabled.

## Actor input object example

```json
{
  "images": [
    {
      "url": "https://picsum.photos/id/26/1000/1500",
      "id": "sample-product"
    }
  ],
  "targetFormat": "carousel",
  "outputFormat": "jpeg",
  "outputQuality": 85,
  "backgroundColor": "#FFFFFF",
  "expansionMode": "edge_extend",
  "combineImages": false,
  "combineSpacing": 20
}
```

# Actor output Schema

## `overview` (type: `string`):

Overview of all processed images with status and download URLs

## `successful` (type: `string`):

View only successfully processed images

## `errors` (type: `string`):

View images that failed to process

## `keyValueStore` (type: `string`):

Key-value store containing the processed image files

# 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": [
        {
            "url": "https://picsum.photos/id/26/1000/1500",
            "id": "sample-product"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("treplit/whatsapp-product-image-resizer-carousel-catalog-templates").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": [{
            "url": "https://picsum.photos/id/26/1000/1500",
            "id": "sample-product",
        }] }

# Run the Actor and wait for it to finish
run = client.actor("treplit/whatsapp-product-image-resizer-carousel-catalog-templates").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": [
    {
      "url": "https://picsum.photos/id/26/1000/1500",
      "id": "sample-product"
    }
  ]
}' |
apify call treplit/whatsapp-product-image-resizer-carousel-catalog-templates --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,treplit/whatsapp-product-image-resizer-carousel-catalog-templates"
        }
    }
}
```

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/UhELiNUHwI2kVLWS3/builds/rfrmpHRxeOlImUc5J/openapi.json
