Skip to content

Commit 268ea70

Browse files
tsmith512dcpenaOxyjun
authored
[Images] Various Updates (#20152)
* [Images] Updates * a typo * Apply suggestions from code review Co-authored-by: Jun Lee <[email protected]> * Updated date * Added example --------- Co-authored-by: Denise Peña <[email protected]> Co-authored-by: Jun Lee <[email protected]> Co-authored-by: Denise Pena <[email protected]>
1 parent 634d52d commit 268ea70

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: "Bind the Images API to your Worker"
3+
description: >
4+
You can now interact with the Images API directly in your Worker with Image Bindings.
5+
date: 2025-02-24T12:00:00Z
6+
---
7+
8+
You can now [interact with the Images API](/images/transform-images/bindings/) directly in your Worker.
9+
10+
This allows more fine-grained control over transformation request flows and cache behavior. For example, you can resize, manipulate, and overlay images without requiring them to be accessible through a URL.
11+
12+
The Images binding can be configured in the Cloudflare dashboard for your Worker or in the `wrangler.toml` file in your project's directory:
13+
14+
``` toml
15+
[images]
16+
binding = "IMAGES" # i.e. available in your Worker on env.IMAGES
17+
```
18+
19+
Within your Worker code, you can interact with this binding by using `env.IMAGES`.
20+
21+
Here's how you can rotate, resize, and blur an image, then output the image as AVIF:
22+
23+
```js
24+
​​const info = await env.IMAGES.info(stream);
25+
// stream contains a valid image, and width/height is available on the info object
26+
27+
const response = (
28+
await env.IMAGES.input(stream)
29+
.transform({ rotate: 90 })
30+
.transform({ width: 128 })
31+
.output({ format: "image/avif" })
32+
).response();
33+
34+
return response;
35+
```
36+
37+
For more information, refer to [Images Bindings](/images/transform-images/bindings/).

0 commit comments

Comments
 (0)