# Depth Map Generator: Image to Depth Map (Depth Anything V2) (`jumblemog/depth-map-generator`) Actor

Turn any photo into a depth map with Depth Anything V2: grayscale PNG ready for ControlNet, 3D photos and displacement, a color preview and an optional 16-bit PNG. Works with image links, Google Drive, Dropbox and uploads. No API key or GPU needed.

- **URL**: https://apify.com/jumblemog/depth-map-generator.md
- **Developed by:** [Jumble Mog](https://apify.com/jumblemog) (community)
- **Categories:** AI, For creators, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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

## Depth Map Generator: Image to Depth Map (Depth Anything V2)

Turn any photo into a **depth map** in seconds. This Actor runs [Depth Anything V2](https://github.com/DepthAnything/Depth-Anything-V2), one of the most accurate open models for monocular depth estimation, and saves a **grayscale depth map PNG** (white = near, black = far) that's ready for **ControlNet**, **3D photos**, **displacement maps** and **VFX**, plus a color preview and an optional **16-bit PNG**. Everything runs inside the Actor: no API key, no GPU and no Python setup needed.

![A 1943 portrait of a woman holding a coil of hose, with its color and grayscale depth maps](https://api.apify.com/v2/key-value-stores/Km5b4PG3kYHdZSb1E/records/depth-map-generator-portrait.jpg?signature=UnDrNS7SibdwRlX7rKGt)

![A girl sitting on a wall with Union Station in the background, with its depth maps](https://api.apify.com/v2/key-value-stores/Km5b4PG3kYHdZSb1E/records/depth-map-generator-park.jpg?signature=VzukWPd1z7EpU5WcKYQm)

![A main street with shops and people walking, with its depth maps](https://api.apify.com/v2/key-value-stores/Km5b4PG3kYHdZSb1E/records/depth-map-generator-street.jpg?signature=RVAMZ6hPX7rxf7kptEOU)

*Sample photos: Library of Congress, Farm Security Administration/Office of War Information color photographs (public domain), cropped. Each row shows the photo, the color preview and the grayscale depth map.*

### What it does

- **Makes a depth map for every image**: a grayscale PNG at the same size as the photo, where brighter means closer to the camera.
- **ControlNet ready**: the default map (near = white) is what depth ControlNets expect in Stable Diffusion, SDXL, Flux, ComfyUI and Automatic1111.
- **3D, displacement and VFX**: turn on the 16-bit PNG for 65,536 depth levels, smooth enough for displacement in Blender, 3D photo and parallax effects, fog, depth of field and relighting. Turn on `invert` for Z-depth style maps where far is white.
- **Color preview** in Inferno, Magma, Plasma, Viridis, Turbo, Jet or Bone, easier to read than grayscale.
- **Two detail levels**: standard (the model's native 518 px) for speed, high (770 px) for finer edges on hair, leaves and thin objects.
- **Reads almost any image**: JPEG, PNG, TIFF (including 16-bit), WebP, HEIC from iPhones, BMP and GIF, with EXIF rotation applied.
- **Takes images from anywhere**: direct links, Google Drive and Dropbox share links, web pages that declare a main image, or files you upload.
- **Handles batches**: give it thousands of links in one run.
- **Fair billing**: you pay per depth map. Links that fail and files that can't be read cost nothing.

### How to use it

1. Paste image links or upload images.
2. Keep the defaults or pick a detail level, palette and extra outputs.
3. Click **Start**. Each depth map appears in the **Output** tab with a preview and a download link.

You can also run it through the [Apify API](https://docs.apify.com/api/v2), on a schedule, or from Make, n8n, Zapier and other integrations.

### Input

| Field | What it does |
| --- | --- |
| `imageUrls` | Links to images, Google Drive or Dropbox share links, or pages that declare a main image. |
| `files` | Images uploaded from your computer or picked from an Apify key-value store. |
| `detail` | `standard` (default, 518 px, fast) or `high` (770 px, finer edges, about 3 times slower). Same price. |
| `invert` | Off (default): near is white. On: near is black and far is white. |
| `saveColorized` | Also save a color preview JPEG (default on). |
| `colormap` | Palette of the color preview: `inferno` (default), `magma`, `plasma`, `viridis`, `turbo`, `jet` or `bone`. |
| `save16bit` | Also save a 16-bit grayscale PNG (default off). |
| `maxImages` | Stop after this many images (default 1000). |

Example:

```json
{
  "imageUrls": [
    "https://tile.loc.gov/storage-services/service/pnp/fsac/1a34000/1a34800/1a34857r.jpg",
    "https://drive.google.com/file/d/YOUR_FILE_ID/view?usp=sharing"
  ],
  "detail": "high",
  "save16bit": true
}
```

### Output

Each image becomes one dataset item. The depth maps are saved in the run's key-value store, and the `...Url` fields are their download links:

```json
{
  "url": "https://tile.loc.gov/storage-services/service/pnp/fsac/1a34000/1a34800/1a34857r.jpg",
  "status": "ok",
  "error": null,
  "depthMapUrl": "https://api.apify.com/v2/key-value-stores/<store>/records/001-1a34857r-depth.png?signature=...",
  "colorizedUrl": "https://api.apify.com/v2/key-value-stores/<store>/records/001-1a34857r-depth-color.jpg?signature=...",
  "depthMap16Url": null,
  "fileName": "001-1a34857r-depth.png",
  "sourceImageUrl": "https://tile.loc.gov/storage-services/service/pnp/fsac/1a34000/1a34800/1a34857r.jpg",
  "inputWidth": 514,
  "inputHeight": 640,
  "width": 514,
  "height": 640,
  "detail": "standard",
  "nearIsWhite": true,
  "processingSeconds": 2.28
}
```

An image that couldn't be downloaded or read gets `status: "failed"` and an `error` that says why, and isn't billed. Download your files within your plan's data retention period, or copy them to your own storage, because run storage expires.

### Pricing

You pay one **Depth map** event per image, at the price shown on this page, whichever detail level and outputs you choose. Links that fail and files that can't be read are never charged. If you set a maximum cost per run, the Actor stops before going over it.

### Speed

With the default 2 GB of memory, a standard depth map takes about 2 to 4 seconds per image and a high-detail one about 7 to 18 seconds, after 5 to 10 seconds to start the run. More memory means more CPU: 4 GB is about twice as fast, and the price per image stays the same.

### Tips and limits

- The depth is **relative**, not in meters: it tells you which parts of the picture are nearer, scaled from 0 (farthest) to 1 (nearest) in each image. Values can't be compared between different images.
- Borders, frames and scanner edges around a photo look "near" to the model and squeeze the rest of the scene into darker tones. Crop them off for the best maps.
- Glass, mirrors, water and very dark areas can confuse any depth model.
- Depth maps are capped at 4096 px on the long side, and inputs above 25 megapixels are reduced to 25 megapixels first.
- Very wide panoramas are processed at up to twice the detail size on the long side, so their short side gets less detail.

### For AI agents and developers

This Actor works with the [Apify MCP server](https://mcp.apify.com), so AI agents can call it as a tool: pass `imageUrls` and read `depthMapUrl` from each dataset item. Every item has the same documented fields, and `status` tells you whether an image succeeded. For a direct API call:

```bash
curl -X POST "https://api.apify.com/v2/acts/jumblemog~depth-map-generator/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"imageUrls": ["https://example.com/photo.jpg"]}'
```

### Privacy

Images are downloaded into the run, processed in memory and saved only to your own Apify storage. Nothing is sent to an outside AI service.

### Credits and licenses

- Depth model: [Depth Anything V2 Small](https://huggingface.co/depth-anything/Depth-Anything-V2-Small-hf) by Lihe Yang et al. (NeurIPS 2024), Apache-2.0, run with ONNX Runtime from the [onnx-community export](https://huggingface.co/onnx-community/depth-anything-v2-small).

# Actor input Schema

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

Direct links to images (JPEG, PNG, TIFF, WebP, HEIC, BMP, GIF), Google Drive or Dropbox share links, or web pages that declare a main image. Instagram, Facebook, X, TikTok and Pinterest links aren't supported because their terms don't allow downloading.

## `files` (type: `array`):

Upload images from your computer, or pick files you already stored in an Apify key-value store.

## `detail` (type: `string`):

standard: the model's native 518 px resolution, fast and right for most uses (ControlNet, 3D photos, previews). high: 770 px, finer edges on hair, leaves and thin objects; about 3 times slower. Same price either way.

## `invert` (type: `boolean`):

By default near is white and far is black, the convention ControlNet and displacement maps use. Turn this on for Z-depth style maps where far is white.

## `saveColorized` (type: `boolean`):

Also save a color-mapped JPEG of the depth map, easier to read than grayscale.

## `colormap` (type: `string`):

Palette of the color preview.

## `save16bit` (type: `boolean`):

Also save a 16-bit grayscale PNG (65,536 depth levels instead of 256) for 3D modeling, displacement and VFX work.

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

Stop after this many images, so the cost of a run stays predictable.

## Actor input object example

```json
{
  "imageUrls": [
    "https://tile.loc.gov/storage-services/service/pnp/fsac/1a34000/1a34800/1a34857r.jpg"
  ],
  "detail": "standard",
  "invert": false,
  "saveColorized": true,
  "colormap": "inferno",
  "save16bit": false,
  "maxImages": 1000
}
```

# Actor output Schema

## `depthMaps` (type: `string`):

One item per image: download links of the grayscale depth map, color preview and optional 16-bit PNG.

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

The depth map files saved in the run's key-value store.

# 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://tile.loc.gov/storage-services/service/pnp/fsac/1a34000/1a34800/1a34857r.jpg"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("jumblemog/depth-map-generator").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://tile.loc.gov/storage-services/service/pnp/fsac/1a34000/1a34800/1a34857r.jpg"] }

# Run the Actor and wait for it to finish
run = client.actor("jumblemog/depth-map-generator").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://tile.loc.gov/storage-services/service/pnp/fsac/1a34000/1a34800/1a34857r.jpg"
  ]
}' |
apify call jumblemog/depth-map-generator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,jumblemog/depth-map-generator"
        }
    }
}
```

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/uv2hQShlYwNIr9eJO/builds/dgbQ8l83SMKbROJBW/openapi.json
