Cloudflare Images - Bind the Images API to your Worker
1y ago
Source
CloudflareCloudflare Images - Bind the Images API to your Workercloudflare.comYou can now interact with the Images API directly in your Worker. 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. The Images binding can be configured in the Cloudflare dashboard for your Worker or in the Wrangler configuration file in your project's directory: wrangler.jsonc { " images " : { " binding " : "IMAGES" , // i.e. available in your Worker on env.IMAGES }, } wrangler.toml [ images ] binding = "IMAGES" Within your Worker code, you can interact with this binding by using env.IMAGES . Here's how you can rotate, resize, and blur an image, then output the image as AVIF: const info = await env . IMAGES . info ( stream ) ; // stream contains a valid image, and width/height is available on the info object const response = ( await env . IMAGES . input ( stream ) . transform ( { rotate : 90 } ) . transform ( { width : 128 } ) . transform ( { blur : 20 } ) . output ( { format : "image/avif" } ) ) . response () ; return response ; For more information, refer to Images Bindings .
You might also wanna read
Cloudflare expands AI bot management tools with granular traffic controls for all customers
Cloudflare is celebrating the second "Content Independence Day" by expanding AI traffic management options for all website owners. Building
Workers - Simpler runtime types with @cloudflare/workers-types v5
Cloudflare·2d ago
AI Search - Manage AI Search sync jobs with Wrangler CLI
Cloudflare·3d ago
Workers - Work across multiple accounts with Wrangler auth profiles
Cloudflare·3d ago
Cache - Cache multiple versions of a URL with Vary
Cloudflare·3d ago
Cloudflare One - Hostname routing for Cloudflare Mesh
Cloudflare·3d ago

Comments
Sign in to join the conversation.
No comments yet. Be the first.