# Batch Image Downloader — URLs & Pages to KV (`ingenious_quip_bxq/batch-image-downloader`) Actor

Download image URL lists or extract img/og:image from pages into KV store with metadata (contentType, bytes, sha256, dims). Default under 1 GB; failed/empty free. For RAG/archives — not spam scraping.

- **URL**: https://apify.com/ingenious\_quip\_bxq/batch-image-downloader.md
- **Developed by:** [新世紀書僮](https://apify.com/ingenious_quip_bxq) (community)
- **Categories:** Developer tools, AI, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 image downloadeds

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

## Batch Image Downloader — URLs & Pages to KV

**Download image URL lists (or extract `img` / `og:image` from pages) into Apify KV store with metadata for RAG and archives.**

Give this Actor a list of image URLs, HTML page URLs, or both. It fetches each image, stores the bytes in the default key-value store, and writes a dataset row with `contentType`, `bytes`, `sha256`, and dimensions when readable. Failed or empty responses are recorded free by default. Positioning: **batch media assets for Agent / dataset pipelines** — not spam scraping.

### What you get

- Direct **image URL** batch download into KV (`img-<sha256>.<ext>` by default)
- Optional **page extraction**: `<img src|srcset>`, `<picture>`, `og:image`, `twitter:image`
- Metadata: content type, byte size, SHA-256, width/height (via Pillow when possible)
- Optional **WebP / JPEG / PNG** re-encode (extra PPE event)
- **Duplicate content skip** by hash (free duplicate rows)
- Default **512 MB** memory; failed / 4xx / empty / non-image free unless you opt in

### Measured results

Cloud benches on build **0.1.2**, **512 MB** (Asia/Taipei 2026-10-02):

| Run | Input | Stored | Peak RSS | Platform cost |
|---|---|---|---|---|
| smoke | 3 URLs (2 ok / 1×404 free) | 2 | 87 MB | ~$0.00048 |
| bench | 12 URLs (10 ok / 2 err free) | 10 | 92 MB | ~$0.00082 (~$0.000082 / image) |
| pages | w3.org/Standards → 9 imgs | 9 | 93 MB | ~$0.00080 |

Details: `docs/PRICING.md`.

### Use cases

- Build an image asset pack from a sitemap-passed URL list for RAG multimodal pipelines
- Archive product or documentation images with integrity hashes
- Chain after sitemap discovery / URL status checker: only download live image URLs

### How to use

```json
{
  "imageUrls": [
    { "url": "https://www.w3.org/Icons/w3c_home.png" },
    { "url": "https://httpbin.org/image/png" }
  ],
  "pageUrls": [],
  "maxImages": 50,
  "maxConcurrency": 6,
  "skipDuplicatesByHash": true
}
```

Example success row:

```json
{
  "sourceUrl": "https://www.w3.org/Icons/w3c_home.png",
  "status": "success",
  "contentType": "image/png",
  "bytes": 2428,
  "width": 72,
  "height": 48,
  "sha256": "…",
  "kvKey": "img-<sha256>.png",
  "durationMs": 120
}
```

### Pricing (pay-per-event)

| Event | Price | When |
|---|---|---|
| Actor start | **$0.001** / GB (1 GB min) | Once per run |
| Image downloaded (primary) | **$0.0025** | Each successful KV store |
| Image converted | **$0.001** | Extra when `convertFormat` succeeds |
| Failed / empty / non-image / duplicate | **$0** | Default (`chargeFailedImages=false`) |

Example: 1,000 successful downloads ≈ **$2.50** + start (before platform CU/storage). Failed items are never charged by default.

### Known limits

- Does not log into sites or bypass paywalls / bot challenges
- SVG may lack width/height; dims come from Pillow for raster formats
- Very large pages: `maxImagesPerPage` caps extraction
- Copyright / robots: you are responsible for lawful use of downloaded assets
- Not a “scrape any website’s images” spam tool — designed for owned or permitted URL lists

### License

AGPL-3.0 (see `LICENSE`). Runtime stack: `httpx` (BSD), `beautifulsoup4` (MIT), `Pillow` (MIT-CMU), Apify SDK.

# Changelog

This Actor's version history is a separate document: https://apify.com/ingenious\_quip\_bxq/batch-image-downloader/changelog.md

# Actor input Schema

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

Direct image URLs to download. Accepts strings, {"url": "..."}, or requestListSources-style entries. Deduplicated, order preserved.

## `pageUrls` (type: `array`):

HTML pages to fetch. Extracts img\[src]/srcset], picture source, link\[rel=image\_src], meta og:image / twitter:image. Relative URLs resolved against the page.

## `maxImages` (type: `integer`):

Stop after downloading this many unique image URLs (0 = no limit). Caps cost.

## `maxImagesPerPage` (type: `integer`):

When extracting from pageUrls, keep at most this many image candidates per page (0 = no per-page cap).

## `maxBytesPerImage` (type: `integer`):

Skip (free) downloads larger than this many bytes. Default 15 MB.

## `maxConcurrency` (type: `integer`):

Parallel downloads. Keep moderate to stay polite and within 512 MB.

## `requestTimeoutSecs` (type: `integer`):

Timeout per HTTP request (page fetch or image download).

## `maxRetries` (type: `integer`):

Retries for transient network / 5xx failures.

## `minDelayMsPerHost` (type: `integer`):

Minimum milliseconds between starting downloads to the same host. 0 = no extra delay.

## `userAgent` (type: `string`):

HTTP User-Agent for page and image requests.

## `convertFormat` (type: `string`):

If set, re-encode successful downloads with Pillow and store the converted bytes (extra image-converted charge). Leave empty to store originals only.

## `convertQuality` (type: `integer`):

Quality 1–95 for WebP/JPEG conversion (ignored for PNG).

## `skipDuplicatesByHash` (type: `boolean`):

If on, identical bytes after the first success are recorded as status=duplicate (free) and not re-stored.

## `kvKeyPrefix` (type: `string`):

Prefix for stored file keys, e.g. img- → img-<sha256>.<ext>. Only a-zA-Z0-9!-\_.'() allowed (no slashes).

## `proxyConfiguration` (type: `object`):

Optional Apify Proxy. Off by default — use only when targets require it.

## `chargeFailedImages` (type: `boolean`):

When off (default), only successful KV stores are charged. Failed/4xx/empty/non-image/duplicate rows are saved free. When on, every attempted image URL is charged once.

## Actor input object example

```json
{
  "imageUrls": [
    {
      "url": "https://www.w3.org/Icons/w3c_home.png"
    },
    {
      "url": "https://httpbin.org/image/png"
    }
  ],
  "pageUrls": [],
  "maxImages": 50,
  "maxImagesPerPage": 100,
  "maxBytesPerImage": 15728640,
  "maxConcurrency": 6,
  "requestTimeoutSecs": 30,
  "maxRetries": 2,
  "minDelayMsPerHost": 50,
  "userAgent": "Mozilla/5.0 (compatible; BatchImageDownloader/0.1; +https://apify.com)",
  "convertFormat": "",
  "convertQuality": 85,
  "skipDuplicatesByHash": true,
  "kvKeyPrefix": "img-",
  "chargeFailedImages": false
}
```

# Actor output Schema

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

Default dataset items: sourceUrl, status, contentType, bytes, width, height, sha256, kvKey, pageUrl, errors, durationMs. Views: overview.

## `images` (type: `string`):

Binary image records under the configured kvKeyPrefix (default img-).

## `summary` (type: `string`):

Key-value store record SUMMARY (JSON): counts, charged, durationSecs, peakMemoryMb.

## `output` (type: `string`):

Key-value store record OUTPUT (JSON): same run summary as SUMMARY plus charged event counts.

# 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": [
        {
            "url": "https://www.w3.org/Icons/w3c_home.png"
        },
        {
            "url": "https://httpbin.org/image/png"
        }
    ],
    "pageUrls": [],
    "maxImages": 50,
    "skipDuplicatesByHash": true,
    "chargeFailedImages": false
};

// Run the Actor and wait for it to finish
const run = await client.actor("ingenious_quip_bxq/batch-image-downloader").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": [
        { "url": "https://www.w3.org/Icons/w3c_home.png" },
        { "url": "https://httpbin.org/image/png" },
    ],
    "pageUrls": [],
    "maxImages": 50,
    "skipDuplicatesByHash": True,
    "chargeFailedImages": False,
}

# Run the Actor and wait for it to finish
run = client.actor("ingenious_quip_bxq/batch-image-downloader").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": [
    {
      "url": "https://www.w3.org/Icons/w3c_home.png"
    },
    {
      "url": "https://httpbin.org/image/png"
    }
  ],
  "pageUrls": [],
  "maxImages": 50,
  "skipDuplicatesByHash": true,
  "chargeFailedImages": false
}' |
apify call ingenious_quip_bxq/batch-image-downloader --silent --output-dataset

```

## MCP server setup

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

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/8ZRvMuaaTGpUyj4JH/builds/r0dUQBT1vaK1IVHxt/openapi.json
