---
title: "Build a Simple Image Resizing API in less than 100 LOC"
description: "An HTTP image resizing API built on Deno uses imagemagick_deno, ImageMagick compiled to WebAssembly, and fits in under 100 lines of TypeScript."
url: "https://swe.quest/articles/build-a-simple-image-resizing-api-in-less-than-100-loc-5c6fb2fd73d43c52"
canonical: "https://deno.com/blog/build-image-resizing-api"
source: "Deno"
published: "2023-02-08"
difficulty: "medium"
kind: "How-to"
reading_minutes: 6
tags: ["typescript","webassembly","serverless","api-design"]
---

# Build a Simple Image Resizing API in less than 100 LOC

A post on [Deno](https://swe.quest/sources/deno.md), published 2023-02-08, 6 min read, How-to. Original: [https://deno.com/blog/build-image-resizing-api](https://deno.com/blog/build-image-resizing-api)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)
- [WebAssembly](https://swe.quest/tags/webassembly.md) (Languages)
- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)
- [API design](https://swe.quest/tags/api-design.md) (Backend & APIs)

## Prerequisites

- TypeScript basics ([easy posts on TypeScript](https://swe.quest/tags/typescript.md?difficulty=easy))
- HTTP request handling

## Keywords

Deno, Deno Deploy, ImageMagick, imagemagick\_deno, WebAssembly

## Related posts

- [wasmbuild - Using Rust in Deno and Web Apps](https://swe.quest/articles/wasmbuild-using-rust-in-deno-and-web-apps-ea6b475b6d77519e.md): Deno · 2022-06-30 · Medium · 3 min read · WebAssembly, Rust, JavaScript, Build systems
  wasmbuild 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.
- [Bun v1.3.14](https://swe.quest/articles/bun-v1-3-14-a83f03d287060048.md): Bun · 2026-05-13 · Medium · 50 min read · JavaScript, Runtimes & VMs, Networking, Build systems, Performance engineering
  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.
- [A Whole Website in a Single JavaScript File](https://swe.quest/articles/a-whole-website-in-a-single-javascript-file-71d46431d0988f5b.md): Deno · 2022-04-05 · Medium · 2 min read · JavaScript, Serverless, CDN & edge, Frontend, TypeScript
  A demo multi-page website fits entirely in one JavaScript file and is server-rendered on demand at the edge with Deno.
- [Deno 1.35: A fast and convenient way to build web servers](https://swe.quest/articles/deno-1-35-a-fast-and-convenient-way-to-build-web-servers-4272182679c6d67c.md): Deno · 2023-07-05 · Medium · 5 min read · JavaScript, TypeScript, Runtimes & VMs, Performance engineering
  Deno.serve() is now stable, replacing the connection-iterator Deno.serveHttp() pattern with a one-line handler built on web-standard Request and Response objects.
- [Supabase Storage v2: Image resizing and Smart CDN](https://swe.quest/articles/supabase-storage-v2-image-resizing-and-smart-cdn-c8ff869de30d9fa5.md): Supabase · 2022-12-13 · Medium · 8 min read · Caching, CDN & edge, Storage systems, System design
  Supabase 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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
