Skip to content

Images

Images is a bounded local raster-transform binding. Input is request-body bytes. Transforms run on the node running ocd. This is not hosted Cloudflare Images.

For example, you can use Images for:

  • Resizing and converting request-body images
  • Overlay and output jpeg / png / webp / avif
  • Inspecting format with info()
ts
export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    if (!request.body) return new Response("empty", { status: 400 });
    const out = await env.IMAGES
      .input(request.body)
      .transform({ width: 200, fit: "scale-down" })
      .output({ format: "image/webp" });
    return out.response();
  },
} satisfies ExportedHandler<{ IMAGES: ImagesBinding }>;

Declare it in open-compute.json. Images is not a resource id in bindings. Use top-level "images": { "binding": "IMAGES" } only:

json
{
  "name": "img-app",
  "main": "src/index.ts",
  "images": { "binding": "IMAGES" }
}

See bindings. The CLI is oc / oc run / oc types.

Compatibility

TopicCloudflareopen-compute
Binding APIImages binding chainSame chain: inputtransform / drawoutputresponse(), plus info()
ProductHosted Cloudflare ImagesBounded local raster binding
InputHosted image id or URLReadableStream bytes
Upload / signingAvailableNot provided
URL transformAvailableNot provided
VideoAvailableNot provided
AI upscaleAvailableNot provided
Bindingwrangler images"images": { "binding": "IMAGES" }

Next