|
|
||
|---|---|---|
| cloudflare | ||
| supabase | ||
| .gitignore | ||
| README.md | ||
README.md
Edge Image Transformer
An Edge function built with Hono and jSquash for on-demand image resizing and metadata retrieval.
Routes
GET /?url=<image_url>&width=<width>&height=<height>&format=<format>
url(required): Absolute URL of the source image.width,height(optional): Desired output dimensions.- Supply one or both values to resize while preserving the source aspect ratio.
- If neither is provided, the original image is returned unchanged.
format(optional): Desired output format (e.g.,jpeg,png,webp,avif). If not specified, the source format is preserved.
Returns: The transformed image encoded in the requested format when provided, otherwise the source format. The Content-Type mirrors the output.
GET /meta/?url=<image_url>
Returns JSON:
{
"width": <number>,
"height": <number>
}
Local Development
pnpm install
pnpm dev
pnpm devruns Vite with the Cloudflare Workers dev server adapter.
Build & Deploy
pnpm build # Emits dist/worker_image_transformations
pnpm deploy # Builds and deploys via Wrangler
Cloudflare Type Synchronisation
Whenever wrangler.jsonc changes, refresh the generated bindings:
pnpm cf-typegen
This command updates the CloudflareBindings type so that Hono routes have accurate autocompletion.