# Image Resizer API (`igview-owner/image-resizer-api`) Actor

Professional image resizer API for automated batch image processing. Resize images to any dimensions with smart cropping, format conversion (JPEG, PNG, WebP, TIFF), and quality optimization. Perfect for web optimization, e-commerce thumbnails, social media content, and responsive design.

- **URL**: https://apify.com/igview-owner/image-resizer-api.md
- **Developed by:** [Sachin Kumar Yadav](https://apify.com/igview-owner) (community)
- **Categories:** Automation, Developer tools, E-commerce
- **Features:** Limited permissions
- **Stats:** 46 total users, 3 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $1.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

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

## Image Resizer API - Batch Image Processing & Smart Cropping

**Professional Image Resizer API** for automated batch image processing. Resize images to any dimensions with smart cropping, format conversion, and quality optimization. Perfect for web optimization, e-commerce, social media, and responsive design.

### Features

✅ **Multiple Image Formats**: Supports JPEG, PNG, WebP, TIFF\
✅ **Batch Processing**: Handle multiple images simultaneously\
✅ **Smart Cropping**: Intelligent face/subject detection using entropy analysis\
✅ **Flexible Resizing**: Multiple fit modes (cover, contain, fill, inside, outside)\
✅ **Format Conversion**: Convert between different image formats\
✅ **Quality Control**: Customizable compression settings\
✅ **Multiple Input Sources**: URLs, Base64, or Key-Value Store

### Pricing Model

This Actor uses **Pay-per-Event** pricing:

| Event | Cost | Description |
|-------|------|-------------|
| ACTOR_START | $0.01 | Charged once when Actor starts |
| ACTOR_PROCESSING | $0.005 | Charged for each image processed |
| ACTOR_COMPLETE | $0.005 | Charged once when Actor completes |

**Example Cost Calculation:**

- Processing 10 images = $0.01 (start) + $0.05 (10 × processing) + $0.005 (complete) = **$0.065**

### Input Configuration

#### Required Fields

- **images**: Array of image objects with one of:
  - `url`: Direct image URL
  - `base64`: Base64 encoded image data
  - `keyValueStoreKey`: Key from Apify Key-Value Store

#### Optional Fields

- **width**: Target width in pixels (1-10000)
- **height**: Target height in pixels (1-10000)
- **fit**: Resize mode
  - `cover`: Crop to fill dimensions (default)
  - `contain`: Fit within dimensions with letterboxing
  - `fill`: Stretch to exact dimensions
  - `inside`: Resize to fit inside dimensions
  - `outside`: Resize to fit outside dimensions
- **position**: Crop position for 'cover' mode
  - `smart`: Intelligent face/subject detection
  - `center`, `top`, `bottom`, `left`, `right`
- **format**: Output format (`jpeg`, `png`, `webp`, `tiff`)
- **quality**: 1-100 (default: 80)
- **backgroundColor**: RGBA color for letterboxing
- **outputFolder**: Folder name in Key-Value Store (default: "resized-images")

### Example Input

```json
{
  "images": [
    {
      "url": "https://example.com/image1.jpg"
    },
    {
      "url": "https://example.com/image2.png",
      "filename": "custom-name"
    }
  ],
  "width": 800,
  "height": 600,
  "fit": "cover",
  "position": "smart",
  "format": "webp",
  "quality": 85
}
```

### Output

Results are saved to the Dataset with:

```json
{
  "summary": {
    "totalImages": 2,
    "processedSuccessfully": 2,
    "errors": 0,
    "successRate": "100.00%"
  },
  "results": [
    {
      "success": true,
      "originalFilename": "image1.jpg",
      "outputFilename": "resized-images/image1_800x600.webp",
      "publicUrl": "https://api.apify.com/v2/key-value-stores/.../records/...",
      "originalSize": {
        "width": 1920,
        "height": 1080,
        "format": "jpeg",
        "bytes": 245678
      },
      "outputSize": {
        "width": 800,
        "height": 600,
        "format": "webp",
        "bytes": 45230
      },
      "compressionRatio": "81.58%"
    }
  ]
}
```

### Use Cases

#### 🌐 Web Development

Optimize images for responsive websites with multiple breakpoints

#### 🛒 E-commerce

Generate product thumbnails and multiple size variants

#### 📱 Social Media

Resize images for different platform requirements (Instagram, Facebook, Twitter)

#### 📰 Content Management

Batch process uploaded images for blogs and news sites

#### 📲 Mobile Apps

Create app icons and assets in various sizes

### API Integration

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_API_TOKEN' });

const run = await client.actor('YOUR_USERNAME/image-resize-api').call({
  images: [
    { url: 'https://example.com/image.jpg' }
  ],
  width: 800,
  height: 600,
  fit: 'cover',
  format: 'webp',
  quality: 85
});

const dataset = await client.dataset(run.defaultDatasetId).listItems();
console.log(dataset.items[0]);
```

### Smart Cropping

When using `"position": "smart"`, the Actor uses advanced algorithms to detect:

- 👤 Faces
- 🎯 Areas of interest (high contrast/detail)
- 📐 Composition balance

This ensures important subjects stay in frame when cropping.

### Performance Tips

1. **Batch Processing**: Group multiple images in one run to minimize startup costs
2. **WebP Format**: Best compression ratio for web use
3. **Quality Setting**: 80-85 is optimal for most use cases
4. **Smart Cropping**: Only use when needed (adds processing time)

### Support

For issues or questions:

- 📧 Create new issue
- 📖 Check [Apify documentation](https://docs.apify.com)

### License

Apache-2.0

# Actor input Schema

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

Array of images to resize. Each image can be provided as URL, base64, or Key-Value Store key.

## `width` (type: `integer`):

Target width in pixels. Leave empty for auto-scaling based on height.

## `height` (type: `integer`):

Target height in pixels. Leave empty for auto-scaling based on width.

## `fit` (type: `string`):

How the image should be resized to fit the dimensions.

## `position` (type: `string`):

Position for cropping (when fit is 'cover'). Use 'smart' for intelligent face/subject detection.

## `format` (type: `string`):

Output image format. Leave empty to keep original format.

## `quality` (type: `integer`):

Output quality (1-100). Higher values mean better quality but larger file size.

## `outputFolder` (type: `string`):

Folder name in Key-Value Store for output images

## Actor input object example

```json
{
  "images": [
    {
      "url": "https://images.unsplash.com/photo-1506748686214-e9df14d4d9d0"
    }
  ],
  "width": 800,
  "height": 600,
  "fit": "cover",
  "position": "center",
  "quality": 80,
  "outputFolder": "resized-images"
}
```

# 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://images.unsplash.com/photo-1506748686214-e9df14d4d9d0"
        }
    ],
    "width": 800,
    "height": 600
};

// Run the Actor and wait for it to finish
const run = await client.actor("igview-owner/image-resizer-api").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://images.unsplash.com/photo-1506748686214-e9df14d4d9d0" }],
    "width": 800,
    "height": 600,
}

# Run the Actor and wait for it to finish
run = client.actor("igview-owner/image-resizer-api").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://images.unsplash.com/photo-1506748686214-e9df14d4d9d0"
    }
  ],
  "width": 800,
  "height": 600
}' |
apify call igview-owner/image-resizer-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,igview-owner/image-resizer-api"
        }
    }
}
```

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/Kblnaui1gGFL9QTzC/builds/5MVDuzrP37Ksf9vdJ/openapi.json
