Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
9073d75
[Media] cf-cli: add cloudflare.config.ts and cf dev to Media Transfor…
MattieTK Nov 30, 2026
263dcf7
[Images] cf-cli: add cloudflare.config.ts and cf dev to optimization …
MattieTK Nov 30, 2026
abd25ec
[Images] cf-cli: add cloudflare.config.ts and cf dev to storage binding
MattieTK Nov 30, 2026
2885167
[Images] cf-cli: add cloudflare.config.ts to optimize-user-uploaded-i…
MattieTK Nov 30, 2026
28b542d
[Images] cf-cli: add cloudflare.config.ts to watermark-from-kv example
MattieTK Nov 30, 2026
e13e1df
[Images] cf-cli: add cf secrets and signing key commands to serve-pri…
MattieTK Nov 30, 2026
4645187
[Images] cf-cli: add cf dev to transform-via-workers and url local de…
MattieTK Nov 30, 2026
9d21d36
[Images] cf-cli: add cf images commands to delete-images and variants…
MattieTK Nov 30, 2026
a45697b
[Stream] cf-cli: add cloudflare.config.ts to Stream Workers binding
MattieTK Nov 30, 2026
eca0f54
[Stream] cf-cli: add cf CLI and cloudflare.config.ts to test-webhooks…
MattieTK Nov 30, 2026
d191935
[Stream] cf-cli: add cf CLI and cloudflare.config.ts to get-started
MattieTK Nov 30, 2026
989ea8d
[Stream] cf-cli: add cf CLI and cloudflare.config.ts to upload-via-li…
MattieTK Nov 30, 2026
1a90879
[Stream] cf-cli: add cf CLI and cloudflare.config.ts to creator-id
MattieTK Nov 30, 2026
0f6418a
[Stream] cf-cli: add cf CLI and cloudflare.config.ts to adding-captions
MattieTK Nov 30, 2026
d1f9e7c
[Stream] cf-cli: add cf CLI and cloudflare.config.ts to applying-wate…
MattieTK Nov 30, 2026
fbfe2c9
[Stream] cf-cli: add cf CLI and cloudflare.config.ts to download-videos
MattieTK Nov 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/content/docs/images/examples/watermark-from-kv.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,21 @@ import { TypeScriptExample, WranglerConfig } from "~/components";

Enable [Workers Cache](/workers/cache/) so repeat requests for the same watermarked image are served from cache without re-running the Worker or re-transforming the image:

<WranglerConfig>
<WranglerConfig
cfConfig={`import { defineConfig } from "cf/config";
import * as entrypoint from "./src/index.ts" with { type: "cf-worker" };

export default defineConfig({
worker: {
name: "my-worker",
compatibilityDate: "$today",
entrypoint,
cache: {
enabled: true,
},
},
});`}
>

```jsonc
{
Expand Down
126 changes: 121 additions & 5 deletions src/content/docs/images/optimization/binding.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ products:
- workers
---

import { WranglerConfig, TypeScriptExample } from "~/components";
import {
CliVariant,
CliVariants,
TypeScriptExample,
WranglerConfig,
} from "~/components";

A [binding](/workers/runtime-apis/bindings/) connects your [Worker](/workers/) to external resources on the Developer Platform, like [Images](/images/), [R2 buckets](/r2/buckets/), or [KV namespaces](/kv/concepts/kv-namespaces/).

Expand All @@ -21,8 +26,19 @@ With the Images binding, you can:
- Resize an image, overlay a watermark, then resize the combined output into a final result — all in a single chain of operations.
- Control the order of operations for optimization parameters. When you use the URL interface, the optimization parameters follow a fixed order of operations.

<CliVariants>
<CliVariant cli="wrangler">

Bindings can be configured in the Cloudflare dashboard for your Worker or in the Wrangler configuration file in your project's directory.

</CliVariant>
<CliVariant cli="cf">

Bindings can be configured in the Cloudflare dashboard for your Worker or in [`cloudflare.config.ts`](/cf/projects/cloudflare-config/) in your project's directory.

</CliVariant>
</CliVariants>

:::note[Billing]

Calls to the Images binding are billed as [unique transformations](/images/pricing/#images-transformed): each unique combination of source image and parameters is billed only once per calendar month, and repeat requests within the same month do not incur additional usage. Calls to [`.info()`](#infostream) are free.
Expand All @@ -35,11 +51,38 @@ Refer to [Images pricing](/images/pricing/) for more information about billing.

The Images binding is enabled on a per-Worker basis.

<CliVariants>
<CliVariant cli="wrangler">

You can define variables in the Wrangler configuration file of your Worker project's directory. These variables are bound to external resources at runtime, and you can then interact with them through this variable.

To bind Images to your Worker, add the following to the end of your Wrangler configuration file:

<WranglerConfig>
</CliVariant>
<CliVariant cli="cf">

You can define bindings in [`cloudflare.config.ts`](/cf/projects/cloudflare-config/) in your Worker project's directory. These bindings connect to external resources at runtime and are exposed on `env`.

To bind Images to your Worker, add `bindings.images()` to `worker.env` in `cloudflare.config.ts`:

</CliVariant>
</CliVariants>

<WranglerConfig
cfConfig={`import { bindings, defineConfig } from "cf/config";
import * as entrypoint from "./src/index.ts" with { type: "cf-worker" };

export default defineConfig({
worker: {
name: "my-worker",
compatibilityDate: "$today",
entrypoint,
env: {
IMAGES: bindings.images(), // available in your Worker on env.IMAGES
},
},
});`}
>

```jsonc
{
Expand All @@ -61,9 +104,34 @@ An operation starts with a source method — `.input()` for an image or `.text()

Responses from the Images binding are not automatically cached. Every uncached call performs a full decode and re-encode of the source image, which adds unnecessary latency to every request.

<CliVariants>
<CliVariant cli="wrangler">

We strongly recommend enabling [Workers Cache](/workers/cache/) so that repeat requests are served from cache without re-running your Worker or re-transforming the image. Add the following to your Wrangler configuration file:

<WranglerConfig>
</CliVariant>
<CliVariant cli="cf">

We strongly recommend enabling [Workers Cache](/workers/cache/) so that repeat requests are served from cache without re-running your Worker or re-transforming the image. Enable `cache` in `cloudflare.config.ts`:

</CliVariant>
</CliVariants>

<WranglerConfig
cfConfig={`import { defineConfig } from "cf/config";
import * as entrypoint from "./src/index.ts" with { type: "cf-worker" };

export default defineConfig({
worker: {
name: "my-worker",
compatibilityDate: "$today",
entrypoint,
cache: {
enabled: true,
},
},
});`}
>

```jsonc
{
Expand Down Expand Up @@ -227,6 +295,9 @@ Outputs information about the image, such as `format`, `fileSize`, `width`, and

## Interact with your Images binding locally

<CliVariants>
<CliVariant cli="wrangler">

You can use the Images API in local development through [Wrangler](/workers/wrangler/install-and-update/). The local simulator does not incur usage charges.

Wrangler supports two different versions of the Images API:
Expand All @@ -236,16 +307,61 @@ Wrangler supports two different versions of the Images API:

To test the low-fidelity version of Images, you can run `wrangler dev`:

```txt
```sh
npx wrangler dev
```

The local simulator supports `.info()` and transformations such as resizing and rotation. When resizing, you can also set `fit`, `gravity`, and `background`. Use `format` to choose the output format.

To test the full Images API while running your Worker locally, set `remote: true` on the Images binding in your Wrangler configuration. To run both your Worker and the binding on Cloudflare, use `wrangler dev --remote`:

```txt
```sh
npx wrangler dev --remote
```

</CliVariant>
<CliVariant cli="cf">

You can use the Images API in local development through the [Cloudflare CLI (`cf`)](/cf/). The local simulator does not incur usage charges.

Local development supports two versions of the Images API:

- A high-fidelity remote version that supports all features available through the Images API. This is the same version that Cloudflare runs globally in production.
- A low-fidelity offline version that supports only a subset of features, such as resizing and rotation.

To test the low-fidelity offline version, run:

```sh
cf dev
```

The local simulator supports `.info()` and transformations such as resizing and rotation. When resizing, you can also set `fit`, `gravity`, and `background`. Use `format` to choose the output format.

To test the full Images API while running your Worker locally, set `dev: { remote: true }` on `bindings.images()` in `cloudflare.config.ts`:

```ts title="cloudflare.config.ts"
import { bindings, defineConfig } from "cf/config";
import * as entrypoint from "./src/index.ts" with { type: "cf-worker" };

export default defineConfig({
worker: {
name: "my-worker",
compatibilityDate: "<COMPATIBILITY_DATE>",
entrypoint,
env: {
IMAGES: bindings.images({ dev: { remote: true } }),
},
},
});
```

Then start the local development server:

```sh
cf dev
```

</CliVariant>
</CliVariants>

When testing with the [Workers Vitest integration](/workers/testing/vitest-integration/), the low-fidelity offline version is used by default, to avoid hitting the Cloudflare API in tests.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ Resize via the Cloudflare dashboard.
4. Name your variant and select **Create**.
5. Define variables for your new variant, such as resizing options, type of fit, and specific metadata options.

## Create a variant via the Cloudflare CLI (`cf`)

Run `cf images variants create` with the variant ID and sizing options:

```sh
cf images variants create \
--id <NAME_OF_THE_VARIANT> \
--options-fit scale-down \
--options-metadata none \
--options-width 1366 \
--options-height 768 \
--never-require-signed-urls
```

## Resize via the API

Make a `POST` request to [create a variant](/api/resources/images/subresources/v1/subresources/variants/methods/create/).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ products:

import { DashButton } from "~/components";

You can delete variants via the Images dashboard or API. The only variant you cannot delete is public.
You can delete variants via the Images dashboard, the [Cloudflare CLI (`cf`)](/cf/), or the API. The only variant you cannot delete is public.

:::caution

Expand All @@ -28,6 +28,14 @@ Deleting a variant is a global action that will affect other images that contain

3. Find the variant you want to remove and select **Delete**.

## Delete variants via the Cloudflare CLI (`cf`)

Run `cf images variants delete` with the variant name:

```sh
cf images variants delete <VARIANT_NAME>
```

## Delete variants via the API

Make a `DELETE` request to the delete variant endpoint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ products:
- images
---

import { TypeScriptExample, DashButton } from "~/components";
import {
CliVariant,
CliVariants,
DashButton,
TypeScriptExample,
} from "~/components";

You can serve private images by using signed URL tokens. When an image requires a signed URL, the image cannot be accessed without a token unless it is being requested for a variant set to always allow public access.

Expand All @@ -19,6 +24,8 @@ You can serve private images by using signed URL tokens. When an image requires
2. Select **Keys**.
3. Copy your key and use it to generate an expiring tokenized URL.

You can also list or create signing keys with the [Cloudflare CLI (`cf`)](/cf/) using `cf images keys list` or `cf images keys create <SIGNING_KEY_NAME>`.

:::note

Private images do not currently support custom paths.
Expand All @@ -32,7 +39,20 @@ Signed URLs are generated server-side to protect your signing key. The example b
The Worker accepts a regular Images URL and returns a signed URL that expires after one day. Adjust the `EXPIRATION` value to set a different expiry period.

:::note

<CliVariants>
<CliVariant cli="wrangler">

Never hardcode your signing key in source code. Store it as a secret using [`npx wrangler secret put`](/workers/wrangler/commands/general/#secret) and access it via the `env` parameter. For more information, refer to [Secrets](/workers/configuration/secrets/).

</CliVariant>
<CliVariant cli="cf">

Never hardcode your signing key in source code. Declare `IMAGES_SIGNING_KEY: bindings.secret()` in [`cloudflare.config.ts`](/cf/projects/cloudflare-config/), provide its value with `cf deploy --secrets-file <PATH>` on initial deployment (or update it on an existing Worker with `cf workers secrets update IMAGES_SIGNING_KEY --worker <WORKER_NAME> --type secret_text --text "<VALUE>"`), and access it via the `env` parameter. For more information, refer to [Secrets](/workers/configuration/secrets/).

</CliVariant>
</CliVariants>

:::

<TypeScriptExample>
Expand Down Expand Up @@ -93,7 +113,7 @@ export default {
.slice(1)
.replace("https:/imagedelivery.net", "https://imagedelivery.net"),
);
// IMAGES_SIGNING_KEY is set via `npx wrangler secret put IMAGES_SIGNING_KEY`
// IMAGES_SIGNING_KEY is stored as a Worker secret
return generateSignedUrl(imageDeliveryURL, env.IMAGES_SIGNING_KEY);
},
} satisfies ExportedHandler<Env>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ products:
- workers
---

import { Render } from "~/components";
import { CliVariant, CliVariants, Render } from "~/components";

Workers lets you optimize images with a custom URL scheme.

Expand Down Expand Up @@ -90,8 +90,19 @@ The script preview of the Worker editor ignores `fetch()` options, and will alwa

## Local development

<CliVariants>
<CliVariant cli="wrangler">

When running `wrangler dev`, `cf.image` transformations are applied locally using a low fidelity mock.

</CliVariant>
<CliVariant cli="cf">

When running `cf dev`, `cf.image` transformations are applied locally using a low fidelity mock.

</CliVariant>
</CliVariants>

A subset of options are supported, including resize, rotate, format, and background colour. Unsupported options are ignored.

## Error handling
Expand Down
37 changes: 35 additions & 2 deletions src/content/docs/images/optimization/transformations/url.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ products:
- images
---

import { DashButton, AnchorHeading, Steps, WranglerConfig } from "~/components";
import {
AnchorHeading,
CliVariant,
CliVariants,
DashButton,
Steps,
WranglerConfig,
} from "~/components";

Use transformation URLs to optimize images from any origin. [Optimization parameters](/images/optimization/features) tell Images how to process an image, such as setting its [quality](/images/optimization/features/#quality), [format](/images/optimization/features/#format), and [size](/images/optimization/features/#width), and other options.

Expand Down Expand Up @@ -150,18 +157,44 @@ allowed_origins = [

</WranglerConfig>

Run `wrangler deploy` or `cf deploy` to apply them to the deployed Worker. For local development, run `wrangler dev` or `cf dev`.
<CliVariants>
<CliVariant cli="wrangler">

Run `wrangler deploy` to apply them to the deployed Worker. For local development, run `wrangler dev`.

Named Wrangler environments do not inherit `images.url_transformations`.

[Version URLs](/workers/versions-and-deployments/version-urls/) support the URL interface using the Worker's deployed settings, rather than version-specific settings. `wrangler versions upload` does not update `images.url_transformations`.

</CliVariant>
<CliVariant cli="cf">

Run `cf deploy` to apply them to the deployed Worker. For local development, run `cf dev`.

[Version URLs](/workers/versions-and-deployments/version-urls/) support the URL interface using the Worker's deployed settings, rather than version-specific settings. Uploading a version with `cf workers versions create` does not update `worker.images.urlTransformations`.

</CliVariant>
</CliVariants>

### Local development

<CliVariants>
<CliVariant cli="wrangler">

You can use the URL interface in local development through [Wrangler](/workers/wrangler/), the command-line interface for Workers. Usage in local development does not incur billable usage.

Set `images.url_transformations.enabled` to `true` to enable URLs locally.

</CliVariant>
<CliVariant cli="cf">

You can use the URL interface in local development through the [Cloudflare CLI (`cf`)](/cf/). Usage in local development does not incur billable usage.

Set `worker.images.urlTransformations.enabled` to `true` in `cloudflare.config.ts` to enable URLs locally.

</CliVariant>
</CliVariants>

In local development, transformation URLs always accept relative sources; any allowed origins are additional.

Local transformations use a low-fidelity offline version that supports a limited subset of features such as resizing, rotation, and format conversion. Deploy your Worker to test complete production behavior.
Expand Down
Loading