fa680b7ca92d87e041220c865d1e643eaf5a2a47
Cloudflare Image Converter
A Cloudflare Worker 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; at least one must be provided.- If only
widthis supplied the height is inferred from the source aspect ratio, and vice versa.
- If only
format(optional): Desired output format (e.g.,jpeg,png,webp). If not specified, defaults towebp.
Returns: The transformed image encoded in its original format (JPEG, PNG, or WebP). The Content-Type mirrors the source.
GET /meta/?url=<image_url>
Returns JSON:
{
"width": <number>,
"height": <number>,
"thumbHash": "<base64>"
}
thumbHashis a ThumbHash placeholder that can be rendered on the client for a quick preview.
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.
Languages
TypeScript
92.9%
JavaScript
7.1%