Transform Images with Wasm in a Cloudflare Worker
Prototype demonstrating running image resizing and other transforms completely inside a Cloudflare Worker.
Sample input images come from Unsplash .
Source is available in the Denoflare repo .
Deploy it to your own account
Since it is a standard module-based Cloudflare Worker, you can deploy it like any other worker with denoflare push
:
First, register a new app with Unsplash (free), you'll need your app name and ixid as worker environment vars, to comply their TOS.
denoflare push --name image-demo \
https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/examples/image-demo-worker/worker.ts \
--text-binding unsplashAppName:your_app_name \
--text-binding unsplashIxid:your_ixid
Host it locally
Since it is a standard module-based Cloudflare Worker, you can run it locally like any other worker with denoflare serve
:
First, register a new app with Unsplash (free), you'll need your app name and ixid as worker environment vars, to comply their TOS.
denoflare serve \
https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/examples/image-demo-worker/worker.ts
--text-binding unsplashAppName:your_app_name \
--text-binding unsplashIxid:your_ixid