# Placeholder images

OpenAPI: [/api/placeholder/openapi.json](/api/placeholder/openapi.json) · Catalog: [/api/placeholder/catalog.json](/api/placeholder/catalog.json) · Tool: [/tools/placeholder-images](/tools/placeholder-images)

Generate an image with `GET /api/placeholder/image.svg`, `image.png`, or `image.jpg`. No account or API key is required. These file extensions allow CDNs to cache image responses. The original `/api/placeholder` endpoint remains supported.

```text
/api/placeholder/image.svg
/api/placeholder/image.png?width=640&height=360&text=Hello&bg=172033&color=ffffff
/api/placeholder/image.jpg?width=1200&height=630&image=nature-1&text=Your%20title
/api/placeholder/image.jpg?random
/api/placeholder/image.jpg?category=food&random
/api/placeholder/image.jpg?width=400&height=400&category=travel&seed=1&text=
```

## Endpoints

| Endpoint | Returns |
| --- | --- |
| `GET /api/placeholder/image.{svg,png,jpg}` | The image, ready for an `img` src. |
| `GET /api/placeholder/catalog.json` | The categories and every photo ID, with image, original and thumbnail URLs, and a random-photo URL for each category. |
| `GET /api/placeholder/openapi.json` | The API described in OpenAPI 3.1. |
| `GET /api/placeholder?format=svg` | The original endpoint, with the format as a parameter. |

## Parameters

| Parameter | Values | Default |
| --- | --- | --- |
| `width`, `height` | Integers 1 to 4096. Maximum area 4,000,000 pixels. | 800, 450 |
| `format` | Legacy endpoint output format. On file URLs, omit it or match the extension. `jpeg` is an alias for `jpg`. | File extension, or `svg` on the legacy endpoint |
| `text` | Up to 200 Unicode characters and 12 lines. URL-encode text. Set `text=` to hide it. | Image dimensions for solid backgrounds, empty for photos |
| `bg` | Three or six hex digits, optional URL-encoded `#`. Applies to solid backgrounds. | `eaf0f5` |
| `color` | Three or six hex digits. | `111820` for solid backgrounds, `ffffff` for photos |
| `fontSize` | Integer 8 to 256. Text shrinks to fit the image. | 48 |
| `image` | A background ID listed below. | None |
| `category` | A category listed below. Use either `image` or `category`. | None |
| `seed` | Integer 0 to 2147483647. Selects a stable image within a category. Not with `random`. | 0 |
| `random` | A flag with no value (`random=1` and `random=true` also work). A different photo on every request: from `category` if given, otherwise from the whole library. Not with `image` or `seed`. | Off |
| `overlay` | Black photo overlay, integer 0 to 80 percent. | 0 |
| `quality` | JPG quality, integer 40 to 95. | 85 |

Omit `image` and `category` for a solid background. Background photos are center-cropped. SVG files embed the photograph, so downloaded files do not depend on another URL. Photo details remain raster within SVG. Prefer JPG for embedded photographs to avoid the original photo and base64 overhead in SVG. Seed selection repeats as it cycles through the available images in a category.

## Text

- `text` sets the label: up to 200 characters on up to 12 lines. URL-encode it: `%20` is a space and `%0A` a new line, as in `text=Line%20one%0ALine%20two`.
- Without `text`, solid backgrounds show the size (`800 × 450`) and photos show nothing. `text=` with no value hides the label.
- `color` sets the text colour and `fontSize` the size (8 to 256 pixels). Text that does not fit shrinks.
- On photos, `overlay` darkens the image (0 to 80 percent) so light text stands out: `image.jpg?image=travel-2&overlay=40&text=Summer%20trip`.

## Random photos

`random` picks a different photo for every request, so a page shows a new one on each load: `image.jpg?random` from the whole library, `image.jpg?category=food&random` from one category. These responses are sent with `Cache-Control: no-store`, so neither browsers nor CDNs keep one pick. The `X-Placeholder-Image` header names the photo used. For a photo that stays the same, use `category` with `seed`, or `image` with an ID from the catalog.

## Backgrounds

| Category | Image IDs |
| --- | --- |
| `nature` | `nature-1` through `nature-12` |
| `architecture` | `architecture-1` through `architecture-12` |
| `abstract` | `abstract-1` through `abstract-12` |
| `food` | `food-1` through `food-12` |
| `workspace` | `workspace-1` through `workspace-12` |
| `travel` | `travel-1` through `travel-12` |
| `animals` | `animals-1` through `animals-12` |
| `interiors` | `interiors-1` through `interiors-12` |
| `technology` | `technology-1` through `technology-12` |

All 108 images were generated for this library, with 12 images per category. Original backgrounds are 1600 × 900 at `/placeholder/backgrounds/{image-id}.jpg`. Gallery thumbnails are 400 × 225 at `/placeholder/thumbnails/{image-id}.jpg`.

`GET /api/placeholder/catalog.json` lists every category and photo with its title and URLs. For varied but stable category images in a list, use seeds 0 through 11.

## Responses

Successful responses use `image/svg+xml`, `image/png`, or `image/jpeg`. `HEAD` returns the same metadata without a body. Cross-origin image use and canvas downloads are allowed. `OPTIONS` supports CORS preflight.

`ETag` and `If-None-Match` support `304 Not Modified`. Responses with a photo name it in `X-Placeholder-Image`. Requests with `random` are never cached. The origin allows one hour of browser caching and one day of shared caching for file URLs, with a one-hour stale-while-revalidate window. CDN settings can extend the browser TTL; symelo.com currently delivers four hours. The legacy endpoint retains five minutes of browser caching and one hour of shared caching. `X-Placeholder-Cache: HIT` identifies a memory hit. `MISS` includes disk reads and new renders. This header is stored with CDN responses; use `CF-Cache-Status` and `Age` to identify Cloudflare cache hits. Keep all query parameters in the CDN cache key. Unknown or duplicate query parameters return `400`.

Invalid input returns JSON with status `400`. A full rendering queue returns `503` and `Retry-After: 2`. Retry with backoff. Render failures return `500`. Error responses are not cached.

Labels appear in URLs and public cache entries. Use display text intended to be public.

## For AI agents

- Every page of the site is available as Markdown: send `Accept: text/markdown`, add `.md` to the path, or use `?format=markdown`. The tool page as Markdown is [/tools/placeholder-images.md](/tools/placeholder-images.md).
- Page responses carry `Link` headers to the Markdown version, [/llms.txt](/llms.txt), the OpenAPI description (`rel="service-desc"`) and this reference (`rel="service-doc"`).
- Image URLs work as they are, with no key or session. Build them from the parameters above and the IDs in the catalog.
