Images
Source:
src/Cloudflare/Images/Images.ts
A Cloudflare Images binding for image transformation inside Workers — a Worker-only binding with no backing cloud resource.
Images is a single value that is at once the Binding.Service tag, the
callable that produces an ImagesBinding, and the type. Declare it on a
Worker’s env (it flows through InferEnv → cf.ImagesBinding) or yield*
it inside an Effect-native Worker to attach the binding and obtain the
ImagesClient.
Effect-style Worker (recommended)
Section titled “Effect-style Worker (recommended)”import { HttpServerRequest } from "effect/unstable/http/HttpServerRequest";
Cloudflare.Worker("ImageWorker", { main: import.meta.url }, Effect.gen(function* () { const images = yield* Cloudflare.Images.Images("PIPELINE"); return { fetch: Effect.gen(function* () { const request = yield* HttpServerRequest; const info = yield* images.info(request.stream); return yield* HttpServerResponse.json(info); }), }; }).pipe(Effect.provide(Cloudflare.Images.ImagesBinding)),);Binding to a Worker (declarative)
Section titled “Binding to a Worker (declarative)”export const Worker = Cloudflare.Worker("Worker", { main: "./src/worker.ts", env: { MEDIA: Cloudflare.Images.Images("PIPELINE") },});
export type WorkerEnv = Cloudflare.InferEnv<typeof Worker>;// { MEDIA: ImagesBinding }Local development
Section titled “Local development”// Default: transforms run locally via Sharp under `alchemy dev` and// hosted images are stored on disk. Alchemy.remote() opts the binding// into the real Images service instead — in an Effect-native Worker:const images = yield* Cloudflare.Images.Images("IMAGES").pipe(Alchemy.remote());
// or declared on an async Worker's env:env: { IMAGES: Cloudflare.Images.Images("IMAGES").pipe(Alchemy.remote()) }