# Bulk Image Downloader & Compressor: Full-Size, WebP, ZIP (`webstack-labs/bulk-image-downloader`) Actor

Download all images from web pages, direct links, a CSV/TXT list of URLs or Dropbox/Drive share links at full size (srcset, lazy, og:image, CSS). Compress to a target size in KB, convert to WebP/JPEG/PNG, resize, dedupe; one ZIP. $0.0015 per file saved; failed files free.

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

## Pricing

from $1.50 / 1,000 file saveds

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 & Compressor: Full-Size, WebP, ZIP

Download every image from a list of web pages, or from direct image links, in one run, and optionally compress
them to a size you choose: you get each file in
the key-value store, one row per file with its link, size and alt text, and all files in one ZIP.

- **Finds the full-size image**: takes the largest candidate of `srcset`, lazy-loaded images (`data-src`,
  `data-srcset`), `<picture>` sources, social preview images (`og:image`, `twitter:image`) and CSS background
  images, not only the small `src` thumbnail.
- **Direct links work too**: mix pages and image/file URLs in one list.
- **Bulk lists**: give a link to a `.txt` or `.csv` file of URLs (`urlListFile`, any column, up to 1,000 URLs)
  instead of pasting them.
- **Dropbox and Google Drive share links** of an image or file (shared with anyone who has the link) are turned
  into download links, with the original file name.
- **Linked files** (optional): PDFs, ZIPs, CSVs, Office files, MP4/MP3 that a page links to.
- **Clean results**: skip images below a minimum width/height, 1x1 tracking pixels and duplicates (same SHA-256),
  optionally only images from the same site.
- **Image compressor**: set `targetSizeKb` (for example 200) and every photo or graphic is made at most that many
  kilobytes: lower JPEG/WebP quality first, a 256-colour palette for PNG, and a smaller size only when needed.
  Each row shows `originalBytes`, `bytes` and `overTargetSize`. Works on direct image links too, so it is also a
  bulk image compressor for files you already host.
- **Convert and resize**: WebP, JPEG or PNG, longest side limit, quality setting.
- **One ZIP** with folders by site, plus a public link per file.
- **Fair price**: $0.0015 per saved file ($1.50 per 1,000). Failed, skipped and duplicate files are free.

### Who uses it

- Marketers and agencies backing up or auditing the images of a website (sizes, missing alt text).
- E-commerce teams collecting product photos from their own or their suppliers' pages.
- AI and data teams building image datasets from pages they may use (deduplicated, resized, with alt text as
  a caption).
- Developers who need image URLs with dimensions for a migration.

### Input

```json
{
  "urls": ["https://books.toscrape.com/", "https://example.com/photo.jpg"],
  "maxFiles": 500,
  "minWidth": 200,
  "convertTo": "webp",
  "maxDimension": 1600,
  "targetSizeKb": 300,
  "dedupe": true,
  "createZip": true,
  "linkedFileTypes": ["pdf"]
}
```

Give `urls`, or `urlListFile` (a link to a .txt/.csv list of URLs), or both. A page URL gives all images in its HTML; a link to an image or file is saved as it is.

### Output

One row per file (dataset), with the same fields in every row:

```json
{
  "url": "https://books.toscrape.com/media/cache/2c/da/2cdad67c44b002e7ead0cc35693c0e8b.jpg",
  "pageUrl": "https://books.toscrape.com/",
  "pageTitle": "All products | Books to Scrape - Sandbox",
  "status": "ok",
  "kind": "image",
  "fileName": "2cdad67c44b002e7ead0cc35693c0e8b.jpg",
  "key": "file-00001-2cdad67c44b002e7ead0cc35693c0e8b.jpg",
  "fileUrl": "https://api.apify.com/v2/key-value-stores/<store>/records/file-00001-2cdad67c44b002e7ead0cc35693c0e8b.jpg",
  "mimeType": "image/jpeg",
  "extension": "jpg",
  "width": 120,
  "height": 174,
  "bytes": 6200,
  "originalBytes": 6200,
  "originalFormat": "JPEG",
  "converted": false,
  "overTargetSize": null,
  "sha256": "…",
  "alt": "A Light in the Attic",
  "foundIn": "img",
  "billed": true,
  "downloadedAt": "2026-11-11T09:00:00+00:00",
  "error": null,
  "errorMessage": null
}
```

(Values shortened for illustration.) Rows with `status` `skipped` (duplicate, too small), `failed` (HTTP error,
robots.txt, too large) or `no_images` (a page without image links) explain why in `error` and `errorMessage`
and are not charged. The key-value store holds every saved file (`file-00001-….jpg`), `images.zip` and a
`SUMMARY` record (counts, reasons, `zipUrl`).

### Pricing

Pay per event: **$0.0015 per saved file** ($1.50 per 1,000), conversion and resizing included, plus Apify's small
start fee. Failed downloads, duplicates, filtered images, pages without images and the ZIP are free. Set a
maximum cost per run in Apify, or `maxFiles`, to cap the bill.

### Use it from AI agents (MCP)

Agents (Claude, ChatGPT, Cursor and others through Apify's MCP server `mcp.apify.com` or the API) can call it
with one page URL:

```json
{"urls": ["https://books.toscrape.com/"], "maxFiles": 20}
```

The first rows of the output then look like the example above: one row per image with `fileUrl`, `width`,
`height`, `alt` and `pageUrl`; the ZIP link is in the `SUMMARY` record. This example run saves 20 files and
costs 20 x $0.0015 = $0.03 plus the start fee.

### How it works

1. Each URL is checked against the site's robots.txt (on by default), then fetched with an honest User-Agent
   (`WebsiteImageDownloaderBot`), 6 downloads at a time.
2. HTML pages are parsed for image links (largest `srcset` candidate first); other responses are files.
3. Each file is checked with Pillow (format, width, height), filtered, optionally converted, resized or compressed to `targetSizeKb`,
   hashed (SHA-256) and saved; then charged.
4. The ZIP and the summary are written at the end.

### FAQ

**Does it run JavaScript?** No browser is used, which keeps it cheap. Images that only appear after JavaScript
runs (infinite scroll, some single-page apps) are not seen; images in the HTML, including lazy-load attributes,
are. For such pages, give the image links directly.

**Does it crawl whole sites?** No, it reads the pages you list. Give it the pages you want (for example from a
sitemap).

**Can I download from any website?** Only download what you are allowed to. The Actor respects robots.txt by
default; turn it off only for sites you own or may download from. Images may be protected by copyright; using
them is your responsibility.

**Can I give a CSV or text file of links?** Yes: put its link in `urlListFile` (a `.txt`, `.csv`, `.tsv` or JSON
file, for example an export from a spreadsheet or a Dropbox/Google Drive share link). Every http(s) link in it is
read, in any column; reading the list is free. Its URLs are added after `urls`.

**Do Dropbox and Google Drive links work?** Yes, share links of a single file that is shared with anyone who has
the link (`dropbox.com/s/…`, `dropbox.com/scl/fi/…`, `drive.google.com/file/d/…/view`). Private files and folder
links do not: you get a free `share_link_not_public` row.

**Can it compress images to a file size?** Yes: `targetSizeKb` (0 = off). JPEG and WebP keep their format and
get the highest quality that fits (not below 30); PNG first becomes a 256-colour palette; only if that is still
too big is the image scaled down (never below 64 px). Files already small enough are kept byte for byte. If a
file cannot reach the size, the smallest version is saved with `overTargetSize: true`. The run summary has
`imagesOverTargetSize` and `bytesSavedByCompression`. Compression is included in the file price.

**Are SVGs supported?** Yes, saved as they are (with width and height when the file states them). Conversion
applies to raster images only. Animated GIFs are kept as they are unless you convert them (then the first frame
is kept).

### Limitations

- Up to 1,000 URLs, 10,000 files and 50 MB per file per run (`maxFileSizeMb`, up to 500); the ZIP is skipped
  above 2 GB (the files stay in the key-value store).
- No logins, no proxies, no JavaScript rendering.

### Credits

Built with the Apify SDK for Python and Pillow (HPND licence). No third-party API is used.

# Actor input Schema

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

Web pages (every image in their HTML is downloaded: img, srcset at the largest size, lazy-load data-src, picture, og:image, CSS backgrounds) and/or direct links to images or files (downloaded as they are). Dropbox and Google Drive share links of an image or file (shared with anyone who has the link) work. Up to 1,000 URLs per run. One row per file.

## `urlListFile` (type: `string`):

Link to a .txt, .csv, .tsv or JSON file that lists the pages or image links (one per line, or in any CSV column; header rows are ignored). Its URLs are added after "urls"; the 1,000-URL limit covers both. A Dropbox or Google Drive share link to the file works. Reading the list is free. Leave empty to use only "urls".

## `maxFiles` (type: `integer`):

Stop after this many files are saved (each saved file is charged once). Default 500.

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

Download at most this many image links from one page (in page order). Default 200.

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

Skip images narrower than this (icons, thumbnails). Skipped images are free. Default 0 (keep all). 1x1 tracking pixels are always skipped.

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

Skip images lower than this. Skipped images are free. Default 0 (keep all).

## `convertTo` (type: `string`):

original (default) keeps each file byte for byte. webp, jpeg or png re-encodes raster images (SVG and non-image files are kept as they are). Included in the file price.

## `maxDimension` (type: `integer`):

Shrink images whose longer side is larger than this, keeping the aspect ratio (never enlarges). 0 (default) = no resizing.

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

Quality 30-100 when images are converted or resized to JPEG or WebP. Default 85.

## `targetSizeKb` (type: `integer`):

Image compressor: make every raster image at most this many kilobytes (for example 200 for web pages, 1000 for upload limits). JPEG and WebP get a lower quality (down to 30), PNG a 256-colour palette, and only if that is not enough the image is scaled down. Keeps the format unless 'Convert images to' is set. Rows show bytes before and after and overTargetSize. Animated images and SVG are kept as they are. 0 (default) = no limit. Included in the file price.

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

Skip files whose content (SHA-256) was already saved in this run, for example the same logo on every page. Duplicates are free. Default true.

## `createZip` (type: `boolean`):

Also put all saved files into one images.zip in the key-value store (folders by site). The link is in the run summary (SUMMARY.zipUrl). Default true.

## `linkedFileTypes` (type: `array`):

File types to download when a page links to them (a href), besides images: pdf, svg, zip, csv, xlsx, docx, pptx, mp4, mp3, json, txt. Default: none (images only).

## `includeCssBackgrounds` (type: `boolean`):

Also take images from inline style attributes and style blocks (background-image: url(...)). Default true.

## `includeMetaImages` (type: `boolean`):

Also take the page's og:image and twitter:image (social preview) images. Default true.

## `sameSiteOnly` (type: `boolean`):

Skip images hosted on other domains than the page (ads, trackers, embeds). CDN subdomains of the same site are kept. Default false.

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

Files larger than this fail (free). Default 50.

## `respectRobotsTxt` (type: `boolean`):

Skip pages and files that the site's robots.txt disallows for bots (free rows). Default true; turn off only for sites you own or may download from.

## Actor input object example

```json
{
  "urls": [
    "https://books.toscrape.com/",
    "https://example.com/photo.jpg"
  ],
  "urlListFile": "https://example.com/image-links.csv",
  "maxFiles": 20,
  "maxImagesPerPage": 200,
  "minWidth": 0,
  "minHeight": 0,
  "convertTo": "original",
  "maxDimension": 0,
  "quality": 85,
  "targetSizeKb": 0,
  "dedupe": true,
  "createZip": true,
  "linkedFileTypes": [
    "pdf"
  ],
  "includeCssBackgrounds": true,
  "includeMetaImages": true,
  "sameSiteOnly": false,
  "maxFileSizeMb": 50,
  "respectRobotsTxt": true
}
```

# Actor output Schema

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

No description

## `zip` (type: `string`):

No description

## `files` (type: `string`):

No description

## `summary` (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://books.toscrape.com/"
    ],
    "maxFiles": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("webstack-labs/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://books.toscrape.com/"],
    "maxFiles": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("webstack-labs/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://books.toscrape.com/"
  ],
  "maxFiles": 20
}' |
apify call webstack-labs/bulk-image-downloader --silent --output-dataset

```

## MCP server setup

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