# Image Resizer: Bulk Resize, Crop and Pad Images from URLs (`kotaro-project/image-resizer`) Actor

Resize images in bulk from public URLs. Fit inside a box, fill and crop from the center, or pad to an exact size such as 1080x1080 or 1280x720. Keep the format or save as JPEG, PNG or WebP. Failed images are not charged.

- **URL**: https://apify.com/kotaro-project/image-resizer.md
- **Developed by:** [KOTARO project](https://apify.com/kotaro-project) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 image resizeds

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: Bulk Resize, Crop and Pad Images from URLs

Need every product photo at 1080x1080, or every thumbnail at 1280x720? Give this tool the image addresses and the size.

### Three modes

- **fit**: stays inside the box, ratio kept. Give only a width or only a height if you like.
- **fill**: covers the box exactly, cropping the overflow from the center.
- **pad**: exact box, ratio kept, empty space filled with your background color.

### Input

```json
{
  "imageUrls": ["https://example.com/photo.jpg"],
  "width": 1080,
  "height": 1080,
  "mode": "pad",
  "background": "#ffffff",
  "format": "webp"
}
```

### Output

One row per image, with a download link in `outputUrl`:

```json
{
  "sourceUrl": "https://example.com/photo.jpg",
  "outputUrl": "https://api.apify.com/v2/key-value-stores/.../records/image-1a2b3c.webp",
  "mode": "pad",
  "outputWidth": 1080,
  "outputHeight": 1080,
  "outputFormat": "webp",
  "outputBytes": 84210
}
```

### Notes

- Up to 200 images per run, 25 MB and 60 megapixels each.
- Only public addresses are accepted. Internal addresses are refused.
- The camera rotation is applied and metadata is removed.
- Animated images keep only their first frame.

### Pricing

Pay per resized image. Images that fail are not charged.

# Actor input Schema

## `imageUrls` (type: `array`):

Public http(s) addresses of the images to resize. Up to 200 per run, 25 MB each.

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

Target width. 0 means it follows the height (mode fit only).

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

Target height. 0 means it follows the width (mode fit only).

## `mode` (type: `string`):

fit: stays inside the box with the ratio kept. fill: covers the box exactly, cropping from the center. pad: exact box with the ratio kept, empty space filled with the background color.

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

same keeps the original format when it is JPEG, PNG or WebP; other formats become PNG.

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

For JPEG and WebP. Lower means smaller files.

## `background` (type: `string`):

Used by mode pad, and when a transparent image is saved as JPEG. Example: #ffffff.

## `enlarge` (type: `boolean`):

In mode fit, small images stay their size unless this is on.

## Actor input object example

```json
{
  "imageUrls": [
    "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"
  ],
  "width": 800,
  "height": 0,
  "mode": "fit",
  "format": "same",
  "quality": 85,
  "background": "#ffffff",
  "enlarge": false
}
```

# Actor output Schema

## `results` (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 = {
    "imageUrls": [
        "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kotaro-project/image-resizer").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 = { "imageUrls": ["https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"] }

# Run the Actor and wait for it to finish
run = client.actor("kotaro-project/image-resizer").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 '{
  "imageUrls": [
    "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"
  ]
}' |
apify call kotaro-project/image-resizer --silent --output-dataset

```

## MCP server setup

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

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/LcbmfYcPBj7CNFNl6/builds/5N5IiHJQ6rxnGKfMl/openapi.json
