Skip to content

Commit 32c76fe

Browse files
authored
[Images] Add auto format option to output for Workers Bindings (#27720)
* [Images] Add auto format option to output for Workers Bindings * Updated according to EM feedback
1 parent 48ad4a0 commit 32c76fe

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/content/docs/images/transform-images/bindings.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,25 @@ return response;
7777

7878
### `.output()`
7979

80-
- Defines the [output format](/images/transform-images/) for the transformed image such as AVIF, WebP, and JPEG.
81-
- Image [quality](/images/transform-images/transform-via-url/#quality) can be altered by specifying `quality` on a 1-100 scale.
80+
- You must define [a supported format](/images/transform-images/#supported-output-formats) such as AVIF, WebP, or JPEG for the [transformed image](/images/transform-images/).
81+
- This is required since there is no default format to fallback to.
82+
- [Image quality](/images/transform-images/transform-via-url/#quality) can be altered by specifying `quality` on a 1-100 scale.
8283

8384
For example, to rotate, resize, and blur an image, then output the image as AVIF:
8485

8586
```ts
8687
const info = await env.IMAGES.info(stream);
87-
// stream contains a valid image, and width/height is available on the info object
88+
// Stream contains a valid image, and width/height is available on the info object
89+
90+
// You can determine the format based on the use case
91+
const outputFormat = "image/avif";
8892

8993
const response = (
9094
await env.IMAGES.input(stream)
9195
.transform({ rotate: 90 })
9296
.transform({ width: 128 })
9397
.transform({ blur: 20 })
94-
.output({ format: "image/avif" })
98+
.output({ format: outputFormat })
9599
).response();
96100

97101
return response;

0 commit comments

Comments
 (0)