Build a Simple Image Resizing API in less than 100 LOC
An HTTP image resizing API built on Deno uses imagemagick_deno, ImageMagick compiled to WebAssembly, and fits in under 100 lines of TypeScript. The server validates query parameters (image URL, width and height capped at 2048, and a resize or crop mode), fetches the remote image and checks its Content-Type. It then resizes or crops it with MagickGeometry, ignoring aspect ratio only when both dimensions are given. The finished single-file app deploys to Deno Deploy via GitHub integration.
Related posts
- wasmbuild - Using Rust in Deno and Web Apps
Deno mediumAdeptwasmbuild is a Deno-run CLI script that compiles Rust crates to WebAssembly via wasm-bindgen, generates JavaScript glue code with multiple loader strategies and lazy instantiation, and optimizes output with wasm-opt. Unlike wasm-pack or wasm-bindgen-cli, it needs no globally installed tool beyond the Rust toolchain and Deno, and it targets Deno and browsers specifically. A walkthrough scaffolds a crate with `deno task wasmbuild new`, builds an `add` function, and calls it from Deno, a browser page, and Deno Deploy. URL-based Deploy deployments don't yet work because the .wasm file isn't part of the module graph.
- Bun v1.3.14
Bun mediumAdept
Bun v1.3.14 adds Bun.Image, a built-in, sharp-compatible image pipeline that benchmarks 1.2–1.4× faster than sharp on resize/encode thanks to fixed-point SIMD resize kernels and JPEG IDCT downscaling. It also adds an experimental global virtual store for isolated installs that replaces per-file clonefileat calls with per-package symlinks, cutting a warm 1,400-package install from 841 ms to 115 ms on macOS. Other additions include experimental HTTP/3 (via lsquic) in Bun.serve, experimental HTTP/2 and HTTP/3 clients for fetch() with RFC 9113 hardening against CONTINUATION floods and PING reflection, a rewritten fs.watch() on inotify/FSEvents/kqueue, and a --no-orphans mode built on PR_SET_PDEATHSIG and kqueue NOTE_EXIT.
- A Whole Website in a Single JavaScript File
Deno mediumAdeptA demo multi-page website fits entirely in one JavaScript file and is server-rendered on demand at the edge with Deno. Routing uses a small `router` module built on `URLPattern`, and JSX is rendered server-side with `nanossr`, which styles via twind. Triple-slash reference comments select exactly which TypeScript libs (dom, dom.asynciterable, deno.ns) are loaded. Hosted on Deno Deploy, the site gets a perfect PageSpeed score and is served from 29 data centers over an anycast IP at no cost.
- Deno 1.35: A fast and convenient way to build web servers
Deno mediumAdeptDeno.serve() is now stable, replacing the connection-iterator Deno.serveHttp() pattern with a one-line handler built on web-standard Request and Response objects. Deno's benchmarks against Node 18.12.1 on a bare-metal Xeon show roughly twice the hello-world throughput, with better tail latency and memory use, and npm packages using node:http get the same speedup. The release also expands Node compatibility (http, https, http2, zlib Brotli), so axios, aws-sdk, puppeteer and astro now work. Other changes include LSP auto-imports for npm and import-map specifiers, an immutable rewrite of std/semver, new std html/entities and http/user_agent modules, V8 11.6 and TypeScript 5.1.6.
- Supabase Storage v2: Image resizing and Smart CDN
Supabase mediumAdeptSupabase Storage adds on-demand image resizing via imgproxy, storage webhooks, rate-limiting and a Smart CDN that invalidates cached objects globally within about 60 seconds of an update or delete. Resizing is requested from the client through URL parameters, never upscales beyond the original, and uses resize modes that mirror CSS object-fit. The CDN builds cache keys from ETag, tenant ID, bucket and object name, stored in a global KV store. A cache manager consumes storage webhook events to refresh ETags, which avoids CDN purge limits and raised cache hit rates. The resizer and Storage API run as separate containers so they scale independently, and pricing is per transformed image rather than per transformation.