# Bulk Image Downloader \[USD 0.50/1K images] (`usefulapi/bulk-image-downloader`) Actor

Download images in bulk from image links or whole web pages (img, srcset, picture, lazy-load, og:image, JSON-LD, CSS backgrounds). Real format, pixel size and SHA-256 read from the bytes, icons and duplicates skipped, every file saved with a ready ZIP link.

- **URL**: https://apify.com/usefulapi/bulk-image-downloader.md
- **Developed by:** [Useful API](https://apify.com/usefulapi) (community)
- **Categories:** E-commerce, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 images

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

## Bulk Image Downloader

Download images in bulk from **image links or whole web pages**. Give it a list of image URLs, page URLs, or both: page
links are read and every image on them is found, image links are downloaded as they are. Each image is **measured from
its own bytes** (real format, pixel width and height, SHA-256), images under your minimum size (default 50 x 50 px) are
skipped, which drops tracking pixels and most small icons (an SVG is measured by its declared width, height or viewBox, so
vector icons can pass: leave `svg` out of the formats to skip them), duplicates are saved once, and every file lands in a store of its own with a ready **ZIP link**.

### What it finds on a page (no browser)

- `<img>` `src` and `srcset` (the **largest** candidate), `<picture><source>` (the largest source), lazy-load attributes
  (`data-src`, `data-srcset`, `data-original`, `data-lazy-src` and similar)
- `og:image`, `twitter:image`, `link rel="image_src"`, `link rel="preload" as="image"`
- JSON-LD `image`, `logo`, `thumbnailUrl`, `contentUrl` fields (Product, Article, Organization ...)
- CSS backgrounds in `style` attributes and `<style>` blocks, `<video poster>`
- optional: links straight to image files (`<a href="photo.jpg">`), and every size of every `srcset`

Relative links and `<base href>` are resolved. When sources differ only by screen size, the largest one is taken
(width descriptors first, then the width the CDN link asks for, such as `?width=620&dpr=2`).

### What you get per image

Real format (JPEG, PNG, WebP, GIF, AVIF, HEIC, SVG, BMP, TIFF, ICO), pixel width and height, bytes, SHA-256, the
server's Content-Type and whether it matches the bytes, the page it was found on, its alt text, which tag it came
from, its key in the store and a direct signed link to the file.

The pixel size is read from the file header while downloading: an image under your minimum size (default 50 x 50 px)
is stopped as soon as its size is known. Width and height are the stored pixel size: a JPEG's EXIF orientation (or a
HEIC/AVIF rotation) is not applied, so a portrait phone photo stored on its side reads as landscape.

### Input examples

Pages:

```json
{ "urls": ["https://en.wikipedia.org/wiki/Bird", "https://en.wikipedia.org/wiki/Paris"], "maxImagesPerPage": 40 }
```

Image links, metadata only (nothing saved):

```json
{ "urls": ["https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"], "mode": "images", "storeFiles": false }
```

Only large photos:

```json
{ "urls": ["https://www.allbirds.com/collections/mens"], "minWidth": 600, "minHeight": 400, "formats": ["jpeg", "webp", "png"] }
```

`mode`: `auto` (default: links ending in an image extension are images, others are pages; a page link that answers with
an image is downloaded too), `images` or `pages`.

### Output

One row per page and per image (dataset views "Images" and "All fields"). A real row from a test run:

```json
{
  "type": "image",
  "status": "ok",
  "imageUrl": "https://upload.wikimedia.org/wikipedia/commons/f/fe/Bar-tailed_Godwit_migration.jpg?utm_source=en.wikipedia.org&utm_campaign=parser&utm_content=thumbnail_unscaled",
  "sourcePage": "https://en.wikipedia.org/wiki/Bird",
  "foundIn": ["srcset"],
  "alt": "A map of the Pacific Ocean with several coloured lines representing bird routes running from New Zealand to Korea",
  "format": "jpeg",
  "mimeType": "image/jpeg",
  "width": 416,
  "height": 408,
  "bytes": 31685,
  "sha256": "08e40c73787746e8051eaa84595a40dffe8dace4d9d077691f4cb95edf082bd2",
  "contentTypeHeader": "image/jpeg",
  "contentTypeMatches": true,
  "key": "images__08e40c73-Bar-tailed_Godwit_migration.jpg",
  "fileUrl": "https://api.apify.com/v2/key-value-stores/0JeSgLucMqTYb6i2s/records/images__08e40c73-Bar-tailed_Godwit_migration.jpg?signature=...",
  "billedAs": { "event": "image", "megabytes": 0 },
  "filesStoreId": "0JeSgLucMqTYb6i2s",
  "zipUrl": "https://api.apify.com/v2/key-value-stores/0JeSgLucMqTYb6i2s/records?prefix=images__&signature=..."
}
```

Image statuses: `ok`, `too_small`, `format_skipped`, `duplicate`, `too_large`, `not_an_image`, `not_found`,
`forbidden`, `rate_limited`, `server_error`, `http_error`, `timeout`, `too_slow`, `unreachable`, `dns_not_found`,
`private_address`, `blocked_port`, `blocked_by_robots`, `store_failed`, `cost_limit`.
Page rows: `ok` (with `imagesFound` and `imagesQueued`), `blocked_by_robots`, `blocked` (a bot check page), errors.
The run's **OUTPUT** record has the totals, `filesStoreId` and `zipUrl`.

### Where the files are, and for how long

Images are saved in a key-value store created for your run (not the run's default store, so the links never expose
your input), under keys `images__<first 8 of SHA-256>-<name>.<ext>`. `fileUrl` and `zipUrl` are signed: they open
without an API token; the ZIP link is valid for 7 days. The store is unnamed, so Apify deletes it after your plan's data
retention period (7 days on most plans): download the ZIP or copy the files before then.

### Pricing (pay per event)

| Event | Price |
|---|---|
| Run start | USD 0.005 |
| Image saved (or measured, with saving off) | **USD 0.0005 (USD 0.50 per 1,000)** |
| Each started MB beyond an image's first MB | USD 0.0002 |
| Page read | USD 0.001 |
| Link or image without a new image (broken, too small, other format, duplicate, over the cap) | USD 0.00015 |
| Image found on a page that is not there (robots.txt, 404, a web page instead of an image) | free |

The megabyte event counts every byte received for a link, including retries and downloads stopped part way (too slow,
over your size cap, your cost limit), so one link bills at most (retries + 1) x your size cap in megabytes. A download
stopped by the 120 s per-image time cap is not retried.

Measured on Apify: 10 Wikipedia articles gave 278 saved images (52 MB) in 274 seconds. Set a maximum cost per run and the
Actor stops cleanly before it, keeping every row it saved.

### Good to know

- Pages are read only when robots.txt allows it (rules for `UsefulApiBot`, else `*`); images found on a page are checked
  against their host's robots.txt too. Image links you give directly are downloaded as given.
- User agent: `Mozilla/5.0 (compatible; UsefulApiBot/1.0; +https://apify.com/usefulapi)` for pages, robots.txt and
  image files. Sites that refuse bots are reported in the row's status, not worked around.
- No browser: images that a page adds with JavaScript after loading are not seen.
- At most 2 requests at a time to one host, with a short pause between them; a host that fails 3 times in a row is
  skipped for the rest of the run. Private, loopback and cloud metadata addresses are refused on every hop.
- Download only images you have the right to use.

# Actor input Schema

## `urls` (type: `array`):

One link per line. A link to an image file is downloaded as it is. A link to a web page is read (robots.txt respected) and every image on it is found: img, srcset (largest size), picture, lazy-load attributes, og:image, twitter:image, JSON-LD, CSS backgrounds and, when asked, links to image files. Up to 20,000 links per run.

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

Auto is right for a mixed list. Choose images when your image links have no extension (no robots.txt is read for them); choose pages when your page links end in .jpg or .png.

## `minWidth` (type: `integer`):

Images narrower than this are skipped (icons, tracking pixels, spacers). The size is read from the image's own bytes; the download stops as soon as the size is known. 0 keeps everything. SVG files without a stated size are kept.

## `minHeight` (type: `integer`):

Images lower than this are skipped. 0 keeps everything.

## `formats` (type: `array`):

Formats are read from the bytes, not from the link or the server's Content-Type. Leave empty for all except HEIC.

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

Stop taking images from one page after this many are saved. Up to 3 times this number (at most 500) of the page's images are checked.

## `maxFileSizeMb` (type: `integer`):

Larger images are skipped: checked from the Content-Length header before the download, and cut while downloading when the server does not say.

## `storeFiles` (type: `boolean`):

Off: metadata only (format, pixel size, bytes, SHA-256), nothing saved. Images are still downloaded to be measured.

## `dedupe` (type: `boolean`):

An image with the same bytes (SHA-256) as one already saved in this run is not saved again; its row points to the first copy.

## `allSrcsetSizes` (type: `boolean`):

Off: one image per img or picture element, the largest candidate. On: every size listed in srcset and every picture source.

## `linkedImages` (type: `boolean`):

Also take links that point to image files (<a href="photo.jpg">), often the full-size version of a thumbnail. Off by default: on Wikipedia and many CMSs those links lead to HTML pages about the file, not to the file.

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

Stop after this many images are saved (leave empty for no limit).

## `retries` (type: `integer`):

Extra tries for an image that got no answer, a server error, a 429, or came too slowly (waits 2 s, then 6 s, then 12 s). Not after the 120 s per-image time cap. Every retry's bytes count toward the megabyte event.

## `concurrency` (type: `integer`):

Downloads at the same time across all sites. At most 2 at a time go to one host, with a short pause between them, whatever this number.

## Actor input object example

```json
{
  "urls": [
    "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
    "https://en.wikipedia.org/wiki/Bird"
  ],
  "mode": "auto",
  "minWidth": 50,
  "minHeight": 50,
  "formats": [
    "jpeg",
    "png",
    "webp",
    "gif",
    "avif",
    "svg",
    "bmp",
    "tiff",
    "ico"
  ],
  "maxImagesPerPage": 100,
  "maxFileSizeMb": 20,
  "storeFiles": true,
  "dedupe": true,
  "allSrcsetSizes": false,
  "linkedImages": false,
  "retries": 1,
  "concurrency": 10
}
```

# Actor output Schema

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

No description

## `details` (type: `string`):

No description

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

No description

## `store` (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 = {
    "urls": [
        "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
        "https://en.wikipedia.org/wiki/Bird"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("usefulapi/bulk-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 = { "urls": [
        "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
        "https://en.wikipedia.org/wiki/Bird",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("usefulapi/bulk-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 '{
  "urls": [
    "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
    "https://en.wikipedia.org/wiki/Bird"
  ]
}' |
apify call usefulapi/bulk-image-downloader --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,usefulapi/bulk-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/hXX0Vgew1wpw7uIVE/builds/PjdL9WEzbDe2NN9ju/openapi.json
